Skip to content

Commit 846415f

Browse files
Merge branch 'master' into master
2 parents c2cce4e + 7c752e5 commit 846415f

12 files changed

+171
-150
lines changed

README.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Successfully tested with **Angular 6** and its Router, PathLocationStrategy as w
3737
- The closed issues contain some ideas for PRs and enhancements (see labels)
3838

3939
# Features
40-
- Logging in via OAuth2 and OpenId Connect (OIDC) Implicit Flow (where user is redirected to Identity Provider)
41-
- "Logging in" via Password Flow (where user enters their password into the client)
40+
- Logging in via OAuth2 and OpenId Connect (OIDC) Implicit Flow (where a user is redirected to Identity Provider)
41+
- "Logging in" via Password Flow (where a user enters their password into the client)
4242
- Token Refresh for Password Flow by using a Refresh Token
4343
- Automatically refreshing a token when/some time before it expires
4444
- Querying Userinfo Endpoint
@@ -71,27 +71,27 @@ npm i angular-oauth2-oidc --save
7171
## Importing the NgModule
7272

7373
```TypeScript
74+
import { HttpClientModule } from '@angular/common/http';
7475
import { OAuthModule } from 'angular-oauth2-oidc';
75-
[...]
76+
// etc.
7677

7778
@NgModule({
7879
imports: [
79-
[...]
80-
HttpModule,
80+
// etc.
81+
HttpClientModule,
8182
OAuthModule.forRoot()
8283
],
8384
declarations: [
8485
AppComponent,
8586
HomeComponent,
86-
[...]
87+
// etc.
8788
],
8889
bootstrap: [
8990
AppComponent
9091
]
9192
})
9293
export class AppModule {
9394
}
94-
9595
```
9696

9797
## Configuring for Implicit Flow
@@ -100,7 +100,7 @@ This section shows how to implement login leveraging implicit flow. This is the
100100
Single Page Application. It sends the user to the Identity Provider's login page. After logging in, the SPA gets tokens.
101101
This also allows for single sign on as well as single sign off.
102102

103-
To configure the library the following sample uses the new configuration API introduced with Version 2.1.
103+
To configure the library, the following sample uses the new configuration API introduced with Version 2.1.
104104
Hence, the original API is still supported.
105105

106106
```TypeScript
@@ -229,7 +229,7 @@ var headers = new HttpHeaders({
229229
});
230230
```
231231

232-
Since 3.1 you can also automate this task by switching ``sendAccessToken`` on and by setting ``allowedUrls`` to an array with prefixes for the respective urls. Use lower case for the prefixes.
232+
Since 3.1 you can also automate this task by switching ``sendAccessToken`` on and by setting ``allowedUrls`` to an array with prefixes for the respective URLs. Use lower case for the prefixes.
233233

234234
```TypeScript
235235
OAuthModule.forRoot({
@@ -250,10 +250,11 @@ See the [documentation](https://manfredsteyer.github.io/angular-oauth2-oidc/docs
250250

251251
## Tutorials
252252

253+
* [Tutorial with Demo Servers available online](https://www.softwarearchitekt.at/post/2016/07/03/authentication-in-angular-2-with-oauth2-oidc-and-guards-for-the-newest-new-router-english-version.aspx)
253254
* [Angular Authentication with OpenID Connect and Okta in 20 Minutes](https://developer.okta.com/blog/2017/04/17/angular-authentication-with-oidc)
254255
* [Add Authentication to Your Angular PWA](https://developer.okta.com/blog/2017/06/13/add-authentication-angular-pwa)
255256
* [Build an Ionic App with User Authentication](https://developer.okta.com/blog/2017/08/22/build-an-ionic-app-with-user-authentication)
256-
257+
* [On-Site Workshops](https://www.softwarearchitekt.at)
257258

258259

259260

docs-src/session-checks.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const authConfig: AuthConfig = {
3333
To get notified, you can hook up for the event ``session_terminated``:
3434

3535
```TypeScript
36-
this.oauthService.events.filter(e => e.type === 'session_terminated').subscribe(e => {
37-
console.debug('Your session has been terminated!');
36+
this.oauthService.events.pipe(filter(e => e.type === 'session_terminated')).subscribe(e => {
37+
console.debug('Your session has been terminated!');
3838
})
39-
```
39+
```

docs-src/silent-refresh.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ this
7070
.catch(err => console.error('refresh error', err));
7171
```
7272

73-
When there is an error in the iframe that prevents the communication with the main application, silentRefresh will give you a timeout. To configure the timespan for this, you can set the property ``siletRefreshTimeout`` (msec). The default value is 20.000 (20 seconds).
73+
When there is an error in the iframe that prevents the communication with the main application, silentRefresh will give you a timeout. To configure the timespan for this, you can set the property ``silentRefreshTimeout`` (msec). The default value is 20.000 (20 seconds).
7474

7575
### Automatically refreshing a token when/ before it expires
7676

docs/additional-documentation/refreshing-a-token-(silent-refresh).html

+1-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ <h1 id="refreshing-a-token-when-using-implicit-flow-silent-refresh-">Refreshing
655655
.oauthService
656656
.silentRefresh()
657657
.then(info =&gt; console.debug(&#39;refresh ok&#39;, info))
658-
.catch(err =&gt; console.error(&#39;refresh error&#39;, err));</code></pre><p>When there is an error in the iframe that prevents the communication with the main application, silentRefresh will give you a timeout. To configure the timespan for this, you can set the property <code>siletRefreshTimeout</code> (msec). The default value is 20.000 (20 seconds).</p>
658+
.catch(err =&gt; console.error(&#39;refresh error&#39;, err));</code></pre><p>When there is an error in the iframe that prevents the communication with the main application, silentRefresh will give you a timeout. To configure the timespan for this, you can set the property <code>silentRefreshTimeout</code> (msec). The default value is 20.000 (20 seconds).</p>
659659
<h3 id="automatically-refreshing-a-token-when-before-it-expires">Automatically refreshing a token when/ before it expires</h3>
660660
<p>To automatically refresh a token when/ some time before it expires, just call the following method after configuring the OAuthService:</p>
661661
<pre class="line-numbers"><code class="language-TypeScript">this.oauthService.setupAutomaticSilentRefresh();</code></pre><p>By default, this event is fired after 75% of the token&#39;s life time is over. You can adjust this factor by setting the property <code>timeoutFactor</code> to a value between 0 and 1. For instance, 0.5 means, that the event is fired after half of the life time is over and 0.33 triggers the event after a third.</p>

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@types/jasminewd2": "~2.0.3",
4949
"@types/node": "~8.0.51",
5050
"codelyzer": "~4.0.1",
51+
"cpr": "^3.0.1",
5152
"jasmine-core": "~2.8.0",
5253
"jasmine-spec-reporter": "~4.2.1",
5354
"karma": "~1.7.1",

projects/lib/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": {
55
"name": "Manfred Steyer"
66
},
7-
"version": "4.0.2",
7+
"version": "4.0.3",
88
"repository": "manfredsteyer/angular-oauth2-oidc",
99
"peerDependencies": {
1010
"@angular/common": "^6.0.0",

projects/lib/src/angular-oauth-oidic.module.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OAuthStorage } from './types';
1+
import { OAuthStorage, OAuthLogger } from './types';
22
import { NgModule, ModuleWithProviders } from '@angular/core';
33
import { CommonModule } from '@angular/common';
44
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
@@ -15,6 +15,10 @@ import { DefaultOAuthInterceptor } from './interceptors/default-oauth.intercepto
1515
import { ValidationHandler } from './token-validation/validation-handler';
1616
import { NullValidationHandler } from './token-validation/null-validation-handler';
1717

18+
export function createDefaultLogger() {
19+
return console;
20+
}
21+
1822
export function createDefaultStorage() {
1923
return typeof sessionStorage !== 'undefined' ? sessionStorage : null;
2024
}
@@ -29,13 +33,12 @@ export class OAuthModule {
2933
config: OAuthModuleConfig = null,
3034
validationHandlerClass = NullValidationHandler
3135
): ModuleWithProviders {
32-
// const setupInterceptor = config && config.resourceServer && config.resourceServer.allowedUrls;
33-
3436
return {
3537
ngModule: OAuthModule,
3638
providers: [
3739
OAuthService,
3840
UrlHelperService,
41+
{ provide: OAuthLogger, useFactory: createDefaultLogger },
3942
{ provide: OAuthStorage, useFactory: createDefaultStorage },
4043
{ provide: ValidationHandler, useClass: validationHandlerClass},
4144
{

projects/lib/src/auth.config.ts

+21-22
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class AuthConfig {
3737
public oidc? = true;
3838

3939
/**
40-
* Defines whether to request a access token during
40+
* Defines whether to request an access token during
4141
* implicit flow.
4242
*/
4343
public requestAccessToken? = true;
@@ -66,7 +66,6 @@ export class AuthConfig {
6666

6767
/**
6868
* Url of the userinfo endpoint as defined by OpenId Connect.
69-
*
7069
*/
7170
public userinfoEndpoint?: string = null;
7271

@@ -107,9 +106,9 @@ export class AuthConfig {
107106

108107
/**
109108
* Some auth servers don't allow using password flow
110-
* w/o a client secreat while the standards do not
109+
* w/o a client secret while the standards do not
111110
* demand for it. In this case, you can set a password
112-
* here. As this passwort is exposed to the public
111+
* here. As this password is exposed to the public
113112
* it does not bring additional security and is therefore
114113
* as good as using no password.
115114
*/
@@ -159,7 +158,7 @@ export class AuthConfig {
159158
public sessionChecksEnabled? = false;
160159

161160
/**
162-
* Intervall in msec for checking the session
161+
* Interval in msec for checking the session
163162
* according to http://openid.net/specs/openid-connect-session-1_0.html#ChangeNotification
164163
*/
165164
public sessionCheckIntervall? = 3 * 1000;
@@ -183,18 +182,18 @@ export class AuthConfig {
183182
*/
184183
public disableAtHashCheck? = false;
185184

186-
/*
187-
* Defines wether to check the subject of a refreshed token after silent refresh.
188-
* Normally, it should be the same as before.
189-
*/
185+
/**
186+
* Defines wether to check the subject of a refreshed token after silent refresh.
187+
* Normally, it should be the same as before.
188+
*/
190189
public skipSubjectCheck? = false;
191190

192191
public useIdTokenHintForSilentRefresh? = false;
193192

194-
/*
195-
* Defined whether to skip the validation of the issuer in the discovery document.
196-
* Normally, the discovey document's url starts with the url of the issuer.
197-
*/
193+
/**
194+
* Defined whether to skip the validation of the issuer in the discovery document.
195+
* Normally, the discovey document's url starts with the url of the issuer.
196+
*/
198197
public skipIssuerCheck? = false;
199198

200199
/**
@@ -204,17 +203,17 @@ export class AuthConfig {
204203
*/
205204
public fallbackAccessTokenExpirationTimeInSec?: number;
206205

207-
/*
208-
* final state sent to issuer is built as follows:
209-
* state = nonce + nonceStateSeparator + additional state
210-
* Default separator is ';' (encoded %3B).
211-
* In rare cases, this character might be forbidden or inconvenient to use by the issuer so it can be customized.
212-
*/
206+
/**
207+
* final state sent to issuer is built as follows:
208+
* state = nonce + nonceStateSeparator + additional state
209+
* Default separator is ';' (encoded %3B).
210+
* In rare cases, this character might be forbidden or inconvenient to use by the issuer so it can be customized.
211+
*/
213212
public nonceStateSeparator? = ';';
214213

215-
/*
216-
* set this to true to use HTTP BASIC auth for password flow
217-
*/
214+
/**
215+
* Set this to true to use HTTP BASIC auth for password flow
216+
*/
218217
public useHttpBasicAuthForPasswordFlow? = false;
219218

220219
constructor(json?: Partial<AuthConfig>) {

0 commit comments

Comments
 (0)