|
3 | 3 | 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 | 4 |
|
5 | 5 |
|
6 |
| -To configure your solution for code flow + PKCE you have to set the ``responseType`` to ``code``: |
| 6 | +To configure your solution for code flow + PKCE you have to set the `responseType` to `code`: |
7 | 7 |
|
8 |
| -```typescript |
9 |
| -import { AuthConfig } from 'angular-oauth2-oidc'; |
| 8 | + ```TypeScript |
| 9 | + import { AuthConfig } from 'angular-oauth2-oidc'; |
10 | 10 |
|
11 |
| -export const authCodeFlowConfig: AuthConfig = { |
12 |
| - // Url of the Identity Provider |
13 |
| - issuer: 'https://demo.identityserver.io', |
| 11 | + export const authCodeFlowConfig: AuthConfig = { |
| 12 | + // Url of the Identity Provider |
| 13 | + issuer: 'https://demo.identityserver.io', |
14 | 14 |
|
15 |
| - // URL of the SPA to redirect the user to after login |
16 |
| - redirectUri: window.location.origin + '/index.html', |
| 15 | + // URL of the SPA to redirect the user to after login |
| 16 | + redirectUri: window.location.origin + '/index.html', |
17 | 17 |
|
18 |
| - // The SPA's id. The SPA is registerd with this id at the auth-server |
19 |
| - // clientId: 'server.code', |
20 |
| - clientId: 'spa', |
| 18 | + // The SPA's id. The SPA is registerd with this id at the auth-server |
| 19 | + // clientId: 'server.code', |
| 20 | + clientId: 'spa', |
21 | 21 |
|
22 |
| - // Just needed if your auth server demands a secret. In general, this |
23 |
| - // is a sign that the auth server is not configured with SPAs in mind |
24 |
| - // and it might not enforce further best practices vital for security |
25 |
| - // such applications. |
26 |
| - // dummyClientSecret: 'secret', |
| 22 | + // Just needed if your auth server demands a secret. In general, this |
| 23 | + // is a sign that the auth server is not configured with SPAs in mind |
| 24 | + // and it might not enforce further best practices vital for security |
| 25 | + // such applications. |
| 26 | + // dummyClientSecret: 'secret', |
27 | 27 |
|
28 |
| - responseType: 'code', |
| 28 | + responseType: 'code', |
29 | 29 |
|
30 |
| - // set the scope for the permissions the client should request |
31 |
| - // The first four are defined by OIDC. |
32 |
| - // Important: Request offline_access to get a refresh token |
33 |
| - // The api scope is a usecase specific one |
34 |
| - scope: 'openid profile email offline_access api', |
| 30 | + // set the scope for the permissions the client should request |
| 31 | + // The first four are defined by OIDC. |
| 32 | + // Important: Request offline_access to get a refresh token |
| 33 | + // The api scope is a usecase specific one |
| 34 | + scope: 'openid profile email offline_access api', |
35 | 35 |
|
36 |
| - showDebugInformation: true, |
| 36 | + showDebugInformation: true, |
37 | 37 |
|
38 |
| - // Not recommented: |
39 |
| - // disablePKCI: true, |
40 |
| -}; |
41 |
| -``` |
| 38 | + // Not recommented: |
| 39 | + // disablePKCI: true, |
| 40 | + }; |
| 41 | + ``` |
42 | 42 |
|
43 | 43 | After this, you can initialize the code flow using:
|
44 | 44 |
|
45 |
| -```typescript |
46 |
| -this.oauthService.initCodeFlow(); |
47 |
| -``` |
| 45 | + ```TypeScript |
| 46 | + this.oauthService.initCodeFlow(); |
| 47 | + ``` |
48 | 48 |
|
49 |
| -There is also a convenience method ``initLoginFlow`` which initializes either the code flow or the implicit flow depending on your configuration. |
| 49 | +There is also a convenience method `initLoginFlow` which initializes either the code flow or the implicit flow depending on your configuration. |
50 | 50 |
|
51 |
| -```typescript |
52 |
| -this.oauthService.initLoginFlow(); |
53 |
| -``` |
| 51 | + ```TypeScript |
| 52 | + this.oauthService.initLoginFlow(); |
| 53 | + ``` |
54 | 54 |
|
55 | 55 | Also -- as shown in the readme -- you have to execute the following code when bootstrapping to make the library to fetch the token:
|
56 | 56 |
|
57 |
| -```typescript |
| 57 | +```TypeScript |
58 | 58 | this.oauthService.configure(authCodeFlowConfig);
|
59 | 59 | this.oauthService.tokenValidationHandler = new JwksValidationHandler();
|
60 | 60 | this.oauthService.loadDiscoveryDocumentAndTryLogin();
|
|
0 commit comments