Skip to content

Commit

Permalink
feat: helper function to decide whether to validate client.sector_ide…
Browse files Browse the repository at this point in the history
…ntifier_uri

See `sectorIdentifierUriValidate`
  • Loading branch information
panva committed Feb 28, 2021
1 parent 202e4c5 commit 72058a5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
18 changes: 16 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ location / {
- [revokeGrantPolicy](#revokegrantpolicy)
- [rotateRefreshToken](#rotaterefreshtoken)
- [routes](#routes)
- [sectorIdentifierUriValidate](#sectoridentifierurivalidate)
- [scopes](#scopes)
- [subjectTypes](#subjecttypes)
- [tokenEndpointAuthMethods](#tokenendpointauthmethods)
Expand Down Expand Up @@ -2384,7 +2385,7 @@ new Prompt(
return Check.REQUEST_PROMPT;
}

if (oidc.client.sectorIdentifier) {
if (oidc.client.subjectType === 'pairwise') {
sub = await instance(oidc.provider).configuration('pairwiseIdentifier')(ctx, sub, oidc.client);
}

Expand All @@ -2407,7 +2408,7 @@ new Prompt(
return Check.REQUEST_PROMPT;
}

if (oidc.client.sectorIdentifier) {
if (oidc.client.subjectType === 'pairwise') {
sub = await instance(oidc.provider).configuration('pairwiseIdentifier')(ctx, sub, oidc.client);
}

Expand Down Expand Up @@ -2862,6 +2863,19 @@ _**default value**_:
]
```

### sectorIdentifierUriValidate

Function called to make a decision about whether sectorIdentifierUri of a client being loaded, registered, or updated should be fetched and its contents validated against the client metadata.


_**default value**_:
```js
function sectorIdentifierUriValidate(client) {
// @param client - the Client instance
return true;
}
```

### subjectTypes

Array of the Subject Identifier types that this OP supports. When only `pairwise` is supported it becomes the default `subject_type` client metadata value. Valid types are
Expand Down
14 changes: 14 additions & 0 deletions lib/helpers/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@ function revokeGrantPolicy(ctx) {
return true;
}

function sectorIdentifierUriValidate(client) {
// @param client - the Client instance
return true;
}

function getDefaults() {
const defaults = {

Expand Down Expand Up @@ -2144,6 +2149,15 @@ function getDefaults() {
*/
revokeGrantPolicy,

/*
* sectorIdentifierUriValidate
*
* description: Function called to make a decision about whether sectorIdentifierUri of
* a client being loaded, registered, or updated should be fetched and its contents
* validated against the client metadata.
*/
sectorIdentifierUriValidate,

/*
* interactions
*
Expand Down
5 changes: 3 additions & 2 deletions lib/models/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ module.exports = function getClient(provider) {
}

async function sectorValidate(client) {
if (!instance(provider).configuration('sectorIdentifierUriValidate')(client)) {
return;
}
const { statusCode, body } = await request.call(provider, {
method: 'GET',
url: client.sectorIdentifierUri,
Expand All @@ -247,8 +250,6 @@ module.exports = function getClient(provider) {
} catch (err) {
throw new InvalidClientMetadata(err.message);
}

return client;
}

function buildKeyStore(client) {
Expand Down

0 comments on commit 72058a5

Please sign in to comment.