From e307e4fce39853d445d086f92b8c556c363ee15d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 24 Apr 2020 11:33:01 +0200 Subject: Add ability for auth plugins to hook tokens validity --- shared/models/plugins/register-server-auth.model.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'shared/models/plugins/register-server-auth.model.ts') diff --git a/shared/models/plugins/register-server-auth.model.ts b/shared/models/plugins/register-server-auth.model.ts index dc46dcbc8..403a49994 100644 --- a/shared/models/plugins/register-server-auth.model.ts +++ b/shared/models/plugins/register-server-auth.model.ts @@ -1,4 +1,5 @@ import { UserRole } from '@shared/models' +import { MOAuthToken } from '@server/typings/models' export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions @@ -6,11 +7,16 @@ export interface RegisterServerAuthPassOptions { // Authentication name (a plugin can register multiple auth strategies) authName: string - onLogout?: Function + // Called by PeerTube when a user from your plugin logged out + onLogout?(): void // Weight of this authentication so PeerTube tries the auth methods in DESC weight order getWeight(): number + // Your plugin can hook PeerTube access/refresh token validity + // So you can control for your plugin the user session lifetime + hookTokenValidity?(options: { token: MOAuthToken, type: 'access' | 'refresh' }): Promise<{ valid: boolean }> + // Used by PeerTube to login a user // Returns null if the login failed, or { username, email } on success login(body: { -- cgit v1.2.3