Skip to content

Commit 139592e

Browse files
poveilleuxshockey
authored andcommitted
feat: add PKCE support for OAuth2 Authorization Code flows (#5361)
* Add PKCE support. * Fix tests * Update oauth2.md * Rename usePkce * Fix the BrokenComponent error * Update oauth2.md * Remove isCode variable. Remove uuid4 dependency. * Remove utils functions * Import crypto * Fix tests * Fix the tests * Cleanup * Fix code_challenge generation * Move code challenge and verifier to utils for mocks. Update tests. * Mock the PKCE methods in the utils file properly. * Add missing expect * use target-method spies * Add comments to explain test values. * Get rid of jsrsasign.
1 parent 8cabcff commit 139592e

File tree

12 files changed

+13917
-18056
lines changed

12 files changed

+13917
-18056
lines changed

dev-helpers/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
realm: "your-realms",
6363
appName: "your-app-name",
6464
scopeSeparator: " ",
65-
additionalQueryStringParams: {}
65+
additionalQueryStringParams: {},
66+
usePkceWithAuthorizationCodeGrant: false
6667
})
6768
}
6869
</script>

docker/configurator/oauth.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const translator = require("./translator")
22
const indent = require("./helpers").indent
33

4-
const oauthBlockSchema = {
4+
const oauthBlockSchema = {
55
OAUTH_CLIENT_ID: {
66
type: "string",
77
name: "clientId"
@@ -26,6 +26,10 @@ const oauthBlockSchema = {
2626
OAUTH_ADDITIONAL_PARAMS: {
2727
type: "object",
2828
name: "additionalQueryStringParams"
29+
},
30+
OAUTH_USE_PKCE: {
31+
type: "boolean",
32+
name: "usePkceWithAuthorizationCodeGrant"
2933
}
3034
}
3135

docs/usage/oauth2.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ appName | `OAUTH_APP_NAME` |application name, displayed in authorization popup.
1010
scopeSeparator | `OAUTH_SCOPE_SEPARATOR` |scope separator for passing scopes, encoded before calling, default value is a space (encoded value `%20`). MUST be a string
1111
additionalQueryStringParams | `OAUTH_ADDITIONAL_PARAMS` |Additional query parameters added to `authorizationUrl` and `tokenUrl`. MUST be an object
1212
useBasicAuthenticationWithAccessCodeGrant | _Unavailable_ |Only activated for the `accessCode` flow. During the `authorization_code` request to the `tokenUrl`, pass the [Client Password](https://tools.ietf.org/html/rfc6749#section-2.3.1) using the HTTP Basic Authentication scheme (`Authorization` header with `Basic base64encode(client_id + client_secret)`). The default is `false`
13+
usePkceWithAuthorizationCodeGrant | `OAUTH_USE_PKCE` | Only applies to `authorizatonCode` flows. [Proof Key for Code Exchange](https://tools.ietf.org/html/rfc7636) brings enhanced security for OAuth public clients. The default is `false`
1314

1415
```javascript
1516
const ui = SwaggerUI({...})
@@ -21,6 +22,7 @@ ui.initOAuth({
2122
realm: "your-realms",
2223
appName: "your-app-name",
2324
scopeSeparator: " ",
24-
additionalQueryStringParams: {test: "hello"}
25+
additionalQueryStringParams: {test: "hello"},
26+
usePkceWithAuthorizationCodeGrant: true
2527
})
2628
```

0 commit comments

Comments
 (0)