-
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Client-Initiated Backchannel Authentication
- Loading branch information
Showing
13 changed files
with
613 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Function: initiateBackchannelAuthentication() | ||
|
||
[💗 Help the project](https://github.com/sponsors/panva) | ||
|
||
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva). | ||
|
||
*** | ||
|
||
▸ **initiateBackchannelAuthentication**(`config`, `parameters`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`BackchannelAuthenticationResponse`](../interfaces/BackchannelAuthenticationResponse.md)\> | ||
|
||
Initiates a [Client-Initiated Backchannel Authentication Grant](https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0.html) using | ||
parameters from the `parameters` argument. | ||
|
||
Note: | ||
[URL of the authorization server's backchannel authentication endpoint](../interfaces/ServerMetadata.md#backchannel_authentication_endpoint) | ||
must be configured. | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| ------ | ------ | ------ | | ||
| `config` | [`Configuration`](../classes/Configuration.md) | - | | ||
| `parameters` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> \| [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | Authorization request parameters that will be sent to the backchannel authentication endpoint | | ||
|
||
## Returns | ||
|
||
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`BackchannelAuthenticationResponse`](../interfaces/BackchannelAuthenticationResponse.md)\> | ||
|
||
## Example | ||
|
||
```ts | ||
let config!: client.Configuration | ||
let scope!: string | ||
let login_hint!: string | ||
|
||
let backchannelAuthenticationResponse = | ||
await client.initiateBackchannelAuthentication(config, { | ||
scope, | ||
login_hint, | ||
}) | ||
|
||
let { auth_req_id } = backchannelAuthenticationResponse | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Function: pollBackchannelAuthenticationGrant() | ||
|
||
[💗 Help the project](https://github.com/sponsors/panva) | ||
|
||
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva). | ||
|
||
*** | ||
|
||
▸ **pollBackchannelAuthenticationGrant**(`config`, `backchannelAuthenticationResponse`, `parameters`?, `options`?): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`TokenEndpointResponse`](../interfaces/TokenEndpointResponse.md) & [`TokenEndpointResponseHelpers`](../interfaces/TokenEndpointResponseHelpers.md)\> | ||
|
||
Continuously polls the [token endpoint](../interfaces/ServerMetadata.md#token_endpoint) | ||
until the end-user finishes the | ||
[Client-Initiated Backchannel Authentication Grant](https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0.html) process | ||
|
||
Note: | ||
[URL of the authorization server's token endpoint](../interfaces/ServerMetadata.md#token_endpoint) | ||
must be configured. | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| ------ | ------ | ------ | | ||
| `config` | [`Configuration`](../classes/Configuration.md) | - | | ||
| `backchannelAuthenticationResponse` | [`BackchannelAuthenticationResponse`](../interfaces/BackchannelAuthenticationResponse.md) | Backchannel Authentication Response obtained from [initiateBackchannelAuthentication](initiateBackchannelAuthentication.md) | | ||
| `parameters`? | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> \| [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | Additional parameters that will be sent to the token endpoint, typically used for parameters such as `scope` and a `resource` ([Resource Indicator](https://www.rfc-editor.org/rfc/rfc8707)) | | ||
| `options`? | [`BackchannelAuthenticationGrantPollOptions`](../interfaces/BackchannelAuthenticationGrantPollOptions.md) | - | | ||
|
||
## Returns | ||
|
||
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`TokenEndpointResponse`](../interfaces/TokenEndpointResponse.md) & [`TokenEndpointResponseHelpers`](../interfaces/TokenEndpointResponseHelpers.md)\> | ||
|
||
## Example | ||
|
||
```ts | ||
let config!: client.Configuration | ||
let scope!: string | ||
let login_hint!: string | ||
|
||
let backchannelAuthenticationResponse = | ||
await client.initiateBackchannelAuthentication(config, { | ||
scope, | ||
login_hint, | ||
}) | ||
|
||
let { auth_req_id } = backchannelAuthenticationResponse | ||
|
||
let tokenEndpointResponse = | ||
await client.pollBackchannelAuthenticationGrant( | ||
config, | ||
backchannelAuthenticationResponse, | ||
) | ||
``` |
30 changes: 30 additions & 0 deletions
30
docs/interfaces/BackchannelAuthenticationGrantPollOptions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Interface: BackchannelAuthenticationGrantPollOptions | ||
|
||
[💗 Help the project](https://github.com/sponsors/panva) | ||
|
||
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva). | ||
|
||
*** | ||
|
||
## Properties | ||
|
||
### DPoP? | ||
|
||
• `optional` **DPoP**: [`DPoPHandle`](DPoPHandle.md) | ||
|
||
DPoP handle to use for requesting a sender-constrained access token. | ||
Obtained from [getDPoPHandle](../functions/getDPoPHandle.md) | ||
|
||
#### See | ||
|
||
[RFC 9449 - OAuth 2.0 Demonstrating Proof of Possession (DPoP)](https://www.rfc-editor.org/rfc/rfc9449.html) | ||
|
||
*** | ||
|
||
### signal? | ||
|
||
• `optional` **signal**: [`AbortSignal`](https://developer.mozilla.org/docs/Web/API/AbortSignal) | ||
|
||
AbortSignal to abort polling. Default is that the operation will time out | ||
after the indicated expires_in property returned by the server in | ||
[initiateBackchannelAuthentication](../functions/initiateBackchannelAuthentication.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Interface: BackchannelAuthenticationResponse | ||
|
||
[💗 Help the project](https://github.com/sponsors/panva) | ||
|
||
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva). | ||
|
||
*** | ||
|
||
## Indexable | ||
|
||
\[`parameter`: `string`\]: `undefined` \| [`JsonValue`](../type-aliases/JsonValue.md) | ||
|
||
## Properties | ||
|
||
### auth\_req\_id | ||
|
||
• `readonly` **auth\_req\_id**: `string` | ||
|
||
Unique identifier to identify the authentication request. | ||
|
||
*** | ||
|
||
### expires\_in | ||
|
||
• `readonly` **expires\_in**: `number` | ||
|
||
The lifetime in seconds of the "auth_req_id". | ||
|
||
*** | ||
|
||
### interval? | ||
|
||
• `readonly` `optional` **interval**: `number` | ||
|
||
The minimum amount of time in seconds that the client should wait between polling requests to | ||
the token endpoint. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.