-
Notifications
You must be signed in to change notification settings - Fork 0
DEV-683 Implement OIDC for GeoServer #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jason-raitz
wants to merge
9
commits into
main
Choose a base branch
from
DEV-683_OIDC
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
09ab67b
WIP
jason-raitz 5e9a4b8
setup oidc for local dev on geoserver
jason-raitz 96fde38
cleanup
jason-raitz d45c9ef
refactor with geoserver-config service
jason-raitz e4403d3
update readme
jason-raitz d28b715
ci resets
jason-raitz ea3b693
cleanup
jason-raitz 97c053f
fixes from PR comments
jason-raitz 4f0ffbd
add keycloak to geoserver-secure
jason-raitz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,83 @@ | ||
| #!/usr/bin/env sh | ||
| set -eu | ||
|
|
||
| GEOSERVER_AUTH="${GEOSERVER_AUTH:-admin:geoserver}" | ||
|
|
||
| # This script assumes both geoserver and geoserver-secure are healthy | ||
| # and configured exactly the same. | ||
| for GEOSERVER_HOST in geoserver geoserver-secure; do | ||
| GEOSERVER_REST="http://${GEOSERVER_HOST}:8080/geoserver/rest" | ||
|
|
||
| echo "Creating keycloak OIDC auth filter on ${GEOSERVER_HOST}..." | ||
| HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ | ||
| --request POST \ | ||
| --url "${GEOSERVER_REST}/security/authfilters" \ | ||
| --user "${GEOSERVER_AUTH}" \ | ||
| --header 'Content-Type: application/xml; charset=utf-8' \ | ||
| --data "<org.geoserver.security.oauth2.login.GeoServerOAuth2LoginFilterConfig> | ||
| <name>keycloak</name> | ||
| <className>org.geoserver.security.oauth2.login.GeoServerOAuth2LoginAuthenticationFilter</className> | ||
| <roleSource class=\"org.geoserver.security.oauth2.login.GeoServerOAuth2LoginFilterConfig\$OpenIdRoleSource\">IdToken</roleSource> | ||
| <baseRedirectUri>http://localhost:8080/geoserver/</baseRedirectUri> | ||
| <googleEnabled>false</googleEnabled> | ||
| <googleUserNameAttribute>email</googleUserNameAttribute> | ||
| <googleRedirectUri>http://localhost:8080/geoserver/web/login/oauth2/code/google</googleRedirectUri> | ||
| <gitHubEnabled>false</gitHubEnabled> | ||
| <gitHubUserNameAttribute>id</gitHubUserNameAttribute> | ||
| <gitHubRedirectUri>http://localhost:8080/geoserver/web/login/oauth2/code/gitHub</gitHubRedirectUri> | ||
| <msEnabled>false</msEnabled> | ||
| <msUserNameAttribute>sub</msUserNameAttribute> | ||
| <msRedirectUri>http://localhost:8080/geoserver/web/login/oauth2/code/microsoft</msRedirectUri> | ||
| <msScopes>openid profile email</msScopes> | ||
| <oidcEnabled>true</oidcEnabled> | ||
| <oidcClientId>${OIDC_CLIENT_ID}</oidcClientId> | ||
| <oidcClientSecret>${OIDC_CLIENT_SECRET}</oidcClientSecret> | ||
| <oidcUserNameAttribute>email</oidcUserNameAttribute> | ||
| <oidcRedirectUri>http://localhost:8080/geoserver/web/login/oauth2/code/oidc</oidcRedirectUri> | ||
| <oidcScopes>openid berkeley_edu_groups email profile</oidcScopes> | ||
| <oidcDiscoveryUri>http://keycloak:8180/realms/berkeley-local/.well-known/openid-configuration</oidcDiscoveryUri> | ||
| <oidcTokenUri>http://keycloak:8180/realms/berkeley-local/protocol/openid-connect/token</oidcTokenUri> | ||
| <oidcAuthorizationUri>http://keycloak.localhost:8180/realms/berkeley-local/protocol/openid-connect/auth</oidcAuthorizationUri> | ||
| <oidcUserInfoUri>http://keycloak:8180/realms/berkeley-local/protocol/openid-connect/userinfo</oidcUserInfoUri> | ||
| <oidcJwkSetUri>http://keycloak:8180/realms/berkeley-local/protocol/openid-connect/certs</oidcJwkSetUri> | ||
| <oidcLogoutUri>http://keycloak.localhost:8180/realms/berkeley-local/protocol/openid-connect/logout</oidcLogoutUri> | ||
| <oidcForceAuthorizationUriHttps>false</oidcForceAuthorizationUriHttps> | ||
| <oidcForceTokenUriHttps>false</oidcForceTokenUriHttps> | ||
| <oidcEnforceTokenValidation>true</oidcEnforceTokenValidation> | ||
| <oidcUsePKCE>false</oidcUsePKCE> | ||
| <oidcAuthenticationMethodPostSecret>false</oidcAuthenticationMethodPostSecret> | ||
| <oidcAllowUnSecureLogging>false</oidcAllowUnSecureLogging> | ||
| <tokenRolesClaim>preferred_username</tokenRolesClaim> | ||
| <postLogoutRedirectUri>http://localhost:8080/geoserver/web/</postLogoutRedirectUri> | ||
| <enableRedirectAuthenticationEntryPoint>true</enableRedirectAuthenticationEntryPoint> | ||
| <msGraphMemberOf>false</msGraphMemberOf> | ||
| <msGraphAppRoleAssignments>false</msGraphAppRoleAssignments> | ||
| <roleConverterString>testadmin=ADMIN</roleConverterString> | ||
| <onlyExternalListedRoles>false</onlyExternalListedRoles> | ||
| </org.geoserver.security.oauth2.login.GeoServerOAuth2LoginFilterConfig>") | ||
|
|
||
| case "$HTTP_STATUS" in | ||
| 200|201) echo "Auth filter created." ;; | ||
| *) echo "ERROR: Unexpected status creating auth filter on ${GEOSERVER_HOST}: $HTTP_STATUS"; exit 1 ;; | ||
| esac | ||
|
|
||
| echo "Updating web filter chain on ${GEOSERVER_HOST}..." | ||
| FILTER_CHAIN_UPDATE_HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ | ||
| --request PUT \ | ||
| --url "${GEOSERVER_REST}/security/filterchain/web" \ | ||
| --user "${GEOSERVER_AUTH}" \ | ||
| --header 'Content-Type: application/xml; charset=utf-8' \ | ||
| --data '<filters name="web" class="org.geoserver.security.HtmlLoginFilterChain" path="/web/**,/gwc/rest/web/**,/" disabled="false" allowSessionCreation="true" ssl="false" matchHTTPMethod="false" interceptorName="interceptor" exceptionTranslationName="exception"> | ||
| <filter>rememberme</filter> | ||
| <filter>form</filter> | ||
| <filter>keycloak</filter> | ||
| <filter>anonymous</filter> | ||
| </filters>') | ||
|
|
||
| case "$FILTER_CHAIN_UPDATE_HTTP_STATUS" in | ||
| 200) echo "Web filter chain updated." ;; | ||
| *) echo "ERROR: Unexpected status updating web filter chain: $FILTER_CHAIN_UPDATE_HTTP_STATUS"; exit 1 ;; | ||
| esac | ||
|
|
||
| echo "Done with ${GEOSERVER_HOST}." | ||
| done |
This file contains hidden or 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,102 @@ | ||
| # keycloak-config-cli realm configuration for local GeoServer development. | ||
| # It provides a local Keycloak realm, GeoServer client, and Berkeley-style | ||
| # group claims for predictable OIDC testing. | ||
| # | ||
| # Group names mirror the production LDAP DN format so GeoServer can test the same | ||
| # role-mapping shape used against the real IdP. | ||
| # | ||
| # Secrets are injected at import time via substitution by keycloak-config-cli. | ||
| # Set OIDC_CLIENT_SECRET in your .env file — never commit a real secret here. | ||
|
|
||
| realm: berkeley-local | ||
| enabled: true | ||
| displayName: Berkeley Local | ||
|
|
||
| clientScopes: | ||
| - name: berkeley_edu_groups | ||
| description: Berkeley group memberships | ||
| protocol: openid-connect | ||
| attributes: | ||
| include.in.token.scope: "true" | ||
| display.on.consent.screen: "false" | ||
| protocolMappers: | ||
| - name: groups | ||
| protocol: openid-connect | ||
| protocolMapper: oidc-group-membership-mapper | ||
| consentRequired: false | ||
| config: | ||
| # Match Calnet's behavior by not prepending groups with "/" | ||
| full.path: "false" | ||
| id.token.claim: "true" | ||
| access.token.claim: "true" | ||
| introspection.token.claim: "true" | ||
| userinfo.token.claim: "true" | ||
| claim.name: groups | ||
| jsonType.label: String | ||
|
|
||
| clients: | ||
| - clientId: "$(OIDC_CLIENT_ID)" | ||
| name: "$(OIDC_CLIENT_ID)" | ||
| enabled: true | ||
| rootUrl: "http://localhost:8080" | ||
| adminUrl: "http://localhost:8080" | ||
| redirectUris: | ||
| - "http://localhost:8080/*" | ||
| webOrigins: | ||
| - "http://localhost:8080" | ||
| publicClient: false | ||
| secret: "$(OIDC_CLIENT_SECRET)" | ||
| standardFlowEnabled: true | ||
| directAccessGrantsEnabled: true | ||
| serviceAccountsEnabled: true | ||
| frontchannelLogout: true | ||
| attributes: | ||
| backchannel.logout.session.required: "true" | ||
| frontchannel.logout.session.required: "true" | ||
| defaultClientScopes: | ||
| - profile | ||
| - berkeley_edu_groups | ||
|
|
||
| groups: | ||
| - name: "$(OIDC_ADMIN_GROUP)" | ||
| - name: "$(OIDC_USER_GROUP)" | ||
| - name: "cn=edu:berkeley:org:libr:unrelated:group,ou=campus groups,dc=berkeley,dc=edu" | ||
|
|
||
| users: | ||
| - username: testadmin | ||
| enabled: true | ||
| email: testadmin@example.edu | ||
| firstName: Test | ||
| lastName: Admin | ||
| credentials: | ||
| - type: password | ||
| value: testadmin | ||
| temporary: false | ||
| groups: | ||
| - "$(OIDC_ADMIN_GROUP)" | ||
| - "$(OIDC_USER_GROUP)" | ||
|
|
||
| - username: testuser | ||
| enabled: true | ||
| email: testuser@example.edu | ||
| firstName: Test | ||
| lastName: User | ||
| credentials: | ||
| - type: password | ||
| value: testuser | ||
| temporary: false | ||
| groups: | ||
| - "$(OIDC_USER_GROUP)" | ||
|
|
||
| - username: testpublic | ||
| enabled: true | ||
| email: testpublic@example.edu | ||
| firstName: Test | ||
| lastName: Public | ||
| credentials: | ||
| - type: password | ||
| value: testpublic | ||
| temporary: false | ||
| groups: | ||
| - cn=edu:berkeley:org:libr:unrelated:group,ou=campus groups,dc=berkeley,dc=edu |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.