Skip to content

Commit 0e1328d

Browse files
committed
Fix authorize handler
1 parent 32ed5b6 commit 0e1328d

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

lib/handlers/authorize-handler.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,22 @@ AuthorizeHandler.prototype.getClient = function(request) {
620620
throw new InvalidClientError('Invalid client: missing client `grants`');
621621
}
622622

623-
if (request.query.response_type === 'code' && !_.includes(client.grants, 'authorization_code')) {
623+
let responseTypeTemp = request.query.response_type.split(' ');
624+
625+
626+
if (responseTypeTemp.includes('code') && !_.includes(client.grants, 'authorization_code')) {
627+
throw new UnauthorizedClientError('Unsupported grant type: `grant_type` is invalid');
628+
}
629+
630+
if (responseTypeTemp.includes('token') && !_.includes(client.grants, 'implicit')) {
631+
throw new UnauthorizedClientError('Unsupported grant type: `grant_type` is invalid');
632+
}
633+
634+
if (responseTypeTemp.includes('id_token') && !_.includes(client.response_types, 'id_token')) {
624635
throw new UnauthorizedClientError('Unsupported grant type: `grant_type` is invalid');
625636
}
626637

627-
if (request.query.response_type === 'token' && !_.includes(client.grants, 'implicit')) {
638+
if ((responseTypeTemp.includes('code') && responseTypeTemp.length > 1) && !_.includes(client.grants, 'hybrid')) {
628639
throw new UnauthorizedClientError('Unsupported grant type: `grant_type` is invalid');
629640
}
630641

0 commit comments

Comments
 (0)