From feba17f0ad80e0c8971bfa63bf470bef1d0ec80a Mon Sep 17 00:00:00 2001 From: Fabian Gosebrink Date: Mon, 15 Jun 2020 17:45:28 +0200 Subject: [PATCH 1/4] catching the error to give out a result in error case --- .../src/lib/callback/callback.service.ts | 3 ++- .../src/lib/oidc.security.service.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/angular-auth-oidc-client/src/lib/callback/callback.service.ts b/projects/angular-auth-oidc-client/src/lib/callback/callback.service.ts index 81710d544..36a51f2f5 100644 --- a/projects/angular-auth-oidc-client/src/lib/callback/callback.service.ts +++ b/projects/angular-auth-oidc-client/src/lib/callback/callback.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { Observable, Subject } from 'rxjs'; import { tap } from 'rxjs/operators'; +import { CallbackContext } from '../flows/callback-context'; import { FlowHelper } from '../utils/flowHelper/flow-helper.service'; import { UrlService } from '../utils/url/url.service'; import { CodeFlowCallbackService } from './code-flow-callback.service'; @@ -25,7 +26,7 @@ export class CallbackService { return this.urlService.isCallbackFromSts(); } - handleCallbackAndFireEvents(currentCallbackUrl: string) { + handleCallbackAndFireEvents(currentCallbackUrl: string): Observable { let callback$: Observable; if (this.flowHelper.isCurrentFlowCodeFlow()) { diff --git a/projects/angular-auth-oidc-client/src/lib/oidc.security.service.ts b/projects/angular-auth-oidc-client/src/lib/oidc.security.service.ts index 8e60dfd68..598ee6fcf 100644 --- a/projects/angular-auth-oidc-client/src/lib/oidc.security.service.ts +++ b/projects/angular-auth-oidc-client/src/lib/oidc.security.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { Observable, of } from 'rxjs'; -import { map, switchMap } from 'rxjs/operators'; +import { catchError, map, switchMap } from 'rxjs/operators'; import { AuthStateService } from './authState/auth-state.service'; import { CallbackService } from './callback/callback.service'; import { PeriodicallyTokenCheckService } from './callback/periodically-token-check.service'; @@ -90,7 +90,8 @@ export class OidcSecurityService { this.loggerService.logDebug('checkAuth completed fire events, auth: ' + isAuthenticated); return isAuthenticated; - }) + }), + catchError(() => of(false)) ); } From 6288d5ef08348e20c55d62cde8ca6348a1ffaad1 Mon Sep 17 00:00:00 2001 From: Fabian Gosebrink Date: Tue, 16 Jun 2020 08:32:29 +0200 Subject: [PATCH 2/4] added forkjoin in refresh session to catch a result in any case --- .../src/lib/callback/refresh-session.service.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/projects/angular-auth-oidc-client/src/lib/callback/refresh-session.service.ts b/projects/angular-auth-oidc-client/src/lib/callback/refresh-session.service.ts index 136553176..6cfe90d00 100644 --- a/projects/angular-auth-oidc-client/src/lib/callback/refresh-session.service.ts +++ b/projects/angular-auth-oidc-client/src/lib/callback/refresh-session.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { of } from 'rxjs'; +import { forkJoin, of } from 'rxjs'; import { map, switchMap, take } from 'rxjs/operators'; import { AuthStateService } from '../authState/auth-state.service'; import { AuthWellKnownService } from '../config/auth-well-known.service'; @@ -42,10 +42,8 @@ export class RefreshSessionService { ); } - return this.startRefreshSession().pipe( - switchMap(() => this.silentRenewService.refreshSessionWithIFrameCompleted$), - take(1), - map((callbackContext) => { + return forkJoin([this.startRefreshSession(), this.silentRenewService.refreshSessionWithIFrameCompleted$.pipe(take(1))]).pipe( + map(([_, callbackContext]) => { const isAuthenticated = this.authStateService.areAuthStorageTokensValid(); if (isAuthenticated) { return { From e64fdcfd95c0b9b477804d00a500955a83323185 Mon Sep 17 00:00:00 2001 From: damienbod Date: Sat, 4 Jul 2020 14:05:39 +0200 Subject: [PATCH 3/4] adding some test console logs --- projects/sample-code-flow/src/app/app.component.ts | 2 ++ projects/sample-code-flow/src/app/home/home.component.html | 1 + projects/sample-code-flow/src/app/home/home.component.ts | 3 +++ 3 files changed, 6 insertions(+) diff --git a/projects/sample-code-flow/src/app/app.component.ts b/projects/sample-code-flow/src/app/app.component.ts index e070a05a2..f81a63415 100644 --- a/projects/sample-code-flow/src/app/app.component.ts +++ b/projects/sample-code-flow/src/app/app.component.ts @@ -11,6 +11,8 @@ export class AppComponent implements OnInit { ngOnInit() { this.oidcSecurityService.checkAuthIncludingServer().subscribe((isAuthenticated) => { console.warn('app authenticated', isAuthenticated); + const at = this.oidcSecurityService.getToken(); + console.warn(at); }); } } diff --git a/projects/sample-code-flow/src/app/home/home.component.html b/projects/sample-code-flow/src/app/home/home.component.html index 7585a2d95..f9f731824 100644 --- a/projects/sample-code-flow/src/app/home/home.component.html +++ b/projects/sample-code-flow/src/app/home/home.component.html @@ -2,6 +2,7 @@
+

diff --git a/projects/sample-code-flow/src/app/home/home.component.ts b/projects/sample-code-flow/src/app/home/home.component.ts index 5126e4c66..28f9023f8 100644 --- a/projects/sample-code-flow/src/app/home/home.component.ts +++ b/projects/sample-code-flow/src/app/home/home.component.ts @@ -24,6 +24,9 @@ export class HomeComponent implements OnInit { this.oidcSecurityService.authorize(); } + forceRefreshSession() { + this.oidcSecurityService.forceRefreshSession().subscribe((result) => console.warn(result)); + } logout() { this.oidcSecurityService.logoff(); } From 694f02e62ec8bcc46265b9c56ed4f34950629a87 Mon Sep 17 00:00:00 2001 From: damienbod Date: Sat, 4 Jul 2020 14:50:16 +0200 Subject: [PATCH 4/4] version 11.1.4 and changelog --- CHANGELOG.md | 9 +++++++-- package-lock.json | 2 +- package.json | 2 +- projects/angular-auth-oidc-client/package.json | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d24a8546..95a7331df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Angular Lib for OpenID Connect/OAuth2 Changelog +### 2020-07-04 Version 11.1.4 + +- checkAuthIncludingServer cannot complete without credentials + - [PR](https://github.com/damienbod/angular-auth-oidc-client/pull/811) // Fixes [#756](https://github.com/damienbod/angular-auth-oidc-client/issues/779) + ### 2020-06-04 Version 11.1.3 - Refresh checksession iframe regularly @@ -8,8 +13,8 @@ - [PR](https://github.com/damienbod/angular-auth-oidc-client/pull/766) // fixes [#750](https://github.com/damienbod/angular-auth-oidc-client/issues/750) - Not throwing an exception if interceptor is set and config is loaded from http - [PR](https://github.com/damienbod/angular-auth-oidc-client/pull/774) // fixes [#772](https://github.com/damienbod/angular-auth-oidc-client/issues/772) -- Bug fix: forceRefreshSession prematurely completes its observable [#767](https://github.com/damienbod/angular-auth-oidc-client/issues/767) -- Bug fix: Returns tokens but doesn't apply them [#759](https://github.com/damienbod/angular-auth-oidc-client/issues/759) +- Bug fix: forceRefreshSession prematurely completes its observable [#767](https://github.com/damienbod/angular-auth-oidc-client/issues/767) +- Bug fix: Returns tokens but doesn't apply them [#759](https://github.com/damienbod/angular-auth-oidc-client/issues/759) ### 2020-05-24 Version 11.1.2 diff --git a/package-lock.json b/package-lock.json index 68a5760e1..e2eb08993 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "angular-auth-oidc-client", - "version": "11.1.3", + "version": "11.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ddc03596e..b9a52029e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "bugs": { "url": "https://github.com/damienbod/angular-auth-oidc-client/issues" }, - "version": "11.1.3", + "version": "11.1.4", "scripts": { "ng": "ng", "build": "npm run build-lib", diff --git a/projects/angular-auth-oidc-client/package.json b/projects/angular-auth-oidc-client/package.json index 4718b47e9..b8bbfe64a 100644 --- a/projects/angular-auth-oidc-client/package.json +++ b/projects/angular-auth-oidc-client/package.json @@ -36,6 +36,6 @@ "authorization" ], "license": "MIT", - "version": "11.1.3", + "version": "11.1.4", "description": "Angular Lib for OpenID Connect & OAuth2" }