graphdb-workbench
Version:
The web application for GraphDB APIs
36 lines (35 loc) • 1.87 kB
TypeScript
import { AuthStrategy, AuthStrategyType } from '../../../models/security/authentication';
import { AuthenticatedUser } from '../../../models/security';
import { LoginData } from '../../../models/security/authentication/login-data';
import { SecurityService } from '../security.service';
import { AuthenticationStorageService } from '../authentication-storage.service';
/**
* Abstract base class for GDB login strategies.
* Implements common login functionality for GDB token-based authentication.
* Strategies, which need to be able to use the login method, should extend this class, e.g. GdbTokenAuthProvider, ExternalStrategy.
*/
export declare abstract class BaseGdbLoginStrategy implements AuthStrategy {
protected readonly securityService: SecurityService;
protected readonly logger: import("../../logging").LoggerService;
protected readonly authStorageService: AuthenticationStorageService;
abstract type: AuthStrategyType;
abstract initialize(): Promise<boolean>;
abstract isAuthenticated(): boolean;
abstract logout(): Promise<void>;
abstract isExternal(): boolean;
/**
* Fetches the currently authenticated user using the security service.
*
* @returns A promise that resolves to the authenticated user.
*/
fetchAuthenticatedUser(): Promise<AuthenticatedUser>;
/**
* Attempts to log in using the provided username and password.
* On success, stores the authentication token and updates the authenticated user in the security context.
* Logs and throws an error if the user cannot be mapped from the response.
* @param {LoginData} loginData - The login credentials (username and password).
* @returns {Promise<void>} A promise that resolves when login is complete.
*/
login(loginData: LoginData): Promise<AuthenticatedUser>;
private getAuthenticationHeader;
}