-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(oauth2): add sso logout support #4604
Changes from all commits
aaf9ace
86dfda8
b87833b
f51fb32
b6a227f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,19 +16,55 @@ | |
*/ | ||
package org.camunda.bpm.spring.boot.starter.security.oauth2; | ||
|
||
import org.camunda.bpm.spring.boot.starter.security.oauth2.impl.OAuth2IdentityProvider; | ||
import org.camunda.bpm.spring.boot.starter.property.CamundaBpmProperties; | ||
import org.camunda.bpm.spring.boot.starter.security.oauth2.impl.OAuth2IdentityProvider; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.NestedConfigurationProperty; | ||
|
||
@ConfigurationProperties(OAuth2Properties.PREFIX) | ||
public class OAuth2Properties { | ||
|
||
public static final String PREFIX = CamundaBpmProperties.PREFIX + ".oauth2"; | ||
|
||
/** | ||
* OAuth2 SSO logout properties. | ||
*/ | ||
@NestedConfigurationProperty | ||
private OAuth2SSOLogoutProperties ssoLogout = new OAuth2SSOLogoutProperties(); | ||
|
||
/** | ||
* OAuth2 identity provider properties. | ||
*/ | ||
private OAuth2IdentityProviderProperties identityProvider; | ||
@NestedConfigurationProperty | ||
private OAuth2IdentityProviderProperties identityProvider = new OAuth2IdentityProviderProperties(); | ||
|
||
public static class OAuth2SSOLogoutProperties { | ||
/** | ||
* Enable SSO Logout. Default {@code false}. | ||
*/ | ||
private boolean enabled = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✍️ We need to document this and default value. |
||
|
||
/** | ||
* Enable SSO Logout. Default {@code {baseUrl}}. | ||
*/ | ||
private String postLogoutRedirectUri = "{baseUrl}"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✍️ In docs, we need to add that this must be provided if sso-logout is enabled. At least for Okta, this property is mandatory. |
||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public String getPostLogoutRedirectUri() { | ||
return postLogoutRedirectUri; | ||
} | ||
|
||
public void setPostLogoutRedirectUri(String postLogoutRedirectUri) { | ||
this.postLogoutRedirectUri = postLogoutRedirectUri; | ||
} | ||
} | ||
|
||
public static class OAuth2IdentityProviderProperties { | ||
/** | ||
|
@@ -71,6 +107,14 @@ public void setGroupNameDelimiter(String groupNameDelimiter) { | |
} | ||
} | ||
|
||
public OAuth2SSOLogoutProperties getSsoLogout() { | ||
return ssoLogout; | ||
} | ||
|
||
public void setSsoLogout(OAuth2SSOLogoutProperties ssoLogout) { | ||
this.ssoLogout = ssoLogout; | ||
} | ||
|
||
public OAuth2IdentityProviderProperties getIdentityProvider() { | ||
return identityProvider; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; 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. | ||
*/ | ||
package org.camunda.bpm.spring.boot.starter.security.oauth2.impl; | ||
|
||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import org.camunda.bpm.spring.boot.starter.security.oauth2.OAuth2Properties; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler; | ||
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* {@link OidcClientInitiatedLogoutSuccessHandler} with logging. | ||
*/ | ||
public class SsoLogoutSuccessHandler extends OidcClientInitiatedLogoutSuccessHandler { | ||
|
||
public SsoLogoutSuccessHandler(ClientRegistrationRepository clientRegistrationRepository, | ||
OAuth2Properties oAuth2Properties) { | ||
super(clientRegistrationRepository); | ||
this.setPostLogoutRedirectUri(oAuth2Properties.getSsoLogout().getPostLogoutRedirectUri()); | ||
} | ||
|
||
@Override | ||
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) | ||
throws IOException, ServletException { | ||
logger.debug("Initiating SSO logout with provider."); | ||
super.onLogoutSuccess(request, response, authentication); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; 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. | ||
*/ | ||
package org.camunda.bpm.spring.boot.starter.security.oauth2.impl.plugin; | ||
|
||
public class SsoLogoutPluginConstants { | ||
|
||
public static final String ID = "sso-logout-plugin"; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; 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. | ||
*/ | ||
package org.camunda.bpm.spring.boot.starter.security.oauth2.impl.plugin.admin; | ||
|
||
import org.camunda.bpm.admin.plugin.spi.impl.AbstractAdminPlugin; | ||
import org.camunda.bpm.spring.boot.starter.security.oauth2.impl.plugin.SsoLogoutPluginConstants; | ||
|
||
import java.util.Set; | ||
|
||
public class SsoLogoutAdminPlugin extends AbstractAdminPlugin { | ||
|
||
@Override | ||
public Set<Class<?>> getResourceClasses() { | ||
return Set.of(SsoLogoutAdminPluginRootResource.class); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return SsoLogoutPluginConstants.ID; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; 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. | ||
*/ | ||
package org.camunda.bpm.spring.boot.starter.security.oauth2.impl.plugin.admin; | ||
|
||
import jakarta.ws.rs.Path; | ||
import org.camunda.bpm.admin.resource.AbstractAdminPluginRootResource; | ||
import org.camunda.bpm.spring.boot.starter.security.oauth2.impl.plugin.SsoLogoutPluginConstants; | ||
|
||
@Path("plugin/" + SsoLogoutPluginConstants.ID) | ||
public class SsoLogoutAdminPluginRootResource extends AbstractAdminPluginRootResource { | ||
|
||
public SsoLogoutAdminPluginRootResource() { | ||
super(SsoLogoutPluginConstants.ID); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; 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. | ||
*/ | ||
package org.camunda.bpm.spring.boot.starter.security.oauth2.impl.plugin.cockpit; | ||
|
||
import org.camunda.bpm.cockpit.plugin.spi.impl.AbstractCockpitPlugin; | ||
import org.camunda.bpm.spring.boot.starter.security.oauth2.impl.plugin.SsoLogoutPluginConstants; | ||
|
||
import java.util.Set; | ||
|
||
public class SsoLogoutCockpitPlugin extends AbstractCockpitPlugin { | ||
|
||
@Override | ||
public Set<Class<?>> getResourceClasses() { | ||
return Set.of(SsoLogoutCockpitPluginRootResource.class); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return SsoLogoutPluginConstants.ID; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; 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. | ||
*/ | ||
package org.camunda.bpm.spring.boot.starter.security.oauth2.impl.plugin.cockpit; | ||
|
||
import jakarta.ws.rs.Path; | ||
import org.camunda.bpm.cockpit.plugin.resource.AbstractCockpitPluginRootResource; | ||
import org.camunda.bpm.spring.boot.starter.security.oauth2.impl.plugin.SsoLogoutPluginConstants; | ||
|
||
@Path("plugin/" + SsoLogoutPluginConstants.ID) | ||
public class SsoLogoutCockpitPluginRootResource extends AbstractCockpitPluginRootResource { | ||
|
||
public SsoLogoutCockpitPluginRootResource() { | ||
super(SsoLogoutPluginConstants.ID); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Refactored this so it uses the same
@Bean
structure as other classes.