Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: read logs and update cors maintenance root-role permissions #8996

Merged
merged 6 commits into from
Jan 8, 2025

Conversation

Tymek
Copy link
Member

@Tymek Tymek commented Dec 18, 2024

About the changes

Additional granular permissions related to instance-level access.

  • CORS settings
  • Reading logs (both instance logs and login history)

Copy link

vercel bot commented Dec 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:55pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Jan 7, 2025 3:55pm

Copy link
Contributor

github-actions bot commented Dec 18, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@Tymek Tymek force-pushed the feat/more-maintenance-permissions branch from 343a857 to f8a62ef Compare December 19, 2024 17:42
Copy link
Contributor

@Tymek, core features have been modified in this pull request. Please review carefully!

Comment on lines +222 to 245
async setCors(
req: IAuthRequest<void, void, SetCorsSchema>,
res: Response<string>,
): Promise<void> {
const granularAdminPermissions = this.flagResolver.isEnabled(
'granularAdminPermissions',
);

if (!granularAdminPermissions) {
throw new NotFoundError();
}

if (req.body.frontendApiOrigins) {
await this.frontendApiService.setFrontendCorsSettings(
req.body.frontendApiOrigins,
req.audit,
);
res.sendStatus(204);
return;
}

throw new NotFoundError();
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous "setUiConfig" is a generic name, but it only sets CORS. For easy transition into endpoint with proper permissions it's easier to create new one, and avoid potential errors or confusion about permissions in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we could use a PATCh on the uiConfig, but we're not using PATCH that frequently... but arguably CORS is a configuration on itself, maybe it's fine not having it as part of uiConfig

@gastonfournier
Copy link
Contributor

Hi @Tymek what's the reasoning behind this PR? It's hard for me to understand why this change (i.e. context)

@Tymek
Copy link
Member Author

Tymek commented Jan 7, 2025

@gastonfournier It's to enable creating custom root-roles, that have access to only some responsibilities of Admin user.

Ticket: https://linear.app/unleash/issue/CJUX-278/[roles]-custom-root-roles-missing-admin-responsibilities

Copy link
Contributor

@gastonfournier gastonfournier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it looks good, but I think there might be a problem with cached values that might override changes made by others. Happy to approve after you check that comment

@@ -99,6 +100,7 @@ class ConfigController extends Controller {
],
});

// TODO: deprecate when removing `granularAdminPermissions` flag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a breaking change so we have to delay removing it. Meanwhile I believe you can flag the route as deprecated (for OpenAPI doc)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the process I'll follow.

src/lib/features/frontend-api/frontend-api-service.ts Outdated Show resolved Hide resolved
src/lib/openapi/spec/set-cors-schema.ts Outdated Show resolved Hide resolved
Comment on lines +222 to 245
async setCors(
req: IAuthRequest<void, void, SetCorsSchema>,
res: Response<string>,
): Promise<void> {
const granularAdminPermissions = this.flagResolver.isEnabled(
'granularAdminPermissions',
);

if (!granularAdminPermissions) {
throw new NotFoundError();
}

if (req.body.frontendApiOrigins) {
await this.frontendApiService.setFrontendCorsSettings(
req.body.frontendApiOrigins,
req.audit,
);
res.sendStatus(204);
return;
}

throw new NotFoundError();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we could use a PATCh on the uiConfig, but we're not using PATCH that frequently... but arguably CORS is a configuration on itself, maybe it's fine not having it as part of uiConfig

@Tymek
Copy link
Member Author

Tymek commented Jan 7, 2025

CORS is a configuration on itself

yes, it's also easier to find if it's 1:1 with action on a dedicated page in admin panel

Copy link
Contributor

@gastonfournier gastonfournier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG!

@Tymek Tymek merged commit dc4a760 into main Jan 8, 2025
13 checks passed
@Tymek Tymek deleted the feat/more-maintenance-permissions branch January 8, 2025 09:03
Tymek added a commit that referenced this pull request Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants