Skip to content

Commit e2de529

Browse files
committed
fix: ignore allowOmittingSingleRegisteredRedirectUri when FAPI 2.0 is used
1 parent 617c3c1 commit e2de529

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

lib/actions/authorization/one_redirect_uri_clients.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import instance from '../../helpers/weak_cache.js';
55
* to be the requested redirect_uri and used as if it was explicitly provided;
66
*/
77
export default function oneRedirectUriClients(ctx, next) {
8-
if (!instance(ctx.oidc.provider).configuration.allowOmittingSingleRegisteredRedirectUri) {
8+
if (!instance(ctx.oidc.provider).configuration.allowOmittingSingleRegisteredRedirectUri || ctx.oidc.isFapi('2.0')) {
99
return next();
1010
}
1111

test/fapi/fapi2.test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,51 @@ describe('FAPI 2.0 Final behaviours', () => {
100100
});
101101
});
102102

103+
context('allowOmittingSingleRegisteredRedirectUri', () => {
104+
before(function () {
105+
this.orig = i(this.provider).configuration.allowOmittingSingleRegisteredRedirectUri;
106+
i(this.provider).configuration.allowOmittingSingleRegisteredRedirectUri = true;
107+
});
108+
after(function () {
109+
i(this.provider).configuration.allowOmittingSingleRegisteredRedirectUri = this.orig;
110+
});
111+
before(function () { return this.login(); });
112+
after(function () { return this.logout(); });
113+
114+
it('is ignored when FAPI 2.0 is used', async function () {
115+
const emitSpy = sinon.spy();
116+
const renderSpy = sinon.spy(i(this.provider).configuration, 'renderError');
117+
this.provider.once('authorization.error', emitSpy);
118+
119+
const auth = new this.AuthorizationRequest({
120+
scope: 'openid',
121+
client_id: 'client',
122+
response_type: 'code',
123+
code_challenge_method: undefined,
124+
code_challenge: undefined,
125+
redirect_uri: undefined,
126+
});
127+
128+
return this.wrap({
129+
agent: this.agent,
130+
route: '/auth',
131+
verb: 'get',
132+
auth,
133+
})
134+
.expect(() => {
135+
renderSpy.restore();
136+
})
137+
.expect(400)
138+
.expect(() => {
139+
expect(emitSpy.calledOnce).to.be.true;
140+
expect(renderSpy.calledOnce).to.be.true;
141+
const renderArgs = renderSpy.args[0];
142+
expect(renderArgs[1]).to.have.property('error', 'invalid_request');
143+
expect(renderArgs[1]).to.have.property('error_description', "missing required parameter 'redirect_uri'");
144+
});
145+
});
146+
});
147+
103148
describe('Request Object', () => {
104149
beforeEach(function () { return this.login(); });
105150
afterEach(function () { return this.logout(); });

0 commit comments

Comments
 (0)