You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-11
Original file line number
Diff line number
Diff line change
@@ -38,15 +38,17 @@ Successfully tested with **Angular 7** and its Router, PathLocationStrategy as w
38
38
- Feel free to file pull requests
39
39
- The closed issues contain some ideas for PRs and enhancements (see labels)
40
40
- 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:
41
-
```
42
-
npm install -g @compodoc/compodoc
43
-
npm run docs
44
-
```
41
+
42
+
```
43
+
npm install -g @compodoc/compodoc
44
+
npm run docs
45
+
```
45
46
46
47
# Features
47
-
- Logging in via OAuth2 and OpenId Connect (OIDC) Implicit Flow (where a user is redirected to Identity Provider)
48
+
- Logging in via Implicit Flow (where a user is redirected to Identity Provider)
49
+
- Logging in via Code Flow + PKCE
48
50
- "Logging in" via Password Flow (where a user enters their password into the client)
49
-
- Token Refresh for Password Flow by using a Refresh Token
51
+
- Token Refresh for all supported flows
50
52
- Automatically refreshing a token when/some time before it expires
51
53
- Querying Userinfo Endpoint
52
54
- Querying Discovery Document to ease configuration
@@ -237,7 +239,7 @@ If you need more versatility, you can look in the [documentation](https://manfre
237
239
238
240
If you use the ``PathLocationStrategy`` (which is on by default) and have a general catch-all-route (``path: '**'``) you should be fine. Otherwise look up the section ``Routing with the HashStrategy`` in the [documentation](https://manfredsteyer.github.io/angular-oauth2-oidc/docs/).
239
241
240
-
## More Documentation
242
+
## More Documentation (!)
241
243
242
244
See the [documentation](https://manfredsteyer.github.io/angular-oauth2-oidc/docs/) for more information about this library.
Since Version 8, this library also supports code flow and [PKCE](https://tools.ietf.org/html/rfc7636) to align with the current draft of the [OAuth 2.0 Security Best Current Practice](https://tools.ietf.org/html/draft-ietf-oauth-security-topics-13) document.
4
+
5
+
6
+
To configure your solution for code flow + PKCE you have to set the ``responseType`` to ``code``:
7
+
8
+
```typescript
9
+
import { AuthConfig } from'angular-oauth2-oidc';
10
+
11
+
exportconst authCodeFlowConfig:AuthConfig= {
12
+
// Url of the Identity Provider
13
+
issuer: 'https://demo.identityserver.io',
14
+
15
+
// URL of the SPA to redirect the user to after login
Copy file name to clipboardExpand all lines: docs-src/silent-refresh.md
+25-3
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,27 @@
1
-
# Refreshing a Token when using Implicit Flow (Silent Refresh)
1
+
# Refreshing a Token
2
2
3
-
To refresh your tokens when using implicit flow you can use a silent refresh. This is a well-known solution that compensates the fact that implicit flow does not allow for issuing a refresh token. It uses a hidden iframe to get another token from the auth-server. When the user is there still logged in (by using a cookie) it will respond without user interaction and provide new tokens.
3
+
The strategy to use for refreshing your token differs between implicit flow and code flow. Hence, you find here one separate section for both of them.
4
+
5
+
The last section shows how to automate refreshing for both flows.
6
+
7
+
## Refreshing when using Code Flow (not Implicit Flow!)
8
+
9
+
>> For refreshing a token with implicit flow, please see section below!
10
+
11
+
When using code flow, you can get an ``refresh_token``. While the original standard DOES NOT allow this for SPAs, the mentioned document proposes to ease this limitation. However, it specifies a list of requirements one should take care about before using refresh_tokens. Please make sure you respect those requirements.
12
+
13
+
Please also note, that you have to request the ``offline_access`` scope to get an refresh token.
14
+
15
+
To refresh your token, just call the ``refresh`` method:
16
+
17
+
```typescript
18
+
this.oauthService.refresh();
19
+
```
20
+
21
+
22
+
## Refreshing when using Implicit Flow (not Code Flow!)
23
+
24
+
To refresh your tokens when using implicit flow you can use a silent refresh. This is a well-known solution that compensates the fact that implicit flow does not allow for issuing a refresh token. It uses a hidden iframe to get another token from the auth server. When the user is there still logged in (by using a cookie) it will respond without user interaction and provide new tokens.
4
25
5
26
To use this approach, setup a redirect uri for the silent refresh.
6
27
@@ -72,7 +93,8 @@ this
72
93
73
94
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).
74
95
75
-
### Automatically refreshing a token when/ before it expires
96
+
### Automatically refreshing a token when/ before it expires (Code Flow and Implicit Flow)
97
+
76
98
77
99
To automatically refresh a token when/ some time before it expires, just call the following method after configuring the OAuthService:
0 commit comments