File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,6 +233,11 @@ declare namespace OAuth2Server {
233233 * Additional supported grant types.
234234 */
235235 extendedGrantTypes ?: Record < string , typeof AbstractGrantType > ;
236+
237+ /**
238+ * Helper function to extract scope string from the request.
239+ */
240+ readScope ?: ( request : Request ) => string [ ] | null ;
236241 }
237242
238243 interface AssertionCredential {
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ class AbstractGrantType {
2525 this . model = options . model ;
2626 this . refreshTokenLifetime = options . refreshTokenLifetime ;
2727 this . alwaysIssueNewRefreshToken = options . alwaysIssueNewRefreshToken ;
28+ this . readScope = options . readScope ?? ( ( request ) => parseScope ( request . body . scope ) ) ;
2829 }
2930
3031 /**
@@ -73,7 +74,7 @@ class AbstractGrantType {
7374 * Get scope from the request body.
7475 */
7576 getScope ( request ) {
76- return parseScope ( request . body . scope ) ;
77+ return this . readScope ( request ) ;
7778 }
7879
7980 /**
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ class TokenHandler {
6161 this . allowExtendedTokenAttributes = options . allowExtendedTokenAttributes ;
6262 this . requireClientAuthentication = options . requireClientAuthentication || { } ;
6363 this . alwaysIssueNewRefreshToken = options . alwaysIssueNewRefreshToken !== false ;
64+ this . readScope = options . readScope ;
6465 }
6566
6667 /**
@@ -247,7 +248,8 @@ class TokenHandler {
247248 accessTokenLifetime : accessTokenLifetime ,
248249 model : this . model ,
249250 refreshTokenLifetime : refreshTokenLifetime ,
250- alwaysIssueNewRefreshToken : this . alwaysIssueNewRefreshToken
251+ alwaysIssueNewRefreshToken : this . alwaysIssueNewRefreshToken ,
252+ readScope : this . readScope ,
251253 } ;
252254
253255 return new Type ( options ) . handle ( request , client ) ;
You can’t perform that action at this time.
0 commit comments