Skip to content

Commit 0d15d6a

Browse files
committed
chore: Add prettier and execute it
1 parent e2599e0 commit 0d15d6a

File tree

81 files changed

+2993
-3038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2993
-3038
lines changed

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Add files here to ignore them from prettier formatting
2+
3+
/dist
4+
/coverage

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

README.md

+47-50
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Support for OAuth 2 and OpenId Connect (OIDC) in Angular. Already prepared for t
1818

1919
## Breaking Change in Version 9
2020

21-
With regards to tree shaking, beginning with version 9, the ``JwksValidationHandler`` has been moved to a library of its own. If you need it for implementing **implicit flow**, please install it using npm:
21+
With regards to tree shaking, beginning with version 9, the `JwksValidationHandler` has been moved to a library of its own. If you need it for implementing **implicit flow**, please install it using npm:
2222

2323
```
2424
npm i angular-oauth2-oidc-jwks --save
@@ -38,7 +38,6 @@ import { JwksValidationHandler } from 'angular-oauth2-oidc';
3838

3939
Please note, that this dependency is not needed for the **code flow**, which is nowadays the **recommended** flow for single page applications. This also results in smaller bundle sizes.
4040

41-
4241
## Tested Environment
4342

4443
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).
@@ -66,14 +65,14 @@ Successfully tested with **Angular 9** and its Router, PathLocationStrategy as w
6665
- The issues contain some ideas for PRs and enhancements (see labels)
6766
- 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:
6867

69-
``` sh
68+
```sh
7069
npm install -g @compodoc/compodoc
7170
npm run docs
7271
```
7372

7473
## Features
7574

76-
- Logging in via Code Flow + PKCE
75+
- Logging in via Code Flow + PKCE
7776
- Hence, you are safe for the upcoming OAuth 2.1
7877
- Logging in via Implicit Flow (where a user is redirected to Identity Provider)
7978
- "Logging in" via Password Flow (where a user enters their password into the client)
@@ -90,17 +89,18 @@ Successfully tested with **Angular 9** and its Router, PathLocationStrategy as w
9089

9190
You can use the OIDC-Sample-Server used in our examples. It assumes, that your Web-App runs on http://localhost:4200
9291

93-
Username/Password:
94-
- max/geheim
95-
- bob/bob
96-
- alice/alice
92+
Username/Password:
93+
94+
- max/geheim
95+
- bob/bob
96+
- alice/alice
9797

98-
*clientIds:*
98+
_clientIds:_
9999

100100
- spa (Code Flow + PKCE)
101101
- implicit (implicit flow)
102102

103-
*redirectUris:*
103+
_redirectUris:_
104104

105105
- localhost:[4200-4202]
106106
- localhost:[4200-4202]/index.html
@@ -138,59 +138,58 @@ export class AppModule {
138138
}
139139
```
140140

141-
# Logging in
141+
# Logging in
142142

143143
Since Version 8, this library 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. This is also the foundation of the upcoming OAuth 2.1.
144144

145-
146145
To configure your solution for code flow + PKCE you have to set the `responseType` to `code`:
147146

148-
```TypeScript
149-
import { AuthConfig } from 'angular-oauth2-oidc';
147+
```TypeScript
148+
import { AuthConfig } from 'angular-oauth2-oidc';
150149

151-
export const authCodeFlowConfig: AuthConfig = {
152-
// Url of the Identity Provider
153-
issuer: 'https://demo.identityserver.io',
150+
export const authCodeFlowConfig: AuthConfig = {
151+
// Url of the Identity Provider
152+
issuer: 'https://demo.identityserver.io',
154153

155-
// URL of the SPA to redirect the user to after login
156-
redirectUri: window.location.origin + '/index.html',
154+
// URL of the SPA to redirect the user to after login
155+
redirectUri: window.location.origin + '/index.html',
157156

158-
// The SPA's id. The SPA is registerd with this id at the auth-server
159-
// clientId: 'server.code',
160-
clientId: 'spa',
157+
// The SPA's id. The SPA is registerd with this id at the auth-server
158+
// clientId: 'server.code',
159+
clientId: 'spa',
161160

162-
// Just needed if your auth server demands a secret. In general, this
163-
// is a sign that the auth server is not configured with SPAs in mind
164-
// and it might not enforce further best practices vital for security
165-
// such applications.
166-
// dummyClientSecret: 'secret',
161+
// Just needed if your auth server demands a secret. In general, this
162+
// is a sign that the auth server is not configured with SPAs in mind
163+
// and it might not enforce further best practices vital for security
164+
// such applications.
165+
// dummyClientSecret: 'secret',
167166

168-
responseType: 'code',
167+
responseType: 'code',
169168

170-
// set the scope for the permissions the client should request
171-
// The first four are defined by OIDC.
172-
// Important: Request offline_access to get a refresh token
173-
// The api scope is a usecase specific one
174-
scope: 'openid profile email offline_access api',
169+
// set the scope for the permissions the client should request
170+
// The first four are defined by OIDC.
171+
// Important: Request offline_access to get a refresh token
172+
// The api scope is a usecase specific one
173+
scope: 'openid profile email offline_access api',
175174

176-
showDebugInformation: true,
175+
showDebugInformation: true,
177176

178-
// Not recommented:
179-
// disablePKCI: true,
180-
};
181-
```
177+
// Not recommented:
178+
// disablePKCI: true,
179+
};
180+
```
182181

183182
After this, you can initialize the code flow using:
184183

185-
```TypeScript
186-
this.oauthService.initCodeFlow();
187-
```
184+
```TypeScript
185+
this.oauthService.initCodeFlow();
186+
```
188187

189-
There is also a convenience method `initLoginFlow` which initializes either the code flow or the implicit flow depending on your configuration.
188+
There is also a convenience method `initLoginFlow` which initializes either the code flow or the implicit flow depending on your configuration.
190189

191-
```TypeScript
192-
this.oauthService.initLoginFlow();
193-
```
190+
```TypeScript
191+
this.oauthService.initLoginFlow();
192+
```
194193

195194
Also -- as shown in the readme -- you have to execute the following code when bootstrapping to make the library to fetch the token:
196195

@@ -199,17 +198,15 @@ this.oauthService.configure(authCodeFlowConfig);
199198
this.oauthService.loadDiscoveryDocumentAndTryLogin();
200199
```
201200

