Skip to content

Commit

Permalink
Merge pull request #811 from damienbod/fabiangosebrink/fixing-missing…
Browse files Browse the repository at this point in the history
…-catch-error

checkAuthIncludingServer cannot complete without credentials
  • Loading branch information
damienbod authored Jul 4, 2020
2 parents ae9dade + 694f02e commit 73b2f75
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 13 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion projects/angular-auth-oidc-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"authorization"
],
"license": "MIT",
"version": "11.1.3",
"version": "11.1.4",
"description": "Angular Lib for OpenID Connect & OAuth2"
}
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -25,7 +26,7 @@ export class CallbackService {
return this.urlService.isCallbackFromSts();
}

handleCallbackAndFireEvents(currentCallbackUrl: string) {
handleCallbackAndFireEvents(currentCallbackUrl: string): Observable<CallbackContext> {
let callback$: Observable<any>;

if (this.flowHelper.isCurrentFlowCodeFlow()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -90,7 +90,8 @@ export class OidcSecurityService {
this.loggerService.logDebug('checkAuth completed fire events, auth: ' + isAuthenticated);

return isAuthenticated;
})
}),
catchError(() => of(false))
);
}

Expand Down
2 changes: 2 additions & 0 deletions projects/sample-code-flow/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
1 change: 1 addition & 0 deletions projects/sample-code-flow/src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<div *ngIf="isAuthenticated$ | async as isAuthenticated; else noAuth">
<button (click)="logout()">Logout</button>
<button (click)="forceRefreshSession()">RefreshSession</button>
<hr />

<br />
Expand Down
3 changes: 3 additions & 0 deletions projects/sample-code-flow/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 73b2f75

Please sign in to comment.