UNPKG

@kephas/ngx-oidc

Version:

Provides the integration of the OIDC API with Kephas and Angular 12+.

1 lines 52.3 kB
{"version":3,"file":"kephas-ngx-oidc.mjs","sources":["../../../../projects/kephas/ngx-oidc/src/lib/appIdProvider.service.ts","../../../../projects/kephas/ngx-oidc/src/lib/authentication.settings.ts","../../../../projects/kephas/ngx-oidc/src/lib/authentication.service.ts","../../../../projects/kephas/ngx-oidc/src/lib/authorize.interceptor.ts","../../../../projects/kephas/ngx-oidc/src/lib/authorize.guard.ts","../../../../projects/kephas/ngx-oidc/src/lib/login/login.component.ts","../../../../projects/kephas/ngx-oidc/src/lib/login/login.component.html","../../../../projects/kephas/ngx-oidc/src/lib/logout/logout.component.ts","../../../../projects/kephas/ngx-oidc/src/lib/logout/logout.component.html","../../../../projects/kephas/ngx-oidc/src/lib/login-menu/login-menu.component.ts","../../../../projects/kephas/ngx-oidc/src/lib/login-menu/login-menu.component.html","../../../../projects/kephas/ngx-oidc/src/lib/oidc.module.ts","../../../../projects/kephas/ngx-oidc/src/public-api.ts","../../../../projects/kephas/ngx-oidc/src/kephas-ngx-oidc.ts"],"sourcesContent":["import { AppService, Priority, SingletonAppServiceContract } from \"@kephas/core\";\r\nimport { NgTarget } from \"@kephas/ngx-core\";\r\n\r\n/**\r\n * This service should be overwritten in the end application\r\n * to provide the real identity application ID in the getIdentityAppId() method.\r\n *\r\n * @export\r\n * @class AppIdProvider\r\n */\r\n@AppService({ overridePriority: Priority.Lowest })\r\n@SingletonAppServiceContract({ target: NgTarget })\r\nexport class AppIdProvider {\r\n /**\r\n * Gets the identity application ID.\r\n *\r\n * @returns\r\n * @memberof AppIdProvider\r\n */\r\n getIdentityAppId() {\r\n return '[TODO-APP-ID]';\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { AppIdProvider } from './appIdProvider.service';\r\n\r\nexport const ReturnUrlType = 'returnUrl';\r\n\r\nexport const QueryParameterNames = {\r\n ReturnUrl: ReturnUrlType,\r\n Message: 'message'\r\n};\r\n\r\nexport const LogoutActions = {\r\n LogoutCallback: 'logout-callback',\r\n Logout: 'logout',\r\n LoggedOut: 'logged-out'\r\n};\r\n\r\nexport const LoginActions = {\r\n Login: 'login',\r\n LoginCallback: 'login-callback',\r\n LoginFailed: 'login-failed',\r\n Profile: 'profile',\r\n Register: 'register'\r\n};\r\n\r\nexport interface ApplicationPathsType {\r\n readonly DefaultLoginRedirectPath: string;\r\n readonly ApiAuthorizationClientConfigurationUrl: string;\r\n readonly Login: string;\r\n readonly LoginFailed: string;\r\n readonly LoginCallback: string;\r\n readonly Register: string;\r\n readonly Profile: string;\r\n readonly LogOut: string;\r\n readonly LoggedOut: string;\r\n readonly LogOutCallback: string;\r\n readonly LoginPathComponents: string [];\r\n readonly LoginFailedPathComponents: string [];\r\n readonly LoginCallbackPathComponents: string [];\r\n readonly RegisterPathComponents: string [];\r\n readonly ProfilePathComponents: string [];\r\n readonly LogOutPathComponents: string [];\r\n readonly LoggedOutPathComponents: string [];\r\n readonly LogOutCallbackPathComponents: string [];\r\n readonly IdentityRegisterPath: string;\r\n readonly IdentityManagePath: string;\r\n}\r\n\r\nexport interface ActivitySettingsType {\r\n /**\r\n * The maximum idle time (seconds) until an automatic disconnect happens.\r\n * Do not set if the automatic disconnect should not be triggered.\r\n *\r\n * @type {number}\r\n * @memberof ActivitySettingsType\r\n */\r\n readonly MaxIdleSeconds?: number;\r\n}\r\n\r\nexport interface AuthenticationSettings {\r\n readonly identityAppId: string;\r\n readonly returnUrl: string;\r\n readonly applicationPaths: ApplicationPathsType;\r\n readonly activity: ActivitySettingsType;\r\n popUpDisabled: boolean;\r\n}\r\n\r\n@Injectable()\r\nexport class AuthenticationSettingsProvider {\r\n public static readonly instance = new AuthenticationSettingsProvider(new AppIdProvider());\r\n\r\n readonly settings: AuthenticationSettings;\r\n\r\n /**\r\n * Creates an instance of AuthenticationSettingsProvider.\r\n * @param {AppIdProvider} appIdProvider The application ID provider.\r\n * @memberof AuthenticationSettingsProvider\r\n */\r\n constructor(appIdProvider: AppIdProvider) {\r\n this.settings = this.getSettings(appIdProvider.getIdentityAppId())\r\n }\r\n\r\n protected getSettings(identityAppId: string): AuthenticationSettings {\r\n let applicationPaths: ApplicationPathsType = {\r\n DefaultLoginRedirectPath: '/',\r\n ApiAuthorizationClientConfigurationUrl: `/_configuration/${identityAppId}`,\r\n Login: `authentication/${LoginActions.Login}`,\r\n LoginFailed: `authentication/${LoginActions.LoginFailed}`,\r\n LoginCallback: `authentication/${LoginActions.LoginCallback}`,\r\n Register: `authentication/${LoginActions.Register}`,\r\n Profile: `authentication/${LoginActions.Profile}`,\r\n LogOut: `authentication/${LogoutActions.Logout}`,\r\n LoggedOut: `authentication/${LogoutActions.LoggedOut}`,\r\n LogOutCallback: `authentication/${LogoutActions.LogoutCallback}`,\r\n LoginPathComponents: [],\r\n LoginFailedPathComponents: [],\r\n LoginCallbackPathComponents: [],\r\n RegisterPathComponents: [],\r\n ProfilePathComponents: [],\r\n LogOutPathComponents: [],\r\n LoggedOutPathComponents: [],\r\n LogOutCallbackPathComponents: [],\r\n IdentityRegisterPath: '/Identity/Account/Register',\r\n IdentityManagePath: '/Identity/Account/Manage'\r\n };\r\n\r\n applicationPaths = {\r\n ...applicationPaths,\r\n LoginPathComponents: applicationPaths.Login.split('/'),\r\n LoginFailedPathComponents: applicationPaths.LoginFailed.split('/'),\r\n RegisterPathComponents: applicationPaths.Register.split('/'),\r\n ProfilePathComponents: applicationPaths.Profile.split('/'),\r\n LogOutPathComponents: applicationPaths.LogOut.split('/'),\r\n LoggedOutPathComponents: applicationPaths.LoggedOut.split('/'),\r\n LogOutCallbackPathComponents: applicationPaths.LogOutCallback.split('/')\r\n };\r\n\r\n let activity: ActivitySettingsType = {\r\n };\r\n\r\n return {\r\n identityAppId: identityAppId,\r\n returnUrl: ReturnUrlType,\r\n applicationPaths: applicationPaths,\r\n activity: activity,\r\n // By default pop ups are disabled because they don't work properly on Edge.\r\n // If you want to enable pop up authentication simply set this flag to false.\r\n popUpDisabled: true,\r\n }\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { AppService, SingletonAppServiceContract } from '@kephas/core';\r\nimport { Profile, User, UserManager, } from 'oidc-client';\r\nimport { BehaviorSubject, concat, from, Observable } from 'rxjs';\r\nimport { filter, map, mergeMap, take, tap } from 'rxjs/operators';\r\nimport { AuthenticationSettingsProvider } from './authentication.settings';\r\n\r\nexport type IAuthenticationResult =\r\n SuccessAuthenticationResult |\r\n FailureAuthenticationResult |\r\n RedirectAuthenticationResult;\r\n\r\nexport interface SuccessAuthenticationResult {\r\n status: AuthenticationResultStatus.Success;\r\n state: any;\r\n}\r\n\r\nexport interface FailureAuthenticationResult {\r\n status: AuthenticationResultStatus.Fail;\r\n message: string | Error;\r\n}\r\n\r\nexport interface RedirectAuthenticationResult {\r\n status: AuthenticationResultStatus.Redirect;\r\n}\r\n\r\nexport enum AuthenticationResultStatus {\r\n Success,\r\n Redirect,\r\n Fail\r\n}\r\n\r\nexport interface IUser extends Profile {\r\n name?: string;\r\n}\r\n\r\n@Injectable()\r\nexport class AuthenticationService {\r\n private _lastActivityTime?: Date;\r\n\r\n /**\r\n * Creates an instance of AuthorizeService.\r\n * @param {AuthenticationSettingsProvider} settingsProvider The settings provider.\r\n * @memberof AuthorizeService\r\n */\r\n constructor(protected readonly settingsProvider: AuthenticationSettingsProvider) {\r\n }\r\n\r\n protected userManager?: UserManager;\r\n protected readonly userSubject: BehaviorSubject<IUser | null> = new BehaviorSubject(null as IUser | null);\r\n protected readonly rawUserSubject: BehaviorSubject<User | null> = new BehaviorSubject(null as User | null);\r\n\r\n /**\r\n * Gets the time of user's last activity.\r\n *\r\n * @readonly\r\n * @type {(Date | undefined)}\r\n * @memberof AuthorizeService\r\n */\r\n public get lastActivityTime(): Date | undefined {\r\n return this._lastActivityTime;\r\n }\r\n\r\n /**\r\n * Gets an observable indicating whether the user is authenticated.\r\n *\r\n * @return {*} {Observable<boolean>}\r\n * @memberof AuthorizeService\r\n */\r\n public isAuthenticated(): Observable<boolean> {\r\n return this.getUser().pipe(map(u => !!u));\r\n }\r\n\r\n /**\r\n * Gets an observable retrieving the user.\r\n *\r\n * @return {*} {(Observable<IUser | null | undefined>)}\r\n * @memberof AuthorizeService\r\n */\r\n public getUser(): Observable<IUser | null | undefined> {\r\n return concat(\r\n this.userSubject.pipe(take(1), filter(u => !!u)),\r\n this.getUserFromStorage().pipe(filter(u => !!u), tap(u => this.setUser(u!)), map(u => u?.profile)),\r\n this.userSubject.asObservable());\r\n }\r\n\r\n /**\r\n * Gets an observable containing the access token of the signed-in user.\r\n *\r\n * @return {*} {(Observable<string | undefined>)}\r\n * @memberof AuthorizeService\r\n */\r\n public getAccessToken(): Observable<string | undefined> {\r\n return from(this.ensureUserManagerInitialized())\r\n .pipe(mergeMap(() => from(this.userManager!.getUser())),\r\n map(user => user?.access_token));\r\n }\r\n\r\n /**\r\n * Notifies the authorization service that the user is active.\r\n *\r\n * @memberof AuthorizeService\r\n */\r\n public touch() {\r\n this._lastActivityTime = new Date();\r\n }\r\n\r\n /**\r\n * Sign in the user.\r\n * We try to authenticate the user in three different ways:\r\n * 1) We try to see if we can authenticate the user silently. This happens\r\n * when the user is already logged in on the IdP and is done using a hidden iframe\r\n * on the client.\r\n * 2) We try to authenticate the user using a PopUp Window. This might fail if there is a\r\n * Pop-Up blocker or the user has disabled PopUps.\r\n * 3) If the two methods above fail, we redirect the browser to the IdP to perform a traditional\r\n * redirect flow.\r\n *\r\n * @param {*} state\r\n * @return {*} {Promise<IAuthenticationResult>}\r\n * @memberof AuthorizeService\r\n */\r\n public async signIn(state: any): Promise<IAuthenticationResult> {\r\n await this.ensureUserManagerInitialized();\r\n let user: User | null = null;\r\n try {\r\n user = await this.userManager!.signinSilent(this.createArguments());\r\n this.setUser(user);\r\n return this.success(state);\r\n } catch (silentError) {\r\n // User might not be authenticated, fallback to popup authentication\r\n console.log('Silent authentication error: ', silentError);\r\n\r\n const popUpDisabled = this.settingsProvider.settings.popUpDisabled;\r\n try {\r\n this.ensurePopupEnabled();\r\n\r\n user = await this.userManager!.signinPopup(this.createArguments());\r\n this.setUser(user);\r\n return this.success(state);\r\n } catch (popupError) {\r\n if ((popupError as Error).message === 'Popup window closed') {\r\n // The user explicitly cancelled the login action by closing an opened popup.\r\n return this.error('The user closed the window.');\r\n } else if (!popUpDisabled) {\r\n console.log('Popup authentication error: ', popupError);\r\n }\r\n\r\n // PopUps might be blocked by the user, fallback to redirect\r\n try {\r\n await this.userManager!.signinRedirect(this.createArguments(state));\r\n return this.redirect();\r\n } catch (redirectError) {\r\n console.log('Redirect authentication error: ', redirectError);\r\n return this.error(redirectError as Error);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public async completeSignIn(url: string): Promise<IAuthenticationResult> {\r\n try {\r\n await this.ensureUserManagerInitialized();\r\n const user = await this.userManager!.signinCallback(url);\r\n this.setUser(user);\r\n return this.success(user?.state);\r\n } catch (error) {\r\n console.log('There was an error signing in: ', error);\r\n return this.error('There was an error signing in.');\r\n }\r\n }\r\n\r\n public async signOut(state: any): Promise<IAuthenticationResult> {\r\n try {\r\n this.ensurePopupEnabled();\r\n\r\n await this.ensureUserManagerInitialized();\r\n await this.userManager!.signoutPopup(this.createArguments());\r\n this.setUser(null);\r\n return this.success(state);\r\n } catch (popupSignOutError) {\r\n console.log('Popup signout error: ', popupSignOutError);\r\n try {\r\n await this.userManager!.signoutRedirect(this.createArguments(state));\r\n return this.redirect();\r\n } catch (redirectSignOutError) {\r\n console.log('Redirect signout error: ', popupSignOutError);\r\n return this.error(redirectSignOutError as Error);\r\n }\r\n }\r\n }\r\n\r\n public async completeSignOut(url: string): Promise<IAuthenticationResult> {\r\n await this.ensureUserManagerInitialized();\r\n try {\r\n const response = await this.userManager!.signoutCallback(url);\r\n this.setUser(null);\r\n return this.success(response && response.state);\r\n } catch (error) {\r\n console.log(`There was an error trying to log out '${error}'.`);\r\n return this.error(error as Error);\r\n }\r\n }\r\n\r\n protected async ensureUserManagerInitialized(): Promise<void> {\r\n if (this.userManager !== undefined) {\r\n return;\r\n }\r\n\r\n const authSettings = this.settingsProvider.settings;\r\n const response = await fetch(authSettings.applicationPaths.ApiAuthorizationClientConfigurationUrl);\r\n if (!response.ok) {\r\n throw new Error(`Could not load settings for '${authSettings.identityAppId}'`);\r\n }\r\n\r\n const settings: any = await response.json();\r\n settings.automaticSilentRenew = true;\r\n settings.includeIdTokenInSilentRenew = true;\r\n this.userManager = new UserManager(settings);\r\n\r\n this.userManager.events.addUserSignedOut(async () => {\r\n await this.userManager!.removeUser();\r\n this.setUser(null);\r\n });\r\n }\r\n\r\n private ensurePopupEnabled() {\r\n if (this.settingsProvider.settings.popUpDisabled) {\r\n throw new Error('Popup disabled. Instruct the AuthorizationSettingsProvider service to return false in \\'settings.popupDisabled\\' to enable it.');\r\n }\r\n }\r\n\r\n private createArguments(state?: any): any {\r\n return { useReplaceToNavigate: true, data: state };\r\n }\r\n\r\n private error(message: string | Error): IAuthenticationResult {\r\n return { status: AuthenticationResultStatus.Fail, message };\r\n }\r\n\r\n private success(state: any): IAuthenticationResult {\r\n return { status: AuthenticationResultStatus.Success, state };\r\n }\r\n\r\n private redirect(): IAuthenticationResult {\r\n return { status: AuthenticationResultStatus.Redirect };\r\n }\r\n\r\n private getUserFromStorage(): Observable<User | null> {\r\n return from(this.ensureUserManagerInitialized())\r\n .pipe(\r\n mergeMap(() => this.userManager!.getUser()));\r\n }\r\n\r\n private setUser(user: User | null) {\r\n const currentUser = this.rawUserSubject.value;\r\n\r\n // make sure not to issue a change if the user is not really changed.\r\n if (currentUser == user || currentUser?.id_token == user?.id_token) {\r\n return;\r\n }\r\n\r\n this.rawUserSubject.next(user);\r\n this.userSubject.next(user?.profile || null);\r\n }\r\n}\r\n","import { HttpHandler, HttpEvent, HttpRequest, HttpInterceptor } from '@angular/common/http';\r\nimport { Observable } from 'rxjs';\r\nimport { AuthenticationService } from './authentication.service';\r\nimport { mergeMap } from 'rxjs/operators';\r\nimport { Injectable } from '@angular/core';\r\n\r\n/**\r\n * Interceptor handling the authorization.\r\n *\r\n * @export\r\n * @class AuthorizeInterceptor\r\n * @implements {HttpInterceptor}\r\n */\r\n@Injectable()\r\nexport class AuthorizeInterceptor implements HttpInterceptor {\r\n /**\r\n * Creates an instance of AuthorizeInterceptor.\r\n * @param {AuthenticationService} authorize The authorization service.\r\n * @memberof AuthorizeInterceptor\r\n */\r\n constructor(private authorize: AuthenticationService) {\r\n }\r\n\r\n /**\r\n * Intercepts the request.\r\n *\r\n * @param {HttpRequest<any>} request\r\n * @param {HttpHandler} next\r\n * @return {*} {Observable<HttpEvent<any>>}\r\n * @memberof AuthorizeInterceptor\r\n */\r\n intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\r\n return this.authorize.getAccessToken()\r\n .pipe(mergeMap(token => this.processRequestWithToken(token, request, next)));\r\n }\r\n\r\n // Checks if there is an access_token available in the authorize service\r\n // and adds it to the request in case it's targeted at the same origin as the\r\n // single page application.\r\n private processRequestWithToken(token: string | undefined, req: HttpRequest<any>, next: HttpHandler) {\r\n if (!!token && this.isSameOriginUrl(req)) {\r\n req = req.clone({\r\n setHeaders: {\r\n Authorization: `Bearer ${token}`\r\n }\r\n });\r\n }\r\n\r\n return next.handle(req);\r\n }\r\n\r\n private isSameOriginUrl(req: any) {\r\n // It's an absolute url with the same origin.\r\n if (req.url.startsWith(`${window.location.origin}/`)) {\r\n return true;\r\n }\r\n\r\n // It's a protocol relative url with the same origin.\r\n // For example: //www.example.com/api/Products\r\n if (req.url.startsWith(`//${window.location.host}/`)) {\r\n return true;\r\n }\r\n\r\n // It's a relative url like /api/Products\r\n if (/^\\/[^\\/].*/.test(req.url)) {\r\n return true;\r\n }\r\n\r\n // It's an absolute or protocol relative url that\r\n // doesn't have the same origin.\r\n return false;\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';\r\nimport { Observable } from 'rxjs';\r\nimport { tap } from 'rxjs/operators';\r\nimport { AuthenticationService } from './authentication.service';\r\nimport { AuthenticationSettingsProvider, QueryParameterNames } from './authentication.settings';\r\n\r\n@Injectable()\r\nexport class AuthorizeGuard implements CanActivate {\r\n constructor(\r\n private authService: AuthenticationService,\r\n private router: Router,\r\n private settingsProvider: AuthenticationSettingsProvider) {\r\n }\r\n canActivate(\r\n _next: ActivatedRouteSnapshot,\r\n state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {\r\n return this.authService.isAuthenticated()\r\n .pipe(tap(isAuthenticated => this.handleAuthorization(isAuthenticated, state)));\r\n }\r\n\r\n private handleAuthorization(isAuthenticated: boolean, state: RouterStateSnapshot) {\r\n if (!isAuthenticated) {\r\n const settings = this.settingsProvider.settings;\r\n this.router.navigate(settings.applicationPaths.LoginPathComponents, {\r\n queryParams: {\r\n [QueryParameterNames.ReturnUrl]: state.url\r\n }\r\n });\r\n }\r\n }\r\n}\r\n","import { Component, OnInit } from '@angular/core';\r\nimport { ActivatedRoute, Router } from '@angular/router';\r\nimport { BehaviorSubject } from 'rxjs';\r\nimport { AuthenticationResultStatus, AuthenticationService } from '../authentication.service';\r\nimport { AuthenticationSettingsProvider, LoginActions, QueryParameterNames } from '../authentication.settings';\r\nimport { NavigationState } from '../navigationState';\r\n\r\n// The main responsibility of this component is to handle the user's login process.\r\n// This is the starting point for the login process. Any component that needs to authenticate\r\n// a user can simply perform a redirect to this component with a returnUrl query parameter and\r\n// let the component perform the login and return back to the return url.\r\n@Component({\r\n selector: 'app-login',\r\n templateUrl: './login.component.html',\r\n styleUrls: ['./login.component.css']\r\n})\r\nexport class LoginComponent implements OnInit {\r\n public message = new BehaviorSubject<string | Error | null>(null);\r\n\r\n constructor(\r\n private authenticationService: AuthenticationService,\r\n private activatedRoute: ActivatedRoute,\r\n private router: Router,\r\n private authSettingsProvider: AuthenticationSettingsProvider) { }\r\n\r\n async ngOnInit() {\r\n const action = this.activatedRoute.snapshot.url[1];\r\n switch (action.path) {\r\n case LoginActions.Login:\r\n await this.login(this.getReturnUrl());\r\n break;\r\n case LoginActions.LoginCallback:\r\n await this.processLoginCallback();\r\n break;\r\n case LoginActions.LoginFailed:\r\n const message = this.activatedRoute.snapshot.queryParamMap.get(QueryParameterNames.Message);\r\n this.message.next(message);\r\n break;\r\n case LoginActions.Profile:\r\n this.redirectToProfile();\r\n break;\r\n case LoginActions.Register:\r\n this.redirectToRegister();\r\n break;\r\n default:\r\n throw new Error(`Invalid action '${action}'`);\r\n }\r\n }\r\n\r\n private async login(returnUrl: string): Promise<void> {\r\n const state: NavigationState = { returnUrl };\r\n const result = await this.authenticationService.signIn(state);\r\n this.message.next(null);\r\n\r\n const applicationPaths = this.authSettingsProvider.settings.applicationPaths;\r\n switch (result.status) {\r\n case AuthenticationResultStatus.Redirect:\r\n break;\r\n case AuthenticationResultStatus.Success:\r\n await this.navigateToReturnUrl(returnUrl);\r\n break;\r\n case AuthenticationResultStatus.Fail:\r\n await this.router.navigate(applicationPaths.LoginFailedPathComponents, {\r\n queryParams: { [QueryParameterNames.Message]: result.message }\r\n });\r\n break;\r\n default:\r\n throw new Error(`Invalid status result ${(result as any).status}.`);\r\n }\r\n }\r\n\r\n private async processLoginCallback(): Promise<void> {\r\n const url = window.location.href;\r\n const result = await this.authenticationService.completeSignIn(url);\r\n switch (result.status) {\r\n case AuthenticationResultStatus.Redirect:\r\n // There should not be any redirects as completeSignIn never redirects.\r\n throw new Error('Should not redirect.');\r\n case AuthenticationResultStatus.Success:\r\n await this.navigateToReturnUrl(this.getReturnUrl(result.state));\r\n break;\r\n case AuthenticationResultStatus.Fail:\r\n this.message.next(result.message);\r\n break;\r\n }\r\n }\r\n\r\n private redirectToRegister(): any {\r\n const applicationPaths = this.authSettingsProvider.settings.applicationPaths;\r\n this.redirectToApiAuthorizationPath(\r\n `${applicationPaths.IdentityRegisterPath}?returnUrl=${encodeURI('/' + applicationPaths.Login)}`);\r\n }\r\n\r\n private redirectToProfile(): void {\r\n const applicationPaths = this.authSettingsProvider.settings.applicationPaths;\r\n this.redirectToApiAuthorizationPath(applicationPaths.IdentityManagePath);\r\n }\r\n\r\n private async navigateToReturnUrl(returnUrl: string) {\r\n // It's important that we do a replace here so that we remove the callback uri with the\r\n // fragment containing the tokens from the browser history.\r\n await this.router.navigateByUrl(returnUrl, {\r\n replaceUrl: true\r\n });\r\n }\r\n\r\n private getReturnUrl(state?: NavigationState): string {\r\n const applicationPaths = this.authSettingsProvider.settings.applicationPaths;\r\n const fromQuery = (this.activatedRoute.snapshot.queryParams as NavigationState).returnUrl;\r\n // If the url is comming from the query string, check that is either\r\n // a relative url or an absolute url\r\n if (fromQuery &&\r\n !(fromQuery.startsWith(`${window.location.origin}/`) ||\r\n /\\/[^\\/].*/.test(fromQuery))) {\r\n // This is an extra check to prevent open redirects.\r\n throw new Error('Invalid return url. The return url needs to have the same origin as the current page.');\r\n }\r\n return (state && state.returnUrl) ||\r\n fromQuery ||\r\n applicationPaths.DefaultLoginRedirectPath;\r\n }\r\n\r\n private redirectToApiAuthorizationPath(apiAuthorizationPath: string) {\r\n // It's important that we do a replace here so that when the user hits the back arrow on the\r\n // browser they get sent back to where it was on the app instead of to an endpoint on this\r\n // component.\r\n const redirectUrl = `${window.location.origin}${apiAuthorizationPath}`;\r\n window.location.replace(redirectUrl);\r\n }\r\n}\r\n","<p>{{ message | async }}</p>","import { Component, OnInit } from '@angular/core';\r\nimport { BehaviorSubject } from 'rxjs';\r\nimport { ActivatedRoute, Router } from '@angular/router';\r\nimport { take } from 'rxjs/operators';\r\nimport { AuthenticationResultStatus, AuthenticationService } from '../authentication.service';\r\nimport { AuthenticationSettingsProvider, LogoutActions } from '../authentication.settings';\r\nimport { NavigationState } from '../navigationState';\r\n\r\n// The main responsibility of this component is to handle the user's logout process.\r\n// This is the starting point for the logout process, which is usually initiated when a\r\n// user clicks on the logout button on the LoginMenu component.\r\n@Component({\r\n selector: 'app-logout',\r\n templateUrl: './logout.component.html',\r\n styleUrls: ['./logout.component.css']\r\n})\r\nexport class LogoutComponent implements OnInit {\r\n public message = new BehaviorSubject<string | Error | null>(null);\r\n\r\n constructor(\r\n private authenticationService: AuthenticationService,\r\n private activatedRoute: ActivatedRoute,\r\n private router: Router,\r\n private authSettingsProvider: AuthenticationSettingsProvider) { }\r\n\r\n async ngOnInit() {\r\n const action = this.activatedRoute.snapshot.url[1];\r\n switch (action.path) {\r\n case LogoutActions.Logout:\r\n if (!!window.history.state.local) {\r\n await this.logout(this.getReturnUrl());\r\n } else {\r\n // This prevents regular links to <app>/authentication/logout from triggering a logout\r\n this.message.next('The logout was not initiated from within the page.');\r\n }\r\n\r\n break;\r\n case LogoutActions.LogoutCallback:\r\n await this.processLogoutCallback();\r\n break;\r\n case LogoutActions.LoggedOut:\r\n this.message.next('You successfully logged out!');\r\n break;\r\n default:\r\n throw new Error(`Invalid action '${action}'`);\r\n }\r\n }\r\n\r\n private async logout(returnUrl: string): Promise<void> {\r\n const state: NavigationState = { returnUrl };\r\n const isauthenticated = await this.authenticationService.isAuthenticated().pipe(\r\n take(1)\r\n ).toPromise();\r\n if (isauthenticated) {\r\n const result = await this.authenticationService.signOut(state);\r\n switch (result.status) {\r\n case AuthenticationResultStatus.Redirect:\r\n break;\r\n case AuthenticationResultStatus.Success:\r\n await this.navigateToReturnUrl(returnUrl);\r\n break;\r\n case AuthenticationResultStatus.Fail:\r\n this.message.next(result.message);\r\n break;\r\n default:\r\n throw new Error('Invalid authentication result status.');\r\n }\r\n } else {\r\n this.message.next('You successfully logged out!');\r\n }\r\n }\r\n\r\n private async processLogoutCallback(): Promise<void> {\r\n const url = window.location.href;\r\n const result = await this.authenticationService.completeSignOut(url);\r\n switch (result.status) {\r\n case AuthenticationResultStatus.Redirect:\r\n // There should not be any redirects as the only time completeAuthentication finishes\r\n // is when we are doing a redirect sign in flow.\r\n throw new Error('Should not redirect.');\r\n case AuthenticationResultStatus.Success:\r\n await this.navigateToReturnUrl(this.getReturnUrl(result.state));\r\n break;\r\n case AuthenticationResultStatus.Fail:\r\n this.message.next(result.message);\r\n break;\r\n default:\r\n throw new Error('Invalid authentication result status.');\r\n }\r\n }\r\n\r\n private async navigateToReturnUrl(returnUrl: string) {\r\n await this.router.navigateByUrl(returnUrl, {\r\n replaceUrl: true\r\n });\r\n }\r\n\r\n private getReturnUrl(state?: NavigationState): string {\r\n const fromQuery = (this.activatedRoute.snapshot.queryParams as NavigationState).returnUrl;\r\n // If the url is comming from the query string, check that is either\r\n // a relative url or an absolute url\r\n if (fromQuery &&\r\n !(fromQuery.startsWith(`${window.location.origin}/`) ||\r\n /\\/[^\\/].*/.test(fromQuery))) {\r\n // This is an extra check to prevent open redirects.\r\n throw new Error('Invalid return url. The return url needs to have the same origin as the current page.');\r\n }\r\n return (state && state.returnUrl) ||\r\n fromQuery ||\r\n this.authSettingsProvider.settings.applicationPaths.LoggedOut;\r\n }\r\n}\r\n","<p>{{ message | async }}</p>","import { Component, OnInit } from '@angular/core';\r\nimport { Observable } from 'rxjs';\r\nimport { map, tap } from 'rxjs/operators';\r\nimport { AuthenticationService } from '../authentication.service';\r\n\r\n@Component({\r\n selector: 'app-login-menu',\r\n templateUrl: './login-menu.component.html',\r\n styleUrls: ['./login-menu.component.css']\r\n})\r\nexport class LoginMenuComponent implements OnInit {\r\n public isAuthenticated?: Observable<boolean>;\r\n public userName?: Observable<string | undefined>;\r\n\r\n constructor(private authenticationService: AuthenticationService) { }\r\n\r\n ngOnInit() {\r\n this.isAuthenticated = this.authenticationService.isAuthenticated();\r\n this.userName = this.authenticationService.getUser().pipe(map(u => u?.name));\r\n }\r\n}\r\n","<ul class=\"navbar-nav\" *ngIf=\"isAuthenticated | async\">\r\n <li class=\"nav-item\">\r\n <a class=\"nav-link\" [routerLink]='[\"/authentication/profile\"]' title=\"Manage\">Hello {{ userName | async }}</a>\r\n </li>\r\n <li class=\"nav-item\">\r\n <a class=\"nav-link\" [routerLink]='[\"/authentication/logout\"]' [state]='{ local: true }' title=\"Logout\">Logout</a>\r\n </li>\r\n</ul>\r\n<ul class=\"navbar-nav\" *ngIf=\"!(isAuthenticated | async)\">\r\n <li class=\"nav-item\">\r\n <a class=\"nav-link\" [routerLink]='[\"/authentication/register\"]'>Register</a>\r\n </li>\r\n <li class=\"nav-item\">\r\n <a class=\"nav-link\" [routerLink]='[\"/authentication/login\"]'>Login</a>\r\n </li>\r\n</ul>\r\n","import { Injector, NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { LoginMenuComponent } from './login-menu/login-menu.component';\r\nimport { LoginComponent } from './login/login.component';\r\nimport { LogoutComponent } from './logout/logout.component';\r\nimport { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';\r\nimport { RouterModule } from '@angular/router';\r\nimport { AuthenticationSettingsProvider } from './authentication.settings';\r\nimport { AppIdProvider } from './appIdProvider.service';\r\nimport { resolveAppService } from '@kephas/ngx-core';\r\nimport { AuthenticationService } from './authentication.service';\r\nimport { AuthorizeGuard } from './authorize.guard';\r\nimport { AuthorizeInterceptor } from './authorize.interceptor';\r\n\r\nconst applicationPaths = AuthenticationSettingsProvider.instance.settings.applicationPaths;\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n HttpClientModule,\r\n RouterModule.forChild(\r\n [\r\n { path: applicationPaths.Register, component: LoginComponent },\r\n { path: applicationPaths.Profile, component: LoginComponent },\r\n { path: applicationPaths.Login, component: LoginComponent },\r\n { path: applicationPaths.LoginFailed, component: LoginComponent },\r\n { path: applicationPaths.LoginCallback, component: LoginComponent },\r\n { path: applicationPaths.LogOut, component: LogoutComponent },\r\n { path: applicationPaths.LoggedOut, component: LogoutComponent },\r\n { path: applicationPaths.LogOutCallback, component: LogoutComponent }\r\n ]\r\n )\r\n ],\r\n declarations: [LoginMenuComponent, LoginComponent, LogoutComponent],\r\n exports: [LoginMenuComponent, LoginComponent, LogoutComponent],\r\n providers: [\r\n {\r\n provide: AppIdProvider,\r\n useFactory: resolveAppService(AppIdProvider),\r\n deps: [Injector]\r\n },\r\n AuthenticationSettingsProvider,\r\n AuthenticationService,\r\n AuthorizeGuard,\r\n {\r\n provide: HTTP_INTERCEPTORS,\r\n multi: true,\r\n useClass: AuthorizeInterceptor,\r\n }\r\n ]\r\n})\r\nexport class OidcModule { }\r\n","/*\r\n * Public API Surface of angular-oidc\r\n */\r\n\r\nexport * from './lib/appIdProvider.service';\r\nexport * from './lib/authentication.settings';\r\nexport * from './lib/navigationState';\r\nexport * from './lib/authentication.service';\r\nexport * from './lib/authorize.interceptor';\r\nexport * from './lib/authorize.guard';\r\n\r\nexport * from './lib/login/login.component';\r\nexport * from './lib/logout/logout.component';\r\nexport * from './lib/login-menu/login-menu.component';\r\n\r\nexport * from './lib/oidc.module';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA;;;;;;;IASa,aAAa,GAA1B,MAAa,aAAa;;;;;;;IAOxB,gBAAgB;QACd,OAAO,eAAe,CAAC;KACxB;EACF;AAVY,aAAa;IAFzB,UAAU,CAAC,EAAE,gBAAgB,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACjD,2BAA2B,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;GACrC,aAAa,CAUzB;;MCnBY,aAAa,GAAG,YAAY;MAE5B,mBAAmB,GAAG;IACjC,SAAS,EAAE,aAAa;IACxB,OAAO,EAAE,SAAS;EAClB;MAEW,aAAa,GAAG;IAC3B,cAAc,EAAE,iBAAiB;IACjC,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,YAAY;EACvB;MAEW,YAAY,GAAG;IAC1B,KAAK,EAAE,OAAO;IACd,aAAa,EAAE,gBAAgB;IAC/B,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;EACpB;MA6CW,8BAA8B;;;;;;IAUzC,YAAY,aAA4B;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW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