mirror of
https://github.com/directus/directus.git
synced 2026-01-30 07:58:15 -05:00
* moving schema and relation types into shared package * updating SchemaOverview imports * removing duplicate import
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import { SchemaOverview } from '@directus/shared/types';
|
|
import { Knex } from 'knex';
|
|
import { AuthDriverOptions, User } from '../types';
|
|
|
|
export abstract class AuthDriver {
|
|
knex: Knex;
|
|
schema: SchemaOverview;
|
|
|
|
constructor(options: AuthDriverOptions, _config: Record<string, any>) {
|
|
this.knex = options.knex;
|
|
this.schema = options.schema;
|
|
}
|
|
|
|
/**
|
|
* Get user id for a given provider payload
|
|
*
|
|
* @param payload Any data that the user might've provided
|
|
* @throws InvalidCredentialsException
|
|
* @return User id of the identifier
|
|
*/
|
|
abstract getUserID(payload: Record<string, any>): Promise<string>;
|
|
|
|
/**
|
|
* Verify user password
|
|
*
|
|
* @param user User information
|
|
* @param password User password
|
|
* @throws InvalidCredentialsException
|
|
*/
|
|
abstract verify(user: User, password?: string): Promise<void>;
|
|
|
|
/**
|
|
* Check with the (external) provider if the user is allowed entry to Directus
|
|
*
|
|
* @param _user User information
|
|
* @param _payload Any data that the user might've provided
|
|
* @throws InvalidCredentialsException
|
|
* @returns Data to be stored with the session
|
|
*/
|
|
async login(_user: User, _payload: Record<string, any>): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Handle user session refresh
|
|
*
|
|
* @param _user User information
|
|
* @throws InvalidCredentialsException
|
|
*/
|
|
async refresh(_user: User): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Handle user session termination
|
|
*
|
|
* @param _user User information
|
|
*/
|
|
async logout(_user: User): Promise<void> {
|
|
return;
|
|
}
|
|
}
|