-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 'Improve SAML Logout' (#32) from feature/saml_logo…
…ut into develop
- Loading branch information
Showing
9 changed files
with
242 additions
and
20 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
52 changes: 52 additions & 0 deletions
52
...ain/java/eu/openanalytics/containerproxy/auth/impl/saml/AuthenticationFailureHandler.java
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* ContainerProxy | ||
* | ||
* Copyright (C) 2016-2020 Open Analytics | ||
* | ||
* =========================================================================== | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Apache License as published by | ||
* The Apache Software Foundation, either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Apache License for more details. | ||
* | ||
* You should have received a copy of the Apache License | ||
* along with this program. If not, see <http://www.apache.org/licenses/> | ||
*/ | ||
package eu.openanalytics.containerproxy.auth.impl.saml; | ||
|
||
import org.springframework.security.core.AuthenticationException; | ||
import org.springframework.security.saml.SAMLStatusException; | ||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; | ||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
public class AuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler { | ||
|
||
public void onAuthenticationFailure(HttpServletRequest request, | ||
HttpServletResponse response, AuthenticationException exception) | ||
throws IOException, ServletException { | ||
|
||
|
||
if (exception.getCause() instanceof SAMLStatusException) { | ||
SAMLStatusException samlException = (SAMLStatusException) exception.getCause(); | ||
|
||
if (samlException.getStatusCode().equals("urn:oasis:names:tc:SAML:2.0:status:RequestDenied")) { | ||
response.sendRedirect(ServletUriComponentsBuilder.fromCurrentContextPath().path("/app-access-denied").build().toUriString()); | ||
return; | ||
} | ||
} | ||
|
||
super.onAuthenticationFailure(request, response, exception); | ||
} | ||
|
||
} |
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
44 changes: 44 additions & 0 deletions
44
src/main/java/eu/openanalytics/containerproxy/ui/LogoutSuccessController.java
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* ContainerProxy | ||
* | ||
* Copyright (C) 2016-2020 Open Analytics | ||
* | ||
* =========================================================================== | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Apache License as published by | ||
* The Apache Software Foundation, either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Apache License for more details. | ||
* | ||
* You should have received a copy of the Apache License | ||
* along with this program. If not, see <http://www.apache.org/licenses/> | ||
*/ | ||
package eu.openanalytics.containerproxy.ui; | ||
|
||
import eu.openanalytics.containerproxy.api.BaseController; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.ModelMap; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
import javax.inject.Inject; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
@Controller | ||
public class LogoutSuccessController extends BaseController { | ||
|
||
@Inject | ||
private Environment environment; | ||
|
||
@RequestMapping(value = "/logout-success", method = RequestMethod.GET) | ||
public String getAuthErrorPage() { | ||
return "logout-success"; | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!-- | ||
ContainerProxy | ||
Copyright (C) 2016-2020 Open Analytics | ||
=========================================================================== | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the Apache License as published by | ||
The Apache Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
Apache License for more details. | ||
You should have received a copy of the Apache License | ||
along with this program. If not, see <http://www.apache.org/licenses/> | ||
--> | ||
<!DOCTYPE html> | ||
<html | ||
xmlns:th="http://www.thymeleaf.org" | ||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"> | ||
|
||
<head lang="en"> | ||
<title th:text="${title}"></title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<link rel="stylesheet" media="screen" th:href="@{/webjars/bootstrap/3.4.1/css/bootstrap.min.css}"/> | ||
<link rel="stylesheet" media="screen" th:href="@{/css/login.css}"/> | ||
<link rel="stylesheet" media="screen" type="text/css" href="https://cdn.jsdelivr.net/bootstrap-social/5.1.1/bootstrap-social.css"/> | ||
<link rel="stylesheet" media="screen" type="text/css" href="https://cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.min.css"/> | ||
<script th:src="@{/webjars/jquery/3.5.0/jquery.min.js}"></script> | ||
<script th:src="@{/webjars/bootstrap/3.4.1/js/bootstrap.min.js}"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h2>You do not have access to this application.</h2> | ||
<p>Your account does not have the required roles or groups required for accessing this application.</p> | ||
<p>Please contact your administrator if you believe this is a mistake.</p> | ||
</div> | ||
|
||
<style> | ||
h2 { | ||
margin-bottom: 20px; | ||
margin-top: 20px; | ||
} | ||
</style> | ||
|
||
</body> | ||
|
||
</html> |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!-- | ||
ContainerProxy | ||
Copyright (C) 2016-2020 Open Analytics | ||
=========================================================================== | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the Apache License as published by | ||
The Apache Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
Apache License for more details. | ||
You should have received a copy of the Apache License | ||
along with this program. If not, see <http://www.apache.org/licenses/> | ||
--> | ||
<!DOCTYPE html> | ||
<html | ||
xmlns:th="http://www.thymeleaf.org" | ||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"> | ||
|
||
<head lang="en"> | ||
<title th:text="${title}"></title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<link rel="stylesheet" media="screen" th:href="@{/webjars/bootstrap/3.4.1/css/bootstrap.min.css}"/> | ||
<link rel="stylesheet" media="screen" th:href="@{/css/login.css}"/> | ||
<link rel="stylesheet" media="screen" type="text/css" href="https://cdn.jsdelivr.net/bootstrap-social/5.1.1/bootstrap-social.css"/> | ||
<link rel="stylesheet" media="screen" type="text/css" href="https://cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.min.css"/> | ||
<script th:src="@{/webjars/jquery/3.5.0/jquery.min.js}"></script> | ||
<script th:src="@{/webjars/bootstrap/3.4.1/js/bootstrap.min.js}"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h2>You have been logged out successfully.</h2> | ||
<p><a th:href="@{/}"><b>Login again</b></a></p> | ||
</div> | ||
|
||
<style> | ||
h2 { | ||
margin-bottom: 20px; | ||
margin-top: 20px; | ||
} | ||
</style> | ||
|
||
</body> | ||
|
||
</html> |