-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(authorization): deduplicate constant strings
- Loading branch information
Showing
6 changed files
with
22 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ object ModelixAuthorization : BaseRouteScopedPlugin<IModelixAuthorizationConfig, | |
val token = JWT.create() | ||
.withIssuer("modelix") | ||
.withAudience("modelix") | ||
.withClaim("email", "[email protected]") | ||
.withClaim(KeycloakTokenConstants.EMAIL, "[email protected]") | ||
.sign(Algorithm.HMAC256("unit-tests")) | ||
// The signing algorithm and key isn't relevant because the token is already considered valid | ||
// and the signature is never checked. | ||
|
8 changes: 8 additions & 0 deletions
8
authorization/src/main/kotlin/org/modelix/authorization/KeycloakTokenConstants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.modelix.authorization | ||
|
||
object KeycloakTokenConstants { | ||
val EMAIL = "email" | ||
val PREFERRED_USERNAME = "preferred_username" | ||
val REALM_ACCESS = "realm_access" | ||
val REALM_ACCESS_ROLES = "roles" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
authorization/src/main/kotlin/org/modelix/authorization/ModelixTokenConstants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.modelix.authorization | ||
|
||
object ModelixTokenConstants { | ||
val PERMISSIONS = "permissions" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters