Skip to content

Commit 5b14963

Browse files
Merge branch 'master' into manfredsteyergh-628/createNonce
2 parents a906a6b + d49021a commit 5b14963

20 files changed

+11946
-6961
lines changed

CHANGELOG.md

+7-20
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,13 @@
22

33
## Lates features
44

5-
See [Release Notes](https://github.com/manfredsteyer/angular-oauth2-oidc/releases)
5+
See [Release Notes](https://github.com/manfredsteyer/angular-oauth2-oidc/releases) for details on each release.
66

7-
## New Features in Version 2.1
8-
- New Config API (the original one is still supported)
9-
- New convenience methods in OAuthService to streamline default tasks:
10-
- ``setupAutomaticSilentRefresh()``
11-
- ``loadDiscoveryDocumentAndTryLogin()``
12-
- Single Sign out through Session Status Change Notification according to the OpenID Connect Session Management specs. This means, you can be notified when the user logs out using at the login provider.
13-
- Possibility to define the ValidationHandler, the Config as well as the OAuthStorage via DI
14-
- Better structured documentation
7+
## Older versions
158

16-
## New Features in Version 2
17-
- Token Refresh for Implicit Flow by implementing "silent refresh"
18-
- Validating the signature of the received id_token
19-
- Providing Events via the observable ``events``.
20-
- The event ``token_expires`` can be used together with a silent refresh to automatically refresh a token when/ before it expires (see also property ``timeoutFactor``).
9+
Since Angular 5, versions of this library matched up with the Angular version.
10+
So versions 5.x were released while Angular 5 was out, the 6.x versions during Angular 6, etc.
11+
If you need to support a specific old version of Angular, you can consider using a version of the library that lines up.
2112

22-
## Breaking Changes in Version 2
23-
- The property ``oidc`` defaults to ``true``.
24-
- If you are just using oauth2, you have to set ``oidc`` to ``false``. Otherwise, the validation of the user profile will fail!
25-
- By default, ``sessionStorage`` is used. To use ``localStorage`` call method setStorage
26-
- Demands using https as OIDC and OAuth2 relay on it. This rule can be relaxed using the property ``requireHttps``, e. g. for local testing.
27-
- Demands that every url provided by the discovery document starts with the issuer's url. This can be relaxed by using the property ``strictDiscoveryDocumentValidation``.
13+
For older release notes check the repository version history, or above-linked release notes.
14+
For even older versions, check out [the old change log](https://github.com/manfredsteyer/angular-oauth2-oidc/blob/5d676101c6118d6fa01bfa05b17fb4a58490eaf7/CHANGELOG.md).

README.md

+70-34
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,23 @@ Support for OAuth 2 and OpenId Connect (OIDC) in Angular.
77
## Credits
88

99
- [generator-angular2-library](https://github.com/jvandemo/generator-angular2-library) for scaffolding an Angular library
10-
- [jsrasign](https://kjur.github.io/jsrsasign/) until version 5: For validating token signature and for hashing; beginning with version 6, we are using browser APIs to minimize our bundle size
11-
- [Identity Server](https://github.com/identityserver) (used for testing with an .NET/.NET Core Backend)
10+
- [jsrasign](https://kjur.github.io/jsrsasign/) for validating token signature and for hashing
11+
- [Identity Server](https://github.com/identityserver) for testing with an .NET/.NET Core Backend
1212
- [Keycloak (Redhat)](http://www.keycloak.org/) for testing with Java
1313

1414
## Resources
1515

16-
- Sources and Sample:
17-
https://github.com/manfredsteyer/angular-oauth2-oidc
18-
19-
- Source Code Documentation
20-
https://manfredsteyer.github.io/angular-oauth2-oidc/docs
16+
- Sources and Sample: [https://github.com/manfredsteyer/angular-oauth2-oidc](https://github.com/manfredsteyer/angular-oauth2-oidc)
17+
- Source Code Documentation: [https://manfredsteyer.github.io/angular-oauth2-oidc/docs](https://manfredsteyer.github.io/angular-oauth2-oidc/docs)
18+
- Community-provided sample implementation: [https://github.com/jeroenheijmans/sample-angular-oauth2-oidc-with-auth-guards/](https://github.com/jeroenheijmans/sample-angular-oauth2-oidc-with-auth-guards/)
2119

2220
## Tested Environment
2321

24-
Successfully tested with **Angular 7** and its Router, PathLocationStrategy as well as HashLocationStrategy and CommonJS-Bundling via webpack. At server side we've used IdentityServer (.NET/ .NET Core) and Redhat's Keycloak (Java).
22+
Successfully tested with **Angular 9** and its Router, PathLocationStrategy as well as HashLocationStrategy and CommonJS-Bundling via webpack. At server side we've used IdentityServer (.NET / .NET Core) and Redhat's Keycloak (Java).
23+
24+
**Angular 8**: Use 8.x versions of this library.
25+
26+
**Angular 7**: Use 7.x versions of this library.
2527

2628
**Angular 6**: Use Version 4.x of this library. Version 4.x was tested with Angular 6. You can also try the newer version 5.x of this library which has a much smaller bundle size.
2729

@@ -30,21 +32,23 @@ Successfully tested with **Angular 7** and its Router, PathLocationStrategy as w
3032
## Release Cycle
3133

3234
- We plan one major release for each Angular version
33-
- Will contain new features
34-
- Will contain bug fixes and PRs
35+
- Will contain new features
36+
- Will contain bug fixes and PRs
3537
- Critical Bugfixes on demand
3638

3739
## Contributions
40+
3841
- Feel free to file pull requests
3942
- The closed issues contain some ideas for PRs and enhancements (see labels)
4043
- If you want to contribute to the docs, you can do so in the `docs-src` folder. Make sure you update `summary.json` as well. Then generate the docs with the following commands:
4144

42-
```
45+
``` sh
4346
npm install -g @compodoc/compodoc
4447
npm run docs
4548
```
4649

47-
# Features
50+
## Features
51+
4852
- Logging in via Implicit Flow (where a user is redirected to Identity Provider)
4953
- Logging in via Code Flow + PKCE
5054
- "Logging in" via Password Flow (where a user enters their password into the client)
@@ -58,22 +62,24 @@ Successfully tested with **Angular 7** and its Router, PathLocationStrategy as w
5862

5963
## Sample-Auth-Server
6064

61-
You can use the OIDC-Sample-Server mentioned in the samples for Testing. It assumes, that your Web-App runs on http://localhost:8080.
65+
You can use the OIDC-Sample-Server mentioned in the samples for Testing. It assumes, that your Web-App runs on http://localhost:8080
6266

6367
Username/Password: max/geheim
6468

65-
*clientIds:*
69+
*clientIds:*
70+
6671
- spa-demo (implicit flow)
6772
- demo-resource-owner (resource owner password flow)
6873

6974
*redirectUris:*
75+
7076
- localhost:[8080-8089|4200-4202]
7177
- localhost:[8080-8089|4200-4202]/index.html
7278
- localhost:[8080-8089|4200-4202]/silent-refresh.html
7379

7480
## Installing
7581

76-
```
82+
```sh
7783
npm i angular-oauth2-oidc --save
7884
```
7985

@@ -85,7 +91,7 @@ import { OAuthModule } from 'angular-oauth2-oidc';
8591
// etc.
8692

8793
@NgModule({
88-
imports: [
94+
imports: [
8995
// etc.
9096
HttpClientModule,
9197
OAuthModule.forRoot()
@@ -96,12 +102,12 @@ import { OAuthModule } from 'angular-oauth2-oidc';
96102
// etc.
97103
],
98104
bootstrap: [
99-
AppComponent
105+
AppComponent
100106
]
101107
})
102108
export class AppModule {
103109
}
104-
```
110+
```
105111

106112
## Configuring for Implicit Flow
107113

@@ -116,7 +122,6 @@ Hence, the original API is still supported.
116122
import { AuthConfig } from 'angular-oauth2-oidc';
117123

118124
export const authConfig: AuthConfig = {
119-
120125
// Url of the Identity Provider
121126
issuer: 'https://steyer-identity-server.azurewebsites.net/identity',
122127

@@ -215,9 +220,47 @@ The following snippet contains the template for the login page:
215220

216221
### Skipping the Login Form
217222

218-
If you don't want to display a login form that tells the user that they are redirected to the identity server, you can use the convenience function ``this.oauthService.loadDiscoveryDocumentAndLogin();`` instead of ``this.oauthService.loadDiscoveryDocumentAndTryLogin();`` when setting up the library.
223+
If you don't want to display a login form that tells the user that they are redirected to the identity server, you can use the convenience function ``this.oauthService.loadDiscoveryDocumentAndLogin();`` instead of ``this.oauthService.loadDiscoveryDocumentAndTryLogin();`` when setting up the library.
224+
225+
This directly redirects the user to the identity server if there are no valid tokens. Ensure you have your `issuer` set to your discovery document endpoint!
226+
219227

220-
This directly redirects the user to the identity server if there are no valid tokens.
228+
#### Manually skipping
229+
230+
This is sort of what ``this.oauthService.loadDiscoveryDocumentAndLogin();`` is doing under the hood. But this gives you a fair bit more control
231+
232+
```TypeScript
233+
this.oauthService
234+
.loadDiscoveryDocumentAndTryLogin(/* { your LoginOptions }*/) // checks to see if the current url contains id token and access token
235+
.(hasReceivedTokens => {
236+
// this would have stored all the tokens needed
237+
if (hasReceivedTokens) {
238+
// carry on with your app
239+
return Promise.resolve();
240+
241+
/* if you wish to do something when the user receives tokens from the identity server,
242+
* use the event stream or the `onTokenReceived` callback in LoginOptions.
243+
*
244+
* this.oauthService.events(filter(e => e.type === 'token_received')).subscribe()
245+
*/
246+
} else {
247+
// may want to check if you were previously authenticated
248+
if (this.oauthService.hasValidAccessToken() && this.oauthService.hasValidIdToken()) {
249+
return Promise.resolve();
250+
} else {
251+
// to safe guard this from progressing through the calling promise,
252+
// resolve it when it directed to the sign up page
253+
return new Promise(resolve => {
254+
this.oauthService.initLoginFlow();
255+
// example if you are using explicit flow
256+
this.window.addEventListener('unload', () => {
257+
resolve(true);
258+
});
259+
});
260+
}
261+
}
262+
})
263+
```
221264

222265

223266
### Calling a Web API with an Access Token
@@ -253,16 +296,9 @@ See the [documentation](https://manfredsteyer.github.io/angular-oauth2-oidc/docs
253296

254297
## Tutorials
255298

256-
* [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)
257-
* [Angular Authentication with OpenID Connect and Okta in 20 Minutes](https://developer.okta.com/blog/2017/04/17/angular-authentication-with-oidc)
258-
* [Add Authentication to Your Angular PWA](https://developer.okta.com/blog/2017/06/13/add-authentication-angular-pwa)
259-
* [Build an Ionic App with User Authentication](https://developer.okta.com/blog/2017/08/22/build-an-ionic-app-with-user-authentication)
260-
* [On-Site Workshops](https://www.softwarearchitekt.at)
261-
262-
263-
264-
265-
266-
267-
268-
299+
- [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)
300+
- [Angular Authentication with OpenID Connect and Okta in 20 Minutes](https://developer.okta.com/blog/2017/04/17/angular-authentication-with-oidc)
301+
- [Add Authentication to Your Angular PWA](https://developer.okta.com/blog/2017/06/13/add-authentication-angular-pwa)
302+
- [Build an Ionic App with User Authentication](https://developer.okta.com/blog/2017/08/22/build-an-ionic-app-with-user-authentication)
303+
- [On-Site Workshops](https://www.softwarearchitekt.at)
304+
- [Angular 6 with Auth0 using this library](https://github.com/jeroenheijmans/sample-auth0-angular-oauth2-oidc)

angular.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
},
1818
"configurations": {
1919
"production": {
20-
"project": "projects/lib/ng-package.prod.json"
20+
"project": "projects/lib/ng-package.prod.json",
21+
"tsConfig": "projects/lib/tsconfig.lib.prod.json"
2122
}
2223
}
2324
},
@@ -45,6 +46,7 @@
4546
"build": {
4647
"builder": "@angular-devkit/build-angular:browser",
4748
"options": {
49+
"aot": true,
4850
"outputPath": "dist/sample",
4951
"index": "projects/sample/src/index.html",
5052
"main": "projects/sample/src/main.ts",
@@ -63,6 +65,12 @@
6365
},
6466
"configurations": {
6567
"production": {
68+
"budgets": [
69+
{
70+
"type": "anyComponentStyle",
71+
"maximumWarning": "6kb"
72+
}
73+
],
6674
"fileReplacements": [
6775
{
6876
"replace": "projects/sample/src/environments/environment.ts",
@@ -157,5 +165,8 @@
157165
"@schematics/angular:component": {
158166
"styleext": "css"
159167
}
168+
},
169+
"cli": {
170+
"analytics": false
160171
}
161172
}

0 commit comments

Comments
 (0)