@@ -114,8 +114,10 @@ AuthorizeHandler.prototype.handle = function(request, response) {
114114 } )
115115 . then ( function ( authorizationCode ) {
116116 ResponseType = this . getResponseType ( request ) ;
117+ const codeChallenge = this . getCodeChallenge ( request ) ;
118+ const codeChallengeMethod = this . getCodeChallengeMethod ( request ) ;
117119
118- return this . saveAuthorizationCode ( authorizationCode , expiresAt , scope , client , uri , user ) ;
120+ return this . saveAuthorizationCode ( authorizationCode , expiresAt , scope , client , uri , user , codeChallenge , codeChallengeMethod ) ;
119121 } )
120122 . then ( function ( code ) {
121123 const responseType = new ResponseType ( code . authorizationCode ) ;
@@ -293,12 +295,14 @@ AuthorizeHandler.prototype.getRedirectUri = function(request, client) {
293295 * Save authorization code.
294296 */
295297
296- AuthorizeHandler . prototype . saveAuthorizationCode = function ( authorizationCode , expiresAt , scope , client , redirectUri , user ) {
298+ AuthorizeHandler . prototype . saveAuthorizationCode = function ( authorizationCode , expiresAt , scope , client , redirectUri , user , codeChallenge , codeChallengeMethod ) {
297299 const code = {
298300 authorizationCode : authorizationCode ,
299301 expiresAt : expiresAt ,
300302 redirectUri : redirectUri ,
301- scope : scope
303+ scope : scope ,
304+ codeChallenge : codeChallenge ,
305+ codeChallengeMethod : codeChallengeMethod
302306 } ;
303307 return promisify ( this . model . saveAuthorizationCode , 3 ) . call ( this . model , code , client , user ) ;
304308} ;
@@ -369,6 +373,14 @@ AuthorizeHandler.prototype.updateResponse = function(response, redirectUri, stat
369373 response . redirect ( url . format ( redirectUri ) ) ;
370374} ;
371375
376+ AuthorizeHandler . prototype . getCodeChallenge = function ( request ) {
377+ return request . body . code_challenge || request . query . code_challenge ;
378+ } ;
379+
380+ AuthorizeHandler . prototype . getCodeChallengeMethod = function ( request ) {
381+ return request . body . code_challenge_method || request . query . code_challenge_method ;
382+ } ;
383+
372384/**
373385 * Export constructor.
374386 */
0 commit comments