mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Begin auth plugin support
This commit is contained in:
@@ -27,6 +27,16 @@ function login (url: string, client: Client, user: User, expectedStatus = 200) {
|
||||
.expect(expectedStatus)
|
||||
}
|
||||
|
||||
function logout (url: string, token: string, expectedStatus = 200) {
|
||||
const path = '/api/v1/users/revoke-token'
|
||||
|
||||
return request(url)
|
||||
.post(path)
|
||||
.set('Authorization', 'Bearer ' + token)
|
||||
.type('form')
|
||||
.expect(expectedStatus)
|
||||
}
|
||||
|
||||
async function serverLogin (server: Server) {
|
||||
const res = await login(server.url, server.client, server.user, 200)
|
||||
|
||||
@@ -71,6 +81,7 @@ function setAccessTokensToServers (servers: ServerInfo[]) {
|
||||
|
||||
export {
|
||||
login,
|
||||
logout,
|
||||
serverLogin,
|
||||
userLogin,
|
||||
getAccessToken,
|
||||
|
||||
33
shared/models/plugins/register-server-auth.model.ts
Normal file
33
shared/models/plugins/register-server-auth.model.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { UserRole } from '@shared/models'
|
||||
|
||||
export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions
|
||||
|
||||
export interface RegisterServerAuthPassOptions {
|
||||
type: 'id-and-pass'
|
||||
|
||||
onLogout?: Function
|
||||
|
||||
getWeight(): number
|
||||
|
||||
// Used by PeerTube to login a user
|
||||
// Returns null if the login failed, or { username, email } on success
|
||||
login(body: {
|
||||
id: string
|
||||
password: string
|
||||
}): Promise<{
|
||||
username: string
|
||||
email: string
|
||||
role?: UserRole
|
||||
displayName?: string
|
||||
} | null>
|
||||
}
|
||||
|
||||
export interface RegisterServerAuthExternalOptions {
|
||||
type: 'external'
|
||||
|
||||
onLogout?: Function
|
||||
}
|
||||
|
||||
export interface RegisterServerAuthExternalResult {
|
||||
onAuth (options: { username: string, email: string }): void
|
||||
}
|
||||
Reference in New Issue
Block a user