mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
a06671e8ce
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
40 lines
942 B
TypeScript
40 lines
942 B
TypeScript
import { action, observable } from "mobx";
|
|
import { client } from "~/utils/ApiClient";
|
|
import User from "../User";
|
|
import ParanoidModel from "../base/ParanoidModel";
|
|
import Field from "../decorators/Field";
|
|
import Relation from "../decorators/Relation";
|
|
import OAuthClient from "./OAuthClient";
|
|
|
|
class OAuthAuthentication extends ParanoidModel {
|
|
static modelName = "OAuthAuthentication";
|
|
|
|
/** A list of scopes that this authentication has access to */
|
|
@Field
|
|
@observable
|
|
scope: string[];
|
|
|
|
@Relation(() => User)
|
|
user: User;
|
|
|
|
userId: string;
|
|
|
|
oauthClient: Pick<OAuthClient, "id" | "name" | "clientId" | "avatarUrl">;
|
|
|
|
oauthClientId: string;
|
|
|
|
lastActiveAt: string;
|
|
|
|
@action
|
|
public async deleteAll() {
|
|
await client.post(`/${this.store.apiEndpoint}.delete`, {
|
|
oauthClientId: this.oauthClientId,
|
|
scope: this.scope,
|
|
});
|
|
|
|
return this.store.remove(this.id);
|
|
}
|
|
}
|
|
|
|
export default OAuthAuthentication;
|