Skip to content
This repository has been archived by the owner on Feb 25, 2019. It is now read-only.

Commit

Permalink
Merge pull request #213 from anvilresearch/vsimonian-lx-valid
Browse files Browse the repository at this point in the history
Use lx-valid validation hooks for jwks and jwks_uri
  • Loading branch information
christiansmith committed Sep 2, 2015
2 parents 8b61322 + 6a91ee9 commit d993492
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 39 deletions.
51 changes: 14 additions & 37 deletions models/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,13 @@ var Client = Modinha.define('clients', {

jwks_uri: {
type: 'string',
format: 'url'
format: 'url',
conform: function (value, instance) {
return !(value && instance.jwks)
},
messages: {
conform: 'Cannot use jwks_uri at the same time as jwks'
}
},

/**
Expand All @@ -247,7 +253,13 @@ var Client = Modinha.define('clients', {
*/

jwks: {
type: 'string'
type: 'string',
conform: function (value, instance) {
return !(value && instance.jwks_uri)
},
messages: {
conform: 'Cannot use jwks at the same time as jwks_uri'
}
},

/**
Expand Down Expand Up @@ -634,41 +646,6 @@ Client.__client = client

Client.intersects('roles')

/**
* Custom validation
*/

var originalValidate = Client.validate
Client.validate = function (data) {
var validation = originalValidate.apply(this, arguments)

// http://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata
// "The jwks_uri and jwks parameters MUST NOT be used together."
if (data.jwks && data.jwks_uri) {
validation = validation || new Modinha.ValidationError({ errors: {} })

validation.errors.jwks = {
property: 'jwks',
expected: false,
actual: data.jwks,
message: 'Cannot use jwks at the same time as jwks_uri'
}

validation.errors.jwks_uri = {
property: 'jwks_uri',
expected: false,
actual: data.jwks_uri,
message: 'Cannot use jwks_uri at the same time as jwks'
}
}

return validation
}

Client.prototype.validate = function () {
return Client.validate(this)
}

/**
* Authorized scope
*/
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
"lodash": "^3.8.0",
"mellt": "~1.0.0",
"mkdirp": "^0.5.1",
"modinha": "0.0.31",
"modinha-redis": "0.0.22",
"modinha": "0.0.32",
"modinha-redis": "0.0.23",
"nodemailer": "^1.4.0",
"passport-adauth": "^0.1.2",
"passport-ldapauth": "^0.3.0",
Expand Down

0 comments on commit d993492

Please sign in to comment.