@labshare/services-auth
Version:
Loopback 4 plugin for resource scope-based HTTP route authz
69 lines • 2.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AUTHENTICATION_METADATA_CLASS_KEY = exports.AUTHENTICATION_METADATA_KEY = exports.AuthenticationBindings = void 0;
/**
* Binding keys used by this component.
*/
const context_1 = require("@loopback/context");
const metadata_1 = require("@loopback/metadata");
var AuthenticationBindings;
(function (AuthenticationBindings) {
/**
* Key used to inject the authentication function into the sequence.
*
* ```ts
* class MySequence implements SequenceHandler {
* constructor(
* @inject(AuthenticationBindings.AUTH_ACTION)
* protected authenticateRequest: AuthenticateFn,
* // ... other sequence action injections
* ) {}
*
* async handle(context: RequestContext) {
* try {
* const {request, response} = context;
* const route = this.findRoute(request);
*
* // Authenticate
* await this.authenticateRequest(request);
*
* // Authentication successful, proceed to invoke controller
* const args = await this.parseParams(request, route);
* const result = await this.invoke(route, args);
* this.send(response, result);
* } catch (err) {
* this.reject(context, err);
* }
* }
* }
* ```
*/
AuthenticationBindings.AUTH_ACTION = context_1.BindingKey.create("authentication.actions.authenticate");
AuthenticationBindings.USER_INFO_ACTION = context_1.BindingKey.create("authentication.actions.userInfo");
/**
* Key used to set configuration for the authentication action
* @type {BindingKey<any>}
*/
AuthenticationBindings.AUTH_CONFIG = context_1.BindingKey.create("authentication.config");
/**
* The key used to set the custom RS256/HS256 secret provider
*/
AuthenticationBindings.SECRET_PROVIDER = context_1.BindingKey.create("authentication.secretProvider");
/**
* The key used to get a custom JWT audience
*/
AuthenticationBindings.AUDIENCE_PROVIDER = context_1.BindingKey.create("authentication.audienceProvider");
/**
* The key used to set the custom RS256/HS256 secret provider
*/
AuthenticationBindings.IS_REVOKED_CALLBACK_PROVIDER = context_1.BindingKey.create("authentication.isRevokedCallbackProvider");
})(AuthenticationBindings = exports.AuthenticationBindings || (exports.AuthenticationBindings = {}));
/**
* The key used to store method authentication decorator metadata
*/
exports.AUTHENTICATION_METADATA_KEY = metadata_1.MetadataAccessor.create("authentication.method.operationsMetadata");
/**
* The key used to store class-level metadata for `@authenticate`
*/
exports.AUTHENTICATION_METADATA_CLASS_KEY = metadata_1.MetadataAccessor.create("authentication:class");
//# sourceMappingURL=keys.js.map