diff --git a/lib/passport_strategy.js b/lib/passport_strategy.js index 031f82ba..2be79c31 100644 --- a/lib/passport_strategy.js +++ b/lib/passport_strategy.js @@ -91,7 +91,7 @@ OpenIDConnectStrategy.prototype.authenticate = function authenticate(req, option const params = { state: random(), ...this._params, - options, + ...options, }; if (!params.nonce && params.response_type.includes('id_token')) { diff --git a/test/passport/passport_strategy.test.js b/test/passport/passport_strategy.test.js index af84edb6..c027fc91 100644 --- a/test/passport/passport_strategy.test.js +++ b/test/passport/passport_strategy.test.js @@ -126,6 +126,26 @@ describe('OpenIDConnectStrategy', () => { expect(target).to.include('scope=openid%20profile'); }); + it('can have authorization parameters specified at runtime', function () { + const strategy = new Strategy({ + client: this.client, + params: { + redirect_uri: 'https://example.com/cb', + scope: 'openid profile', + }, + }, () => {}); + + const req = new MockRequest('GET', '/login/oidc'); + req.session = {}; + + strategy.redirect = sinon.spy(); + strategy.authenticate(req, { resource: 'urn:example:foo' }); + + expect(strategy.redirect.calledOnce).to.be.true; + const target = strategy.redirect.firstCall.args[0]; + expect(target).to.include(`resource=${encodeURIComponent('urn:example:foo')}`); + }); + it('automatically includes nonce for where it applies', function () { const strategy = new Strategy({ client: this.client,