Skip to content

Commit

Permalink
fix: aud for jwt oauth tokens no longer gets the client id pushed in
Browse files Browse the repository at this point in the history
ID Tokens continue ensuring conform ID Token behaviour by forcing the
azp claim if the audience is an array and ensuring the azp value is
in the aud array. For now.
  • Loading branch information
panva committed Nov 25, 2018
1 parent 4df8160 commit 14c556e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lib/helpers/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,9 @@ const DEFAULTS = {
* throw new InvalidResource('unauthorized "resource" requested');
* }
*
* return transform(resourceParam, grantedResource); // => array of validated and transformed string audiences
* // => array of validated and transformed string audiences or undefined if no audiences
* // are to be listed
* return transform(resourceParam, grantedResource);
* }
* },
* formats: {
Expand Down
5 changes: 3 additions & 2 deletions lib/helpers/ensure_conform.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ const assert = require('assert');
module.exports = function ensureConform(audiences, clientId) {
assert(Array.isArray(audiences), 'audiences must be an array');

const value = Array.from(audiences);
const value = audiences.slice();
value.forEach((audience) => {
assert(audience && typeof audience === 'string', 'audiences must be non-empty string values');
});
if (!value.includes(clientId)) {

if (clientId && !value.includes(clientId)) {
value.unshift(clientId);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/models/mixins/set_audiences.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ const ensureConform = require('../../helpers/ensure_conform');

module.exports = superclass => class extends superclass {
setAudiences(audiences) {
const { clientId } = this;
if (audiences) {
const value = ensureConform(audiences, clientId);
const value = ensureConform(audiences);

if (value.length > 1) {
if (value.length) {
this.aud = value;
}
}
Expand Down

0 comments on commit 14c556e

Please sign in to comment.