-
Notifications
You must be signed in to change notification settings - Fork 0
Restrict User Info endpoints to specific roles #382
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,9 @@ import { AllOrganizationNameList } from "@acm-uiuc/js-shared"; | |||||||||||||||||||||
| /* eslint-disable import/prefer-default-export */ | ||||||||||||||||||||||
| export const runEnvironments = ["dev", "prod"] as const; | ||||||||||||||||||||||
| export type RunEnvironment = (typeof runEnvironments)[number]; | ||||||||||||||||||||||
| export enum AppRoles { | ||||||||||||||||||||||
| export const META_ROLE_PREFIX = "__metaRole:" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export enum BaseRoles { | ||||||||||||||||||||||
| EVENTS_MANAGER = "manage:events", | ||||||||||||||||||||||
| TICKETS_SCANNER = "scan:tickets", | ||||||||||||||||||||||
| TICKETS_MANAGER = "manage:tickets", | ||||||||||||||||||||||
|
|
@@ -21,19 +23,25 @@ export enum AppRoles { | |||||||||||||||||||||
| VIEW_EXTERNAL_MEMBERSHIP_LIST = "view:externalMembershipList", | ||||||||||||||||||||||
| MANAGE_EXTERNAL_MEMBERSHIP_LIST = "manage:externalMembershipList", | ||||||||||||||||||||||
| ALL_ORG_MANAGER = "manage:orgDefinitions", | ||||||||||||||||||||||
| AT_LEAST_ONE_ORG_MANAGER = "manage:someOrg" // THIS IS A FAKE ROLE - DO NOT ASSIGN IT MANUALLY - only used for permissioning | ||||||||||||||||||||||
| VIEW_USER_INFO = "view:userInfo", | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export enum MetaRoles { | ||||||||||||||||||||||
| AT_LEAST_ONE_ORG_MANAGER = `${META_ROLE_PREFIX}manage:someOrg`, | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| export const PSUEDO_ROLES = [AppRoles.AT_LEAST_ONE_ORG_MANAGER] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const AppRoles = { ...BaseRoles, ...MetaRoles } as const; | ||||||||||||||||||||||
| export type AppRoles = BaseRoles | MetaRoles; | ||||||||||||||||||||||
| export const orgRoles = ["LEAD", "MEMBER"] as const; | ||||||||||||||||||||||
| export type OrgRole = typeof orgRoles[number]; | ||||||||||||||||||||||
| export type OrgRoleDefinition = { | ||||||||||||||||||||||
| org: typeof AllOrganizationNameList[number], | ||||||||||||||||||||||
| role: OrgRole | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
36
to
40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues in type definitions. Multiple formatting issues that will cause prettier/ESLint failures. Apply this diff: -export type OrgRole = typeof orgRoles[number];
+export type OrgRole = (typeof orgRoles)[number];
export type OrgRoleDefinition = {
- org: typeof AllOrganizationNameList[number],
- role: OrgRole
-}
+ org: (typeof AllOrganizationNameList)[number];
+ role: OrgRole;
+};📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 36-36: Replace (prettier/prettier) [error] 38-38: Replace (prettier/prettier) [error] 39-39: Insert (prettier/prettier) [error] 40-40: Insert (prettier/prettier) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const allAppRoles = Object.values(AppRoles).filter( | ||||||||||||||||||||||
| export const allAppRoles = Object.values(BaseRoles).filter( | ||||||||||||||||||||||
| (value) => typeof value === "string", | ||||||||||||||||||||||
| ).filter(value => !PSUEDO_ROLES.includes(value)); // don't assign psuedo roles by default | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const AppRoleHumanMapper: Record<AppRoles, string> = { | ||||||||||||||||||||||
| [AppRoles.EVENTS_MANAGER]: "Events Manager", | ||||||||||||||||||||||
|
|
@@ -54,4 +62,5 @@ export const AppRoleHumanMapper: Record<AppRoles, string> = { | |||||||||||||||||||||
| [AppRoles.MANAGE_EXTERNAL_MEMBERSHIP_LIST]: "External Membership List Manager", | ||||||||||||||||||||||
| [AppRoles.ALL_ORG_MANAGER]: "Organization Definition Manager", | ||||||||||||||||||||||
| [AppRoles.AT_LEAST_ONE_ORG_MANAGER]: "Manager of at least one org", | ||||||||||||||||||||||
| [AppRoles.VIEW_USER_INFO]: "User Information Viewer" | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add missing trailing comma. The last entry in the AppRoleHumanMapper object is missing a trailing comma, which will cause prettier/ESLint failures. Apply this diff: - [AppRoles.VIEW_USER_INFO]: "User Information Viewer"
+ [AppRoles.VIEW_USER_INFO]: "User Information Viewer",📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 65-65: Insert (prettier/prettier) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
| } | ||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing semicolon.
The statement is missing a semicolon, which will cause prettier/ESLint failures.
Apply this diff:
📝 Committable suggestion
🧰 Tools
🪛 ESLint
[error] 6-6: Insert
;(prettier/prettier)
🤖 Prompt for AI Agents