forked from geoserver/geoserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add JWT Header support for multiple ADMIN/ROLE_ADMINISTRATOR support * better javascript handling for when creating a new jwt headers filter * doc change for role converter * fix bug when json path doesn't exist * delete old src/ dir * afabiani review changes - (c) header, more specific import, UI: Role Source enum --------- Co-authored-by: david blasby <[email protected]>
- Loading branch information
1 parent
c98f9c0
commit b692158
Showing
43 changed files
with
126 additions
and
3,179 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
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
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
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
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
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 |
---|---|---|
|
@@ -31,10 +31,11 @@ public void testSimpleJwt() throws ParseException { | |
Assert.assertEquals("[email protected]", username); | ||
} | ||
|
||
String json = | ||
"{\"exp\":1707155912,\"iat\":1707155612,\"jti\":\"888715ae-a79d-4633-83e5-9b97dee02bbc\",\"iss\":\"https://login-live-dev.geocat.live/realms/dave-test2\",\"aud\":\"account\",\"sub\":\"ea33e3cc-f0e1-4218-89cb-8d48c27eee3d\",\"typ\":\"Bearer\",\"azp\":\"live-key2\",\"session_state\":\"ae7796fa-b374-4754-a294-e0eb834b23b5\",\"acr\":\"1\",\"realm_access\":{\"roles\":[\"default-roles-dave-test2\",\"offline_access\",\"uma_authorization\"]},\"resource_access\":{\"live-key2\":{\"roles\":[\"GeoserverAdministrator\"]},\"account\":{\"roles\":[\"manage-account\",\"manage-account-links\",\"view-profile\"]}},\"scope\":\"openidprofileemail\",\"sid\":\"ae7796fa-b374-4754-a294-e0eb834b23b5\",\"email_verified\":false,\"name\":\"davidblasby\",\"preferred_username\":\"[email protected]\",\"given_name\":\"david\",\"family_name\":\"blasby\",\"email\":\"[email protected]\"}"; | ||
|
||
@Test | ||
public void testSimpleJson() throws ParseException { | ||
String json = | ||
"{\"exp\":1707155912,\"iat\":1707155612,\"jti\":\"888715ae-a79d-4633-83e5-9b97dee02bbc\",\"iss\":\"https://login-live-dev.geocat.live/realms/dave-test2\",\"aud\":\"account\",\"sub\":\"ea33e3cc-f0e1-4218-89cb-8d48c27eee3d\",\"typ\":\"Bearer\",\"azp\":\"live-key2\",\"session_state\":\"ae7796fa-b374-4754-a294-e0eb834b23b5\",\"acr\":\"1\",\"realm_access\":{\"roles\":[\"default-roles-dave-test2\",\"offline_access\",\"uma_authorization\"]},\"resource_access\":{\"live-key2\":{\"roles\":[\"GeoserverAdministrator\"]},\"account\":{\"roles\":[\"manage-account\",\"manage-account-links\",\"view-profile\"]}},\"scope\":\"openidprofileemail\",\"sid\":\"ae7796fa-b374-4754-a294-e0eb834b23b5\",\"email_verified\":false,\"name\":\"davidblasby\",\"preferred_username\":\"[email protected]\",\"given_name\":\"david\",\"family_name\":\"blasby\",\"email\":\"[email protected]\"}"; | ||
String username = | ||
getExtractor(JwtConfiguration.UserNameHeaderFormat.JSON, "preferred_username") | ||
.extractUserName(json); | ||
|
@@ -49,4 +50,33 @@ public void testSimpleString() throws ParseException { | |
.extractUserName(json); | ||
Assert.assertEquals("[email protected]", username); | ||
} | ||
|
||
@Test | ||
public void testNonExistentClaim() { | ||
String claimValue = | ||
getExtractor(JwtConfiguration.UserNameHeaderFormat.JSON, "notThere") | ||
.extractUserName(json); | ||
Assert.assertNull(claimValue); | ||
|
||
claimValue = | ||
getExtractor( | ||
JwtConfiguration.UserNameHeaderFormat.JSON, | ||
"resource_access.notThere.abc") | ||
.extractUserName(json); | ||
Assert.assertNull(claimValue); | ||
|
||
claimValue = | ||
getExtractor( | ||
JwtConfiguration.UserNameHeaderFormat.JSON, | ||
"resource_access.live-key2.notThere") | ||
.extractUserName(json); | ||
Assert.assertNull(claimValue); | ||
|
||
claimValue = | ||
getExtractor( | ||
JwtConfiguration.UserNameHeaderFormat.JSON, | ||
"resource_access.live-key2.roles.notThere") | ||
.extractUserName(json); | ||
Assert.assertNull(claimValue); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/community/jwt-headers/src/main/java/applicationSecurityContext.xml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.