202-
203201
### Skipping the Login Form
204202

205-
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.
203+
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.
206204

207205
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!
208206

209-
210207
### Calling a Web API with an Access Token
211208

212-
You can 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.
209+
You can 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.
213210

214211
```TypeScript
215212
OAuthModule.forRoot({
@@ -228,7 +225,7 @@ See docs: https://manfredsteyer.github.io/angular-oauth2-oidc/docs/additional-do
228225

229226
## Routing
230227

231-
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/).
228+
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/).
232229

233230
## Implicit Flow
234231

angular.json

+7-19
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
"projects/lib/tsconfig.lib.json",
3030
"projects/lib/tsconfig.spec.json"
3131
],
32-
"exclude": [
33-
"**/node_modules/**"
34-
]
32+
"exclude": ["**/node_modules/**"]
3533
}
3634
}
3735
}
@@ -131,9 +129,7 @@
131129
"projects/sample/tsconfig.app.json",
132130
"projects/sample/tsconfig.spec.json"
133131
],
134-
"exclude": [
135-
"**/node_modules/**"
136-
]
132+
"exclude": ["**/node_modules/**"]
137133
}
138134
}
139135
}
@@ -159,9 +155,7 @@
159155
"projects/quickstart-demo/src/favicon.ico",
160156
"projects/quickstart-demo/src/assets"
161157
],
162-
"styles": [
163-
"projects/quickstart-demo/src/styles.css"
164-
],
158+
"styles": ["projects/quickstart-demo/src/styles.css"],
165159
"scripts": []
166160
},
167161
"configurations": {
@@ -219,9 +213,7 @@
219213
"projects/quickstart-demo/src/favicon.ico",
220214
"projects/quickstart-demo/src/assets"
221215
],
222-
"styles": [
223-
"projects/quickstart-demo/src/styles.css"
224-
],
216+
"styles": ["projects/quickstart-demo/src/styles.css"],
225217
"scripts": []
226218
}
227219
},
@@ -233,9 +225,7 @@
233225
"projects/quickstart-demo/tsconfig.spec.json",
234226
"projects/quickstart-demo/e2e/tsconfig.json"
235227
],
236-
"exclude": [
237-
"**/node_modules/**"
238-
]
228+
"exclude": ["**/node_modules/**"]
239229
}
240230
},
241231
"e2e": {
@@ -281,9 +271,7 @@
281271
"projects/angular-oauth2-oidc-jwks/tsconfig.lib.json",
282272
"projects/angular-oauth2-oidc-jwks/tsconfig.spec.json"
283273
],
284-
"exclude": [
285-
"**/node_modules/**"
286-
]
274+
"exclude": ["**/node_modules/**"]
287275
}
288276
}
289277
}
@@ -297,4 +285,4 @@
297285
"cli": {
298286
"analytics": false
299287
}
300-
}
288+
}

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"scripts": {
66
"ng": "ng",
77
"start": "ng serve --project sample -o",
8-
"build": "ng build --prod --project lib && npm run copy:readme && npm run docs",
9-
"build:jwks": "ng build angular-oauth2-oidc-jwks --ts-config tsconfig.npm.json",
8+
"build": "npm run prettier && ng build --prod --project lib && npm run copy:readme && npm run docs",
9+
"build:jwks": "npm run prettier && ng build angular-oauth2-oidc-jwks --ts-config tsconfig.npm.json",
1010
"test": "ng test",
1111
"lint": "ng lint",
1212
"e2e": "ng e2e",
1313
"tsc": "tsc",
14+
"prettier": "prettier --write projects/**",
1415
"docs": "npm run docs:build -- --disableCoverage --disablePrivate --disableInternal --includes docs-src",
1516
"docs:build": "compodoc -p projects/lib/tsconfig.lib.json -n angular-oauth2-oidc -d docs --hideGenerator",
1617
"docs:serve": "npm run docs:build -- -s",
@@ -64,7 +65,7 @@
6465
"karma-jasmine": "~3.1.0",
6566
"karma-jasmine-html-reporter": "^1.5.2",
6667
"ng-packagr": "^9.0.0",
67-
"prettier": "1.19.1",
68+
"prettier": "^1.19.1",
6869
"protractor": "~5.4.3",
6970
"ts-node": "~8.6.2",
7071
"tslint": "~5.18.0",
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# angular-oauth2-oidc-jwks
22

3-
``JwksValidationHandler`` for ``angular-oauth2-odic``. Only needed for implicit flow.
3+
`JwksValidationHandler` for `angular-oauth2-odic`. Only needed for implicit flow.

projects/angular-oauth2-oidc-jwks/karma.conf.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Karma configuration file, see link for more information
22
// https://karma-runner.github.io/1.0/config/configuration-file.html
33

4-
module.exports = function (config) {
4+
module.exports = function(config) {
55
config.set({
66
basePath: '',
77
frameworks: ['jasmine', '@angular-devkit/build-angular'],
@@ -16,7 +16,10 @@ module.exports = function (config) {
1616
clearContext: false // leave Jasmine Spec Runner output visible in browser
1717
},
1818
coverageIstanbulReporter: {
19-
dir: require('path').join(__dirname, '../../coverage/angular-oauth2-oidc-jwks'),
19+
dir: require('path').join(
20+
__dirname,
21+
'../../coverage/angular-oauth2-oidc-jwks'
22+
),
2023
reports: ['html', 'lcovonly'],
2124
fixWebpackSourcePaths: true
2225
},

projects/angular-oauth2-oidc-jwks/ng-package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44
"lib": {
55
"entryFile": "src/public-api.ts"
66
},
7-
"whitelistedNonPeerDependencies": [
8-
"jsrsasign"
9-
]
10-
}
7+
"whitelistedNonPeerDependencies": ["jsrsasign"]
8+
}

projects/angular-oauth2-oidc-jwks/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"dependencies": {
55
"jsrsasign": "^8.0.12"
66
}
7-
}
7+
}

projects/angular-oauth2-oidc-jwks/src/lib/jwks-validation-handler.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import * as rs from 'jsrsasign';
2-
import { AbstractValidationHandler, ValidationParams } from 'angular-oauth2-oidc';
2+
import {
3+
AbstractValidationHandler,
4+
ValidationParams
5+
} from 'angular-oauth2-oidc';
36

47
/**
58
* Validates the signature of an id_token against one
@@ -147,4 +150,4 @@ export class JwksValidationHandler extends AbstractValidationHandler {
147150
}
148151
return result;
149152
}
150-
}
153+
}

projects/angular-oauth2-oidc-jwks/tsconfig.lib.json

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
"declaration": true,
77
"inlineSources": true,
88
"types": [],
9-
"lib": [
10-
"dom",
11-
"es2018"
12-
]
9+
"lib": ["dom", "es2018"]
1310
},
1411
"angularCompilerOptions": {
1512
"annotateForClosureCompiler": true,
@@ -19,8 +16,5 @@
1916
"strictInjectionParameters": true,
2017
"enableResourceInlining": true
2118
},
22-
"exclude": [
23-
"src/test.ts",
24-
"**/*.spec.ts"
25-
]
19+
"exclude": ["src/test.ts", "**/*.spec.ts"]
2620
}

projects/angular-oauth2-oidc-jwks/tsconfig.spec.json

+3-11
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../../out-tsc/spec",
5-
"types": [
6-
"jasmine",
7-
"node"
8-
]
5+
"types": ["jasmine", "node"]
96
},
10-
"files": [
11-
"src/test.ts"
12-
],
13-
"include": [
14-
"**/*.spec.ts",
15-
"**/*.d.ts"
16-
]
7+
"files": ["src/test.ts"],
8+
"include": ["**/*.spec.ts", "**/*.d.ts"]
179
}

0 commit comments

Comments
 (0)