@adonisjs/auth
Version:
Official authentication provider for Adonis framework
68 lines (67 loc) • 2.22 kB
TypeScript
/// <reference types="@adonisjs/events/build/adonis-typings" />
import { EmitterContract } from '@ioc:Adonis/Core/Event';
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
import { UserProviderContract, BasicAuthGuardConfig, BasicAuthGuardContract } from '@ioc:Adonis/Addons/Auth';
import { BaseGuard } from '../Base';
/**
* Basic auth guard enables user login using basic auth headers.
*/
export declare class BasicAuthGuard extends BaseGuard<any> implements BasicAuthGuardContract<any, any> {
private emitter;
private ctx;
constructor(name: string, config: BasicAuthGuardConfig<any>, emitter: EmitterContract, provider: UserProviderContract<any>, ctx: HttpContextContract);
/**
* Returns data packet for the authenticate event. Arguments are
*
* - The mapping identifier
* - Logged in user
* - HTTP context
*/
private getAuthenticateEventData;
/**
* Returns user credentials by parsing the HTTP "Authorization" header
*/
private getCredentials;
/**
* Returns user for the uid and password.
*/
private getUser;
/**
* Implemented method to raise exception when someone calls this method
* without selecting the guard explicitly
*/
attempt(): Promise<any>;
/**
* Implemented method to raise exception when someone calls this method
* without selecting the guard explicitly
*/
loginViaId(): Promise<void>;
/**
* Implemented method to raise exception when someone calls this method
* without selecting the guard explicitly
*/
login(): Promise<void>;
/**
* Authenticates the current HTTP request by checking for the HTTP
* "Authorization" header
*/
authenticate(): Promise<any>;
/**
* Same as [[authenticate]] but returns a boolean over raising exceptions
*/
check(): Promise<boolean>;
/**
* Logout by clearing session and cookies
*/
logout(): Promise<void>;
/**
* Serialize toJSON for JSON.stringify
*/
toJSON(): {
isLoggedIn: boolean;
isGuest: boolean;
authenticationAttempted: boolean;
isAuthenticated: boolean;
user: any;
};
}