Skip to content

Commit

Permalink
fix: client schema invalidation code not set
Browse files Browse the repository at this point in the history
Co-authored-by: Or Gaizer <or.gaizer@transmitsecurity.com>
Co-authored-by: Filip Skokan <panva.ip@gmail.com>
  • Loading branch information
3 people authored Apr 25, 2022
1 parent 30c7406 commit edf22fb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/helpers/client_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,11 @@ module.exports = function getSchema(provider) {

if (this.grant_types.includes('implicit')) {
if (protocol === 'http:') {
this.invalidate(`${label} for web clients using implicit flow MUST only register URLs using the https scheme', 'implicit-force-https`);
this.invalidate(`${label} for web clients using implicit flow MUST only register URLs using the https scheme`, 'implicit-force-https');
}

if (hostname === 'localhost') {
this.invalidate(`${label} for web clients using implicit flow must not be using localhost', 'implicit-forbid-localhost`);
this.invalidate(`${label} for web clients using implicit flow must not be using localhost`, 'implicit-forbid-localhost');
}
}
break;
Expand Down
37 changes: 37 additions & 0 deletions test/configuration/client_metadata.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { strict: assert } = require('assert');
const util = require('util');

const sinon = require('sinon');
const { expect } = require('chai');
const camelCase = require('lodash/camelCase');
const merge = require('lodash/merge');
Expand Down Expand Up @@ -370,6 +371,42 @@ describe('Client metadata validation', () => {
grant_types: ['implicit'],
response_types: ['id_token'],
});
it('has an schema invalidation hook for forcing https on implicit', async () => {
const sandbox = sinon.createSandbox();
sandbox.spy(DefaultProvider.Client.Schema.prototype, 'invalidate');
await addClient({
grant_types: ['implicit'],
response_types: ['id_token'],
redirect_uris: ['http://foo/bar'],
}).then(() => {
assert(false);
}, () => {
const spy = DefaultProvider.Client.Schema.prototype.invalidate;
expect(spy).to.have.property('calledOnce', true);
const call = spy.getCall(0);
const [, code] = call.args;
expect(code).to.eql('implicit-force-https');
}).finally(() => {
sandbox.restore();
});
});
it('has an schema invalidation hook for preventing localhost', async () => {
const sandbox = sinon.createSandbox();
sandbox.spy(DefaultProvider.Client.Schema.prototype, 'invalidate');
await addClient({
grant_types: ['implicit'],
response_types: ['id_token'],
redirect_uris: ['https://localhost'],
}).then(() => {
assert(false);
}, () => {
const spy = DefaultProvider.Client.Schema.prototype.invalidate;
expect(spy).to.have.property('calledOnce', true);
const call = spy.getCall(0);
const [, code] = call.args;
expect(code).to.eql('implicit-forbid-localhost');
});
});
});

context('post_logout_redirect_uris', function () {
Expand Down

0 comments on commit edf22fb

Please sign in to comment.