@ffdc/nestjs-oidc
Advanced tools
Comparing version 0.14.1 to 0.15.0
@@ -8,3 +8,2 @@ import { Response, Request } from 'express'; | ||
login(req: Request, res: Response, next: Function, params: any): void; | ||
loginCallback(req: Request, res: Response, next: Function, params: any): void; | ||
logout(req: Request, res: Response, params: any): Promise<void>; | ||
@@ -11,0 +10,0 @@ refreshTokens(req: Request, res: Response, next: Function): Promise<void>; |
@@ -29,5 +29,2 @@ "use strict"; | ||
} | ||
loginCallback(req, res, next, params) { | ||
this.oidcService.login(req, res, next, params); | ||
} | ||
async logout(req, res, params) { | ||
@@ -60,10 +57,2 @@ this.oidcService.logout(req, res, params); | ||
public_decorator_1.Public(), | ||
common_1.Get('/login/callback'), | ||
__param(0, common_1.Req()), __param(1, common_1.Res()), __param(2, common_1.Next()), __param(3, common_1.Param()), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object, Object, Function, Object]), | ||
__metadata("design:returntype", void 0) | ||
], AuthMultitenantController.prototype, "loginCallback", null); | ||
__decorate([ | ||
public_decorator_1.Public(), | ||
common_1.Get('/logout'), | ||
@@ -70,0 +59,0 @@ __param(0, common_1.Req()), __param(1, common_1.Res()), __param(2, common_1.Param()), |
@@ -11,3 +11,2 @@ /// <reference types="passport" /> | ||
login(req: Request, res: Response, next: Function, params: any): void; | ||
loginCallback(req: Request, res: Response, next: Function, params: any): void; | ||
logout(req: Request, res: Response, params: any): Promise<void>; | ||
@@ -14,0 +13,0 @@ refreshTokens(req: Request, res: Response, next: Function): void; |
@@ -25,7 +25,3 @@ "use strict"; | ||
user(user) { | ||
return user | ||
? user['userinfo'] | ||
: { | ||
isGuest: true, | ||
}; | ||
return user ? user['userinfo'] : { isGuest: true }; | ||
} | ||
@@ -35,5 +31,2 @@ login(req, res, next, params) { | ||
} | ||
loginCallback(req, res, next, params) { | ||
this.oidcService.login(req, res, next, params); | ||
} | ||
async logout(req, res, params) { | ||
@@ -67,10 +60,2 @@ this.oidcService.logout(req, res, params); | ||
public_decorator_1.Public(), | ||
common_1.Get('/login/callback'), | ||
__param(0, common_1.Req()), __param(1, common_1.Res()), __param(2, common_1.Next()), __param(3, common_1.Param()), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object, Object, Function, Object]), | ||
__metadata("design:returntype", void 0) | ||
], AuthController.prototype, "loginCallback", null); | ||
__decorate([ | ||
public_decorator_1.Public(), | ||
common_1.Get('/logout'), | ||
@@ -77,0 +62,0 @@ __param(0, common_1.Req()), __param(1, common_1.Res()), __param(2, common_1.Param()), |
export * from './auth.controller'; | ||
export * from './auth-multitenant.controller'; | ||
export * from './tenant-switch.controller'; | ||
export * from './login-callback.controller'; |
@@ -9,2 +9,3 @@ "use strict"; | ||
__export(require("./tenant-switch.controller")); | ||
__export(require("./login-callback.controller")); | ||
//# sourceMappingURL=index.js.map |
@@ -14,2 +14,3 @@ "use strict"; | ||
const auth_multitenant_controller_1 = require("./controllers/auth-multitenant.controller"); | ||
const login_callback_controller_1 = require("./controllers/login-callback.controller"); | ||
const jwt_1 = require("@nestjs/jwt"); | ||
@@ -83,3 +84,3 @@ const oidc_constants_1 = require("./oidc.constants"); | ||
imports: [jwt_1.JwtModule.register({})], | ||
controllers: [auth_controller_1.AuthController, auth_multitenant_controller_1.AuthMultitenantController, controllers_1.TenantSwitchController], | ||
controllers: [auth_controller_1.AuthController, auth_multitenant_controller_1.AuthMultitenantController, login_callback_controller_1.LoginCallbackController, controllers_1.TenantSwitchController], | ||
providers: [ | ||
@@ -86,0 +87,0 @@ session_serializer_1.SessionSerializer, |
{ | ||
"name": "@ffdc/nestjs-oidc", | ||
"version": "0.14.1", | ||
"version": "0.15.0", | ||
"contributors": [ | ||
@@ -5,0 +5,0 @@ "David Boclé <david.bocle@finastra.com>", |
@@ -6,2 +6,3 @@ import { OnModuleInit } from '@nestjs/common'; | ||
import { ChannelType, IdentityProviderOptions, OidcModuleOptions } from '../interfaces'; | ||
import { OidcStrategy } from '../strategies'; | ||
export declare class OidcService implements OnModuleInit { | ||
@@ -16,2 +17,3 @@ options: OidcModuleOptions; | ||
client: Client; | ||
strategy: OidcStrategy; | ||
}; | ||
@@ -18,0 +20,0 @@ }; |
@@ -53,3 +53,3 @@ "use strict"; | ||
issuer = `${this.options['issuerOrigin']}/${tenantId}/.well-known/openid-configuration`; | ||
redirectUri = `${this.options.origin}/${tenantId}/${channelType}/login/callback`; | ||
redirectUri = `${this.options.origin}/login/callback`; | ||
switch (channelType.toLowerCase()) { | ||
@@ -72,2 +72,3 @@ case interfaces_1.ChannelType.b2e: | ||
tokenStore, | ||
strategy, | ||
}; | ||
@@ -77,2 +78,3 @@ this.options.authParams.redirect_uri = redirectUri; | ||
strategy = new strategies_1.OidcStrategy(this, key, channelType); | ||
this.idpInfos[key].strategy = strategy; | ||
return strategy; | ||
@@ -112,4 +114,11 @@ } | ||
try { | ||
const strategy = this.strategy || (await this.createStrategy(params.tenantId, params.channelType)); | ||
let prefix = params.tenantId && params.channelType ? `/${params.tenantId}/${params.channelType}` : ''; | ||
const tenantId = params.tenantId || req.session.tenant; | ||
const channel = params.channelType || req.session.channel; | ||
const strategy = this.strategy || | ||
(this.idpInfos[this.getIdpInfosKey(tenantId, channel)] && | ||
this.idpInfos[this.getIdpInfosKey(tenantId, channel)].strategy) || | ||
(await this.createStrategy(tenantId, channel)); | ||
const prefix = channel && tenantId ? `/${tenantId}/${channel}` : ''; | ||
req.session.tenant = tenantId; | ||
req.session.channel = channel; | ||
passport.authenticate(strategy, Object.assign(Object.assign({}, req['options']), { successRedirect: `${prefix}/`, failureRedirect: `${prefix}/login` }))(req, res, next); | ||
@@ -116,0 +125,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2267383
112
1515