mirror of
https://github.com/outline/outline.git
synced 2026-11-22 05:51:43 +03:00
This PR contains the necessary work to make Outline an OAuth provider including: - OAuth app registration - OAuth app management - Private / public apps (Public in cloud only) - Full OAuth 2.0 spec compatible authentication flow - Granular scopes - User token management screen in settings - Associated API endpoints for programatic access
20 lines
659 B
TypeScript
20 lines
659 B
TypeScript
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.isAdmin)
|
|
);
|
|
|
|
allow(User, "listOAuthClients", Team, (actor, team) =>
|
|
isTeamAdmin(actor, team)
|
|
);
|
|
|
|
allow(User, "read", OAuthClient, (actor, oauthClient) =>
|
|
or(isTeamModel(actor, oauthClient), !!oauthClient?.published)
|
|
);
|
|
|
|
allow(User, ["update", "delete"], OAuthClient, (actor, oauthClient) =>
|
|
and(isTeamModel(actor, oauthClient), isTeamMutable(actor), actor.isAdmin)
|
|
);
|