Skip to content

Commit 7a6fd64

Browse files
authored
Merge pull request #12 from wpdebruin/development
scopes -> scope
2 parents e01727e + f861fe2 commit 7a6fd64

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

models/jwt/JwtService.cfc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ component accessors="true" singleton {
3939
"iat",
4040
"sub",
4141
"exp",
42-
"scopes"
42+
"scope"
4343
];
4444

4545
// Default JWT Settings
@@ -189,7 +189,7 @@ component accessors="true" singleton {
189189
// The unique identifier of the token
190190
"jti" : hash( timestamp & arguments.user.getId() ),
191191
// Get the user scopes for the JWT token
192-
"scopes" : arguments.user.getJwtScopes()
192+
"scope" : arguments.user.getJwtScopes().toList(" ")
193193
};
194194

195195
// Append user custom claims with override, they take prescedence
@@ -712,7 +712,7 @@ component accessors="true" singleton {
712712
if ( listLen( arguments.permissions ) ) {
713713
// Check if the user has the right permissions?
714714
results.allow = (
715-
tokenHasScopes( arguments.permissions, payload.scopes )
715+
tokenHasScopes( arguments.permissions, payload.scope )
716716
||
717717
variables.cbSecurity
718718
.getAuthService()
@@ -731,6 +731,8 @@ component accessors="true" singleton {
731731

732732
/**
733733
* Verify if the jwt token has the appropriate scopes
734+
* @permission
735+
* @scopes a space delimited string of scopes
734736
*/
735737
private function tokenHasScopes( required permission, required scopes ){
736738
if ( isSimpleValue( arguments.permission ) ) {
@@ -739,7 +741,7 @@ component accessors="true" singleton {
739741

740742
return arguments.permission
741743
.filter( function( item ){
742-
return ( scopes.findNoCase( item ) );
744+
return ( scopes.listfindNoCase( item, " " ) );
743745
} )
744746
.len();
745747
}

test-harness/tests/specs/integration/JWTSpec.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="/root" {
156156
// The unique identifier of the token
157157
"jti" : hash( timestamp & userId ),
158158
// Get the user scopes for the JWT token
159-
"scopes" : [],
159+
"scope" : [],
160160
"role" : "admin"
161161
};
162162

0 commit comments

Comments
 (0)