@@ -336,25 +336,29 @@ This model function is **required** if the ``authorization_code`` grant is used.
336336
337337An ``Object `` representing the authorization code and associated data.
338338
339- +--------------------+--------+--------------------------------------------------------------+
340- | Name | Type | Description |
341- +====================+========+==============================================================+
342- | code | Object | The return value. |
343- +--------------------+--------+--------------------------------------------------------------+
344- | code.code | String | The authorization code passed to ``getAuthorizationCode() ``. |
345- +--------------------+--------+--------------------------------------------------------------+
346- | code.expiresAt | Date | The expiry time of the authorization code. |
347- +--------------------+--------+--------------------------------------------------------------+
348- | [code.redirectUri] | String | The redirect URI of the authorization code. |
349- +--------------------+--------+--------------------------------------------------------------+
350- | [code.scope] | String | The authorized scope of the authorization code. |
351- +--------------------+--------+--------------------------------------------------------------+
352- | code.client | Object | The client associated with the authorization code. |
353- +--------------------+--------+--------------------------------------------------------------+
354- | code.client.id | String | A unique string identifying the client. |
355- +--------------------+--------+--------------------------------------------------------------+
356- | code.user | Object | The user associated with the authorization code. |
357- +--------------------+--------+--------------------------------------------------------------+
339+ +----------------------------+--------+---------------------------------------------------------------+
340+ | Name | Type | Description |
341+ +============================+========+===============================================================+
342+ | code | Object | The return value. |
343+ +----------------------------+--------+---------------------------------------------------------------+
344+ | code.code | String | The authorization code passed to ``getAuthorizationCode() ``. |
345+ +----------------------------+--------+---------------------------------------------------------------+
346+ | code.expiresAt | Date | The expiry time of the authorization code. |
347+ +----------------------------+--------+---------------------------------------------------------------+
348+ | [code.redirectUri] | String | The redirect URI of the authorization code. |
349+ +----------------------------+--------+---------------------------------------------------------------+
350+ | [code.scope] | String | The authorized scope of the authorization code. |
351+ +----------------------------+--------+---------------------------------------------------------------+
352+ | code.client | Object | The client associated with the authorization code. |
353+ +----------------------------+--------+---------------------------------------------------------------+
354+ | code.client.id | String | A unique string identifying the client. |
355+ +----------------------------+--------+---------------------------------------------------------------+
356+ | code.user | Object | The user associated with the authorization code. |
357+ +----------------------------+--------+---------------------------------------------------------------+
358+ | [code.codeChallenge] | String | The code challenge string used with PKCE (RFC7636). |
359+ +----------------------------+--------+---------------------------------------------------------------+
360+ | [code.codeChallengeMethod] | String | The string for the code challenge method (`S256 ` or `plain `). |
361+ +----------------------------+--------+---------------------------------------------------------------+
358362
359363``code.client `` and ``code.user `` can carry additional properties that will be ignored by *oauth2-server *.
360364
@@ -379,7 +383,9 @@ An ``Object`` representing the authorization code and associated data.
379383 redirectUri: code.redirect_uri,
380384 scope: code.scope,
381385 client: client, // with 'id' property
382- user: user
386+ user: user,
387+ codeChallenge: code.code_challenge,
388+ codeChallengeMethod: code.code_challenge_method
383389 };
384390 });
385391 }
@@ -665,51 +671,59 @@ This model function is **required** if the ``authorization_code`` grant is used.
665671
666672**Arguments: **
667673
668- +------------------------+----------+---------------------------------------------------------------------+
669- | Name | Type | Description |
670- +========================+==========+=====================================================================+
671- | code | Object | The code to be saved. |
672- +------------------------+----------+---------------------------------------------------------------------+
673- | code.authorizationCode | String | The authorization code to be saved. |
674- +------------------------+----------+---------------------------------------------------------------------+
675- | code.expiresAt | Date | The expiry time of the authorization code. |
676- +------------------------+----------+---------------------------------------------------------------------+
677- | code.redirectUri | String | The redirect URI associated with the authorization code. |
678- +------------------------+----------+---------------------------------------------------------------------+
679- | [code.scope] | String | The authorized scope of the authorization code. |
680- +------------------------+----------+---------------------------------------------------------------------+
681- | client | Object | The client associated with the authorization code. |
682- +------------------------+----------+---------------------------------------------------------------------+
683- | user | Object | The user associated with the authorization code. |
684- +------------------------+----------+---------------------------------------------------------------------+
685- | [callback] | Function | Node-style callback to be used instead of the returned ``Promise ``. |
686- +------------------------+----------+---------------------------------------------------------------------+
674+ +----------------------------+----------+---------------------------------------------------------------------+
675+ | Name | Type | Description |
676+ +============================+==========+=====================================================================+
677+ | code | Object | The code to be saved. |
678+ +----------------------------+----------+---------------------------------------------------------------------+
679+ | code.authorizationCode | String | The authorization code to be saved. |
680+ +----------------------------+----------+---------------------------------------------------------------------+
681+ | code.expiresAt | Date | The expiry time of the authorization code. |
682+ +----------------------------+----------+---------------------------------------------------------------------+
683+ | code.redirectUri | String | The redirect URI associated with the authorization code. |
684+ +----------------------------+----------+---------------------------------------------------------------------+
685+ | [code.scope] | String | The authorized scope of the authorization code. |
686+ +----------------------------+----------+---------------------------------------------------------------------+
687+ | [code.codeChallenge] | String | The code challenge string used with PKCE (RFC7636). |
688+ +----------------------------+----------+---------------------------------------------------------------------+
689+ | [code.codeChallengeMethod] | String | The string for the code challenge method (`S256 ` or `plain `). |
690+ +----------------------------+----------+---------------------------------------------------------------------+
691+ | client | Object | The client associated with the authorization code. |
692+ +----------------------------+----------+---------------------------------------------------------------------+
693+ | user | Object | The user associated with the authorization code. |
694+ +----------------------------+----------+---------------------------------------------------------------------+
695+ | [callback] | Function | Node-style callback to be used instead of the returned ``Promise ``. |
696+ +----------------------------+----------+---------------------------------------------------------------------+
687697
688698.. todo :: Is ``code.scope`` really optional?
689699
690700**Return value: **
691701
692702An ``Object `` representing the authorization code and associated data.
693703
694- +------------------------+--------+---------------------------------------------------------------+
695- | Name | Type | Description |
696- +========================+========+===============================================================+
697- | code | Object | The return value. |
698- +------------------------+--------+---------------------------------------------------------------+
699- | code.authorizationCode | String | The authorization code passed to ``saveAuthorizationCode() ``. |
700- +------------------------+--------+---------------------------------------------------------------+
701- | code.expiresAt | Date | The expiry time of the authorization code. |
702- +------------------------+--------+---------------------------------------------------------------+
703- | code.redirectUri | String | The redirect URI associated with the authorization code. |
704- +------------------------+--------+---------------------------------------------------------------+
705- | [code.scope] | String | The authorized scope of the authorization code. |
706- +------------------------+--------+---------------------------------------------------------------+
707- | code.client | Object | The client associated with the authorization code. |
708- +------------------------+--------+---------------------------------------------------------------+
709- | code.client.id | String | A unique string identifying the client. |
710- +------------------------+--------+---------------------------------------------------------------+
711- | code.user | Object | The user associated with the authorization code. |
712- +------------------------+--------+---------------------------------------------------------------+
704+ +----------------------------+--------+----------------------------------------------------------------+
705+ | Name | Type | Description |
706+ +============================+========+================================================================+
707+ | code | Object | The return value. |
708+ +----------------------------+--------+----------------------------------------------------------------+
709+ | code.authorizationCode | String | The authorization code passed to ``saveAuthorizationCode() ``. |
710+ +----------------------------+--------+----------------------------------------------------------------+
711+ | code.expiresAt | Date | The expiry time of the authorization code. |
712+ +----------------------------+--------+----------------------------------------------------------------+
713+ | code.redirectUri | String | The redirect URI associated with the authorization code. |
714+ +----------------------------+--------+----------------------------------------------------------------+
715+ | [code.scope] | String | The authorized scope of the authorization code. |
716+ +----------------------------+--------+----------------------------------------------------------------+
717+ | code.client | Object | The client associated with the authorization code. |
718+ +----------------------------+--------+----------------------------------------------------------------+
719+ | code.client.id | String | A unique string identifying the client. |
720+ +----------------------------+--------+----------------------------------------------------------------+
721+ | code.user | Object | The user associated with the authorization code. |
722+ +----------------------------+--------+----------------------------------------------------------------+
723+ | [code.codeChallenge] | String | The code challenge string used with PKCE (RFC7636). |
724+ +----------------------------+--------+----------------------------------------------------------------+
725+ | [code.codeChallengeMethod] | String | The string for the code challenge method (`S256 ` or `plain ` |
726+ +----------------------------+--------+----------------------------------------------------------------+
713727
714728``code.client `` and ``code.user `` can carry additional properties that will be ignored by *oauth2-server *.
715729
@@ -725,7 +739,9 @@ An ``Object`` representing the authorization code and associated data.
725739 redirect_uri: code.redirectUri,
726740 scope: code.scope,
727741 client_id: client.id,
728- user_id: user.id
742+ user_id: user.id,
743+ code_challenge: code.codeChallenge,
744+ code_challenge_method: code.codeChallengeMethod
729745 };
730746 return db.saveAuthorizationCode(authCode)
731747 .then(function(authorizationCode) {
@@ -735,7 +751,9 @@ An ``Object`` representing the authorization code and associated data.
735751 redirectUri: authorizationCode.redirect_uri,
736752 scope: authorizationCode.scope,
737753 client: {id: authorizationCode.client_id},
738- user: {id: authorizationCode.user_id}
754+ user: {id: authorizationCode.user_id},
755+ codeChallenge: authorizationCode.code_challenge,
756+ codeChallengeMethod: authorizationCode.code_challenge_method
739757 };
740758 });
741759 }
0 commit comments