aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models/plugins/register-server-auth.model.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-23 14:10:17 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-06-23 16:00:49 +0200
commit67ed6552b831df66713bac9e672738796128d33f (patch)
tree59c97d41e0b49d75a90aa3de987968ab9b1ff447 /shared/models/plugins/register-server-auth.model.ts
parent0c4bacbff53bc732f5a2677d62a6ead7752e2405 (diff)
downloadPeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.gz
PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.zst
PeerTube-67ed6552b831df66713bac9e672738796128d33f.zip
Reorganize client shared modules
Diffstat (limited to 'shared/models/plugins/register-server-auth.model.ts')
-rw-r--r--shared/models/plugins/register-server-auth.model.ts52
1 files changed, 0 insertions, 52 deletions
diff --git a/shared/models/plugins/register-server-auth.model.ts b/shared/models/plugins/register-server-auth.model.ts
deleted file mode 100644
index fc6f0f258..000000000
--- a/shared/models/plugins/register-server-auth.model.ts
+++ /dev/null
@@ -1,52 +0,0 @@
1import { UserRole } from '@shared/models'
2import { MOAuthToken, MUser } from '@server/types/models'
3import * as express from 'express'
4
5export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions
6
7export interface RegisterServerAuthenticatedResult {
8 username: string
9 email: string
10 role?: UserRole
11 displayName?: string
12}
13
14export interface RegisterServerExternalAuthenticatedResult extends RegisterServerAuthenticatedResult {
15 req: express.Request
16 res: express.Response
17}
18
19interface RegisterServerAuthBase {
20 // Authentication name (a plugin can register multiple auth strategies)
21 authName: string
22
23 // Called by PeerTube when a user from your plugin logged out
24 onLogout?(user: MUser): void
25
26 // Your plugin can hook PeerTube access/refresh token validity
27 // So you can control for your plugin the user session lifetime
28 hookTokenValidity?(options: { token: MOAuthToken, type: 'access' | 'refresh' }): Promise<{ valid: boolean }>
29}
30
31export interface RegisterServerAuthPassOptions extends RegisterServerAuthBase {
32 // Weight of this authentication so PeerTube tries the auth methods in DESC weight order
33 getWeight(): number
34
35 // Used by PeerTube to login a user
36 // Returns null if the login failed, or { username, email } on success
37 login(body: {
38 id: string
39 password: string
40 }): Promise<RegisterServerAuthenticatedResult | null>
41}
42
43export interface RegisterServerAuthExternalOptions extends RegisterServerAuthBase {
44 // Will be displayed in a block next to the login form
45 authDisplayName: () => string
46
47 onAuthRequest: (req: express.Request, res: express.Response) => void
48}
49
50export interface RegisterServerAuthExternalResult {
51 userAuthenticated (options: RegisterServerExternalAuthenticatedResult): void
52}