Repository navigation
Replace OpenID 2.0 with OAuth 2.0/OIDC login #155
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ecaf730
Replace OpenID 2.0 with OAuth 2.0/OIDC login via Spring Security
mraible cb68f00
Build the Docker image from the working tree and seed Keycloak with t…
mraible 87cfd06
Resolve OIDC users by Roller username and provision independently of …
mraible f37a3b7
Enforce the configured authentication method server side and harden O…
mraible 09fc55b
Update the registration, profile, and user admin views for the rename…
mraible 5efd0db
Default OIDC auto-provisioning off, matching the LDAP precedent
mraible 212dad6
Fix the OIDC account views, upgrades, and provider resolution raised …
mraible d4f1ca9
Merge branch 'feature/jakarta-ee-10-migration' into feature/oidc-login
mraible 3a94a0d
Update jackson-databind to 2.22.3 to clear known CVEs
mraible da09b1b
Merge branch 'feature/jakarta-ee-10-migration' into feature/oidc-login
mraible 94269ac
Merge branch 'feature/jakarta-ee-10-migration' into feature/oidc-login
mraible 2b8d0a4
Hold OIDC sign-in behind the initial setup token
mraible c4d5dec
Add the ASF license header to the Keycloak health check script
mraible 5985ad2
Merge branch 'feature/jakarta-ee-10-migration' into feature/oidc-login
mraible ec5cbf1
End the identity provider session when an OIDC user logs out
mraible 17aadd6
Merge branch 'feature/jakarta-ee-10-migration' into feature/oidc-login
mraible 4e30f98
Add the ASF license header to .dockerignore
mraible e40978f
Complete the license header in .dockerignore
mraible 5eff52b
Drop the leading blank line from .dockerignore
mraible 457de9c
Merge pull request #154 from mraible/feature/jakarta-ee-10-migration
mraible 93ff6eb
Merge master into feature/oidc-login
mraible 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. The ASF licenses this file to You | ||
| # under the Apache License, Version 2.0 (the "License"); you may not | ||
| # use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. For additional information regarding | ||
| # copyright in this work, please see the NOTICE file in the top level | ||
| # directory of this distribution. | ||
|
|
||
| .git | ||
| docker/postgresql-data | ||
| docker/postgresql-16-data | ||
| docker/roller-data | ||
| it-selenium |
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
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
84 changes: 84 additions & 0 deletions
84
app/src/main/java/org/apache/roller/weblogger/ui/core/security/LogoutRedirect.java
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,84 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. The ASF licenses this file to You | ||
| * under the Apache License, Version 2.0 (the "License"); you may not | ||
| * use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. For additional information regarding | ||
| * copyright in this work, please see the NOTICE file in the top level | ||
| * directory of this distribution. | ||
| */ | ||
|
|
||
| package org.apache.roller.weblogger.ui.core.security; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import jakarta.servlet.ServletContext; | ||
| import jakarta.servlet.ServletException; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
|
|
||
| import org.springframework.security.core.Authentication; | ||
| import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken; | ||
| import org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler; | ||
| import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; | ||
| import org.springframework.security.oauth2.core.oidc.user.OidcUser; | ||
| import org.springframework.web.context.support.WebApplicationContextUtils; | ||
|
|
||
| /** | ||
| * Sends the browser on after Roller has ended its own session. | ||
| * | ||
| * <p>A user who signed in through an OIDC provider is sent to the provider's | ||
| * {@code end_session_endpoint}, so the provider session ends too and the next | ||
| * "Sign in with ..." asks for credentials again. The provider then returns the | ||
| * browser to {@code postLogoutRedirectUri}. Everyone else, and OIDC users whose | ||
| * provider does not advertise an end-session endpoint, go to the front page as | ||
| * before. | ||
| */ | ||
| public class LogoutRedirect { | ||
|
|
||
| private final ClientRegistrationRepository clientRegistrationRepository; | ||
|
|
||
| public LogoutRedirect(ClientRegistrationRepository clientRegistrationRepository) { | ||
| this.clientRegistrationRepository = clientRegistrationRepository; | ||
| } | ||
|
|
||
| /** Uses the client registrations configured in {@code security.xml}. */ | ||
| public static LogoutRedirect forServletContext(ServletContext servletContext) { | ||
| return new LogoutRedirect(WebApplicationContextUtils | ||
| .getRequiredWebApplicationContext(servletContext) | ||
| .getBean(ClientRegistrationRepository.class)); | ||
| } | ||
|
|
||
| /** | ||
| * @param authentication the authentication of the session being ended, | ||
| * captured before the session was invalidated; may be null | ||
| * @param postLogoutRedirectUri absolute URL the provider returns to, or | ||
| * null to let Spring derive it from the request | ||
| */ | ||
| public void sendRedirect(HttpServletRequest request, HttpServletResponse response, | ||
| Authentication authentication, String postLogoutRedirectUri) | ||
| throws IOException, ServletException { | ||
|
|
||
| if (clientRegistrationRepository != null | ||
| && authentication instanceof OAuth2AuthenticationToken | ||
| && authentication.getPrincipal() instanceof OidcUser) { | ||
| OidcClientInitiatedLogoutSuccessHandler handler = | ||
| new OidcClientInitiatedLogoutSuccessHandler(clientRegistrationRepository); | ||
| handler.setPostLogoutRedirectUri(postLogoutRedirectUri != null | ||
| ? postLogoutRedirectUri : "{baseUrl}/"); | ||
| // falls back to the context root when the provider has no end-session endpoint | ||
| handler.onLogoutSuccess(request, response, authentication); | ||
| return; | ||
| } | ||
|
|
||
| response.sendRedirect(request.getContextPath() + "/"); | ||
| } | ||
| } |
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.