Skip to content

Commit 3b04eb6

Browse files
committed
Update docs
1 parent f7b648c commit 3b04eb6

1 file changed

Lines changed: 44 additions & 4 deletions

File tree

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,21 @@ Alternatively you can use a `GET` request for the `/connect/:provider/:override?
347347
https://awesome.com/connect/shopify?subdomain=usershop
348348
```
349349

350+
Lastly you can use the request/response lifecycle state as well:
351+
352+
```js
353+
// Express
354+
res.locals.grant = {dynamic: {subdomain: 'usershop'}}
355+
// Koa
356+
ctx.state.grant = {dynamic: {subdomain: 'usershop'}}
357+
// Hapi
358+
request.plugins.grant = {dynamic: {subdomain: 'usershop'}}
359+
```
360+
361+
Note that the dynamic overrides set in the request/response lifecycle state are not controlled by the `dynamic` configuration option.
362+
363+
Any allowed dynamic key sent through GET/POST request will override the identical one set in state.
364+
350365
---
351366

352367
# Response Data
@@ -435,6 +450,27 @@ It is **recommended** to use the *session* `transport` instead:
435450

436451
That way the result will no longer be encoded as *querystring*, and you will receive the response data inside the [*session*][session-transport-example] instead.
437452

453+
Lastly the request/response lifecycle state can be used as `state` transport:
454+
455+
```json
456+
{
457+
"defaults": {
458+
"transport": "state"
459+
}
460+
}
461+
```
462+
463+
Note that in this case a `callback` route is not needed, and if there is one, the user won't be redirected there. The response data will be available in the request/response lifecycle state instead:
464+
465+
```js
466+
// Express
467+
res.locals.grant.response
468+
// Koa
469+
ctx.state.grant.response
470+
// Hapi
471+
request.plugins.grant.response
472+
```
473+
438474

439475
## Limit Response Data
440476

@@ -497,8 +533,9 @@ Key | Availability | Description
497533
`dynamic` | Depends on request type | The [dynamic override](#dynamic-override) configuration passed for this authorization
498534
`state` | OAuth 2.0 only | OAuth 2.0 state string that was generated
499535
`nonce` | OpenID Connect only | [OpenID Connect](#openid-connect) nonce string that was generated
500-
`response` | Depends on transport used | The final [response data](#response-data)
536+
`code_verifier` | PKCE only | The code verifier that was generated
501537
`request` | OAuth 1.0a only | Data returned from the first request of the OAuth 1.0a flow
538+
`response` | Depends on transport used | The final [response data](#response-data)
502539

503540
---
504541

@@ -523,6 +560,7 @@ scope | `[provider]` | list of scopes to request
523560
custom_params | `[provider]` | custom authorization [parameters](#custom-parameters) and their values
524561
subdomain | `[provider]` | string to be [embedded](#subdomain-urls) in `request_url`, `authorize_url` and `access_url`
525562
nonce | `[provider]` | toggle random `nonce` string generation for [OpenID Connect](#openid-connect) providers
563+
pkce | `[provider]` | toggle `pkce` support
526564
callback | `[provider]` | final callback route on your server to receive the [response data](#response-data)
527565
dynamic | `[provider]` | allow [dynamic override](#dynamic-override) of configuration
528566
overrides | `[provider]` | [static overrides](#static-overrides) for a provider
@@ -535,17 +573,19 @@ redirect_uri | generated | OAuth app [redirect URI](#redirect-uri), generated us
535573

536574
## Configuration Scopes
537575

538-
Grant relies on configuration gathered from **5** different places:
576+
Grant relies on configuration gathered from **6** different places:
539577

540578
1. The **first** place Grant looks for configuration is the built-in [oauth.json][oauth-config] file located in the config folder.
541579

542580
2. The **second** place Grant looks for configuration is the `defaults` key, specified in the user's configuration. These defaults are applied for every provider in the user's configuration.
543581

544582
3. The **third** place for configuration is the provider itself. All providers in the user's configuration inherit every option defined for them in the [oauth.json][oauth-config] file, and all options defined inside the `defaults` key. Having [oauth.json][oauth-config] file and a `defaults` configuration is only a convenience. You can define all available options directly for a provider.
545583

546-
4. The **fourth** place for configuration is the provider's `overrides`. The [static overrides](#static-overrides) inherit their parent provider, essentially creating a sub provider of the same type.
584+
4. The **fourth** place for configuration are the provider's `overrides`. The [static overrides](#static-overrides) inherit their parent provider, essentially creating a sub provider of the same type.
585+
586+
5. The **fifth** place for configuration is the [dynamic state override](#dynamic-override). The request/response lifecycle state of your HTTP framework of choice can be used to dynamically override configuration.
547587

548-
5. The **fifth** place for configuration, that _[potentially](#oauth-proxy)_ can override all of the above, and make all of the above optional, is the [dynamic override](#dynamic-override).
588+
6. The **sixth** place for configuration, that _[potentially](#oauth-proxy)_ can override all of the above, and make all of the above optional, is the [dynamic HTTP override](#dynamic-override).
549589

550590

551591
## Custom Providers

0 commit comments

Comments
 (0)