self review

This commit is contained in:
Tom Moor committed 2025-04-06 00:42:15 -04:00
1 parent 8656c21e14
commit eb3f74cf21
4 files changed
+14 -11

No files matched your search

View File
Whitespace-only changes.
@@ -66,7 +66,12 @@ export default class AuthenticationHelper {
}
/**
* Returns whether the given path can be accessed with any of the scopes.
* Returns whether the given path can be accessed with any of the scopes. We
* support scopes in the formats of:
*
* - `/api/namespace.method`
* - `namespace:scope`
* - `scope`
*
* @param path The path to check
* @param scopes The scopes to check
+1 -10
View File
@@ -1,18 +1,9 @@
import { TeamPreference } from "@shared/types";
import { Team, User, OAuthClient } from "@server/models";
import { allow } from "./cancan";
import { or, isTeamModel, isTeamMutable, and, isTeamAdmin } from "./utils";
allow(User, "createOAuthClient", Team, (actor, team) =>
and(
isTeamModel(actor, team),
isTeamMutable(actor),
!actor.isViewer,
!actor.isGuest,
!actor.isSuspended,
actor.isAdmin ||
!!team?.getPreference(TeamPreference.MembersCanCreateApiKey)
)
and(isTeamModel(actor, team), isTeamMutable(actor), actor.isAdmin)
);
allow(User, "listOAuthClients", Team, (actor, team) =>
+7
View File
@@ -17,6 +17,13 @@ export default function presentOAuthClient(oauthClient: OAuthClient) {
};
}
/**
* Important: This function is used to present the OAuth client to users
* that are not in the same workspace as the client. Be very careful about
* what you expose here.
*
* @param oauthClient The OAuth client to present
*/
export function presentPublishedOAuthClient(oauthClient: OAuthClient) {
return {
name: oauthClient.name,