diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index 984136a8d..935951c14 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -156,6 +156,8 @@ AuthorizeHandler.prototype.getAuthorizationCodeLifetime = function() { */ AuthorizeHandler.prototype.getClient = function(request) { + var that = this; + var clientId = request.body.client_id || request.query.client_id; if (!clientId) { @@ -189,9 +191,16 @@ AuthorizeHandler.prototype.getClient = function(request) { throw new InvalidClientError('Invalid client: missing client `redirectUri`'); } - if (redirectUri && !_.includes(client.redirectUris, redirectUri)) { - throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); + if (typeof that.model.validateRedirectUri === 'function') { + if (redirectUri && !that.model.validateRedirectUri(redirectUri, client.redirectUris)) { + throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); + } + } else { + if (redirectUri && !_.includes(client.redirectUris, redirectUri)) { + throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); + } } + return client; }); };