Skip to content
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

Fix federated IdP logout #425

Merged
merged 5 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class ApplicationConfig {
public static final String LOGOUT_ENDPOINT_CONTEXT = "LogoutEndpointContext";
public static final String USER_INFO_ENDPOINT_CONTEXT = "UserInfoEndpointContext";
public static final String SESSION_IFRAME_ENDPOINT_CONTEXT = "SessionIFrameEndpointContext";
public static final String POST_LOGOUT_REDIRECT_URI = "PostLogoutRedirectUri";

private static Properties properties = new Properties();

Expand Down Expand Up @@ -138,6 +139,15 @@ public static int getISPort() {
return value;
}

public static String getPostLogoutRedirectUri() {

String value = getProperties().getProperty(POST_LOGOUT_REDIRECT_URI);
AmshikaH marked this conversation as resolved.
Show resolved Hide resolved
if (StringUtils.isBlank(value)) {
value = StringUtils.EMPTY;
}
return value;
}

private static String buildURL(String context) {
String buildURL = "";
if (StringUtils.isNotEmpty(context)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ConsumerSecret=
Scope=openid
#Callback URL endpoint that is configured in Identity Server for this OAuth2 application.
CallbackURL=http://localhost:8080/playground2/oauth2client

PostLogoutRedirectUri=http://localhost:8080/playground2/oauth2client
#Identity Server endpoint details.
IdentityServerHostName=localhost
IdentityServerPort=9443
Expand Down
10 changes: 5 additions & 5 deletions oauth2/playground2/src/main/webapp/oauth2.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@
%>
<td>
<button type="button" class="button"
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>';">
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>?post_logout_redirect_uri=<%=ApplicationConfig.getPostLogoutRedirectUri()%>&client_id=<%=(String)session.getAttribute(OAuth2Constants.CONSUMER_KEY)%>';">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if these params empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the post redirect uri and the client id/id token hint (as per the updated flow) are both empty, federated IdP logout will not be possible and the playground app will only log out of the Identity Server.

Logout
</button>
</td>
Expand Down Expand Up @@ -759,7 +759,7 @@
%>
<td>
<button type="button" class="button"
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>';">
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>?post_logout_redirect_uri=<%=ApplicationConfig.getPostLogoutRedirectUri()%>&client_id=<%=(String)session.getAttribute(OAuth2Constants.CONSUMER_KEY)%>';">
Logout
</button>
</td>
Expand Down Expand Up @@ -820,7 +820,7 @@
%>
<td>
<button type="button" class="button"
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>';">
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>?post_logout_redirect_uri=<%=ApplicationConfig.getPostLogoutRedirectUri()%>&client_id=<%=(String)session.getAttribute(OAuth2Constants.CONSUMER_KEY)%>';">
Logout
</button>
</td>
Expand Down Expand Up @@ -890,7 +890,7 @@
<tr>
<td>
<button type="button" class="button"
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>';">
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>?post_logout_redirect_uri=<%=ApplicationConfig.getPostLogoutRedirectUri()%>&client_id=<%=(String)session.getAttribute(OAuth2Constants.CONSUMER_KEY)%>';">
Logout
</button>
</td>
Expand Down Expand Up @@ -920,7 +920,7 @@
<tr>
<td>
<button type="button" class="button"
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>';">
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>?post_logout_redirect_uri=<%=ApplicationConfig.getPostLogoutRedirectUri()%>&client_id=<%=(String)session.getAttribute(OAuth2Constants.CONSUMER_KEY)%>';">
Logout
</button>
</td>
Expand Down
3 changes: 2 additions & 1 deletion oauth2/playground2/src/main/webapp/user-info.jsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%@page import="org.apache.commons.lang.StringUtils" %>
<%@page import="org.json.simple.JSONObject" %>
<%@page import="org.json.simple.parser.JSONParser" %>
<%@page import="org.wso2.sample.identity.oauth2.ApplicationConfig" %>
<%@page import="org.wso2.sample.identity.oauth2.OAuth2Constants" %>
<%@page import="java.util.Iterator" %>
<%@page import="java.util.Map" %>
Expand Down Expand Up @@ -95,7 +96,7 @@
%>
<td colspan="2">
<button type="button" class="button"
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>';">
onclick="document.location.href='<%=(String)session.getAttribute(OAuth2Constants.OIDC_LOGOUT_ENDPOINT)%>?post_logout_redirect_uri=<%=ApplicationConfig.getPostLogoutRedirectUri()%>&client_id=<%=(String)session.getAttribute(OAuth2Constants.CONSUMER_KEY)%>';">
Logout
</button>
</td>
Expand Down
Loading