forked from panva/node-oidc-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Device Flow experimental/draft feature
Based on [OAuth 2.0 Device Flow for Browserless and Input Constrained Devices - draft 10](https://tools.ietf.org/html/draft-ietf-oauth-device-flow-10) with added OIDC flavor - device_authorization_endpoint accepts additional OIDC defined params (i.e. claims, request, request_uri, etc...) and processes them in the same way a regular OIDC authorization endpoint would - device_authorization_endpoint ignores response_type, response_mode, state, redirect_uri params > This OAuth 2.0 authorization flow for browserless and input > constrained devices, often referred to as the device flow, enables > OAuth clients to request user authorization from devices that have an > Internet connection, but don't have an easy input method (such as a > smart TV, media console, picture frame, or printer), or lack a > suitable browser for a more traditional OAuth flow. This > authorization flow instructs the user to perform the authorization > request on a secondary device, such as a smartphone. There is no > requirement for communication between the constrained device and the > user's secondary device.
- Loading branch information
Showing
81 changed files
with
3,436 additions
and
471 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
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,36 @@ | ||
const { merge } = require('lodash'); | ||
|
||
const instance = require('../../helpers/weak_cache'); | ||
|
||
/* | ||
* If claims parameter is provided and supported handles it's validation | ||
* - should not be combined with rt none | ||
* - should be JSON serialized object with id_token or userinfo properties as objects | ||
* - claims.userinfo should not be used if authorization result is not access_token | ||
* | ||
* Merges requested claims with auth_time as requested if max_age is provided or require_auth_time | ||
* is configured for the client. | ||
* | ||
* Merges requested claims with acr as requested if acr_values is provided | ||
* | ||
* @throws: invalid_request | ||
*/ | ||
module.exports = provider => async function assignClaims(ctx, next) { | ||
const { params } = ctx.oidc; | ||
|
||
if (params.claims !== undefined && instance(provider).configuration('features.claimsParameter')) { | ||
ctx.oidc.claims = JSON.parse(params.claims); | ||
} | ||
|
||
if (params.max_age || ctx.oidc.client.requireAuthTime || ctx.oidc.prompts.includes('login')) { | ||
merge(ctx.oidc.claims, { id_token: { auth_time: { essential: true } } }); | ||
} | ||
|
||
const acrValues = params.acr_values; | ||
|
||
if (acrValues) { | ||
merge(ctx.oidc.claims, { id_token: { acr: { values: acrValues.split(' ') } } }); | ||
} | ||
|
||
await next(); | ||
}; |
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.