UNPKG

@mvx/identity

Version:

identity is oidc for mvc, type-mvc is base on koa. Decorator, Ioc, AOP mvc framework on server.

47 lines (45 loc) 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuthFlowService = void 0; const tslib_1 = require("tslib"); const ioc_1 = require("@tsdi/ioc"); const mvc_1 = require("@mvx/mvc"); const passports_1 = require("../passports"); let AuthFlowService = class AuthFlowService extends mvc_1.AuthorizationService { getAuthMiddlewares(ctx, controller, propertyKey) { var _a, _b; let middlewares = []; let mvcCtx = ctx.mvcContext; let configuration = mvcCtx.getConfiguration(); let flowOption = configuration.passports.default; if (!flowOption) { return middlewares; } let refl = mvcCtx.reflects; let authOption = Object.assign(Object.assign({}, configuration.passports.initialize), flowOption.options); if (!authOption.userProperty && ((_a = flowOption.options) === null || _a === void 0 ? void 0 : _a.assignProperty)) { authOption.userProperty = (_b = flowOption.options) === null || _b === void 0 ? void 0 : _b.assignProperty; } if (propertyKey) { if (refl.hasMethodMetadata(mvc_1.Authorization, controller, propertyKey)) { middlewares.push(this.passport.authenticate(flowOption.strategy, authOption)); } } else if (refl.hasMetadata(mvc_1.Authorization, controller)) { middlewares.push(this.passport.authenticate(flowOption.strategy, authOption)); } return middlewares; } static ρAnn() { return { "name": "AuthFlowService", "params": { "getAuthMiddlewares": ["ctx", "controller", "propertyKey"] } }; } }; tslib_1.__decorate([ ioc_1.Inject(passports_1.AuthenticatorToken), tslib_1.__metadata("design:type", Object) ], AuthFlowService.prototype, "passport", void 0); AuthFlowService = tslib_1.__decorate([ ioc_1.Singleton() ], AuthFlowService); exports.AuthFlowService = AuthFlowService; //# sourceMappingURL=../sourcemaps/middlewares/AuthFlowService.js.map