loopback4-authentication
Version:
A loopback-next extension for authentication feature. Various Oauth strategies supported by this package.
34 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClientAuthenticationMiddlewareProvider = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@loopback/core");
const rest_1 = require("@loopback/rest");
const keys_1 = require("../keys");
const middleware_groups_enum_1 = require("./middleware-groups.enum");
let ClientAuthenticationMiddlewareProvider = class ClientAuthenticationMiddlewareProvider {
constructor(authenticateClient) {
this.authenticateClient = authenticateClient;
}
value() {
const middleware = async (ctx, next) => {
await this.authenticateClient(ctx.request);
return next();
};
return middleware;
}
};
exports.ClientAuthenticationMiddlewareProvider = ClientAuthenticationMiddlewareProvider;
exports.ClientAuthenticationMiddlewareProvider = ClientAuthenticationMiddlewareProvider = tslib_1.__decorate([
(0, core_1.injectable)((0, rest_1.asMiddleware)({
group: middleware_groups_enum_1.AuthenticationMiddlewareGroups.CLIENT,
upstreamGroups: rest_1.RestMiddlewareGroups.PARSE_PARAMS,
downstreamGroups: [
middleware_groups_enum_1.AuthenticationMiddlewareGroups.USER,
rest_1.RestMiddlewareGroups.INVOKE_METHOD,
],
})),
tslib_1.__param(0, (0, core_1.inject)(keys_1.AuthenticationBindings.CLIENT_AUTH_ACTION)),
tslib_1.__metadata("design:paramtypes", [Function])
], ClientAuthenticationMiddlewareProvider);
//# sourceMappingURL=client-authentication.middleware.js.map