diff --git a/plugins/oauth/server/adapter.ts b/plugins/oauth/server/adapter.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/server/models/helpers/AuthenticationHelper.ts b/server/models/helpers/AuthenticationHelper.ts index 9f0f973e2a..97e41c2629 100644 --- a/server/models/helpers/AuthenticationHelper.ts +++ b/server/models/helpers/AuthenticationHelper.ts @@ -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 diff --git a/server/policies/oauthClient.ts b/server/policies/oauthClient.ts index 22f9c141c8..d1341ee008 100644 --- a/server/policies/oauthClient.ts +++ b/server/policies/oauthClient.ts @@ -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) => diff --git a/server/presenters/oauthClient.ts b/server/presenters/oauthClient.ts index 5148f0d7d5..2cb0ba955f 100644 --- a/server/presenters/oauthClient.ts +++ b/server/presenters/oauthClient.ts @@ -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,