Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Pac4j delegation issue in the event that provider cancels.
- Loading branch information
1 parent
b24cb62
commit 46c8769
Showing
6 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...r-support-pac4j-webflow/src/main/java/org/apereo/cas/web/flow/Pac4jErrorViewResolver.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 @@ | ||
package org.apereo.cas.web.flow; | ||
|
||
import com.google.common.collect.Maps; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.autoconfigure.web.DefaultErrorViewResolver; | ||
import org.springframework.boot.autoconfigure.web.ErrorViewResolver; | ||
import org.springframework.boot.autoconfigure.web.ResourceProperties; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.util.Map; | ||
|
||
/** | ||
* This is {@link Pac4jErrorViewResolver}. | ||
* | ||
* @author Misagh Moayyed | ||
* @since 5.0.0 | ||
*/ | ||
public class Pac4jErrorViewResolver implements ErrorViewResolver { | ||
|
||
@Autowired | ||
@Qualifier("conventionErrorViewResolver") | ||
private ErrorViewResolver conventionErrorViewResolver; | ||
|
||
@Override | ||
public ModelAndView resolveErrorView(final HttpServletRequest request, | ||
final HttpStatus status, final Map<String, Object> map) { | ||
|
||
final Map<String, String[]> params = request.getParameterMap(); | ||
if (params.containsKey("error") && params.containsKey("error_code") && params.containsKey("error_description")) { | ||
final Map<String, Object> model = Maps.newHashMap(); | ||
model.put("code", status.value()); | ||
model.put("error", request.getParameter("error")); | ||
model.put("description", request.getParameter("error_description")); | ||
model.put("client", request.getParameter("client_name")); | ||
model.putAll(map); | ||
return new ModelAndView("casPac4jStopWebflow", model); | ||
} | ||
return conventionErrorViewResolver.resolveErrorView(request, status, map); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
webapp/cas-server-webapp/src/main/resources/templates/casPac4jStopWebflow.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,22 @@ | ||
<!DOCTYPE html> | ||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="layout"> | ||
|
||
<head> | ||
<title th:text="#{screen.pac4j.unauthz.pagetitle}"></title> | ||
</head> | ||
|
||
<body id="cas"> | ||
<div layout:fragment="content"> | ||
<div class="alert alert-danger"> | ||
<h2 th:utext="#{screen.pac4j.unauthz.heading}"/> | ||
<p th:utext="#{screen.pac4j.unauthz.message}"/> | ||
|
||
<div> | ||
<p/> | ||
<pre th:text="'Error: ' + ${error} + ', Code: ' + ${error} + ', Description: ' + ${description} + ', Client: ' + ${client}"/> | ||
</div> | ||
</div> | ||
<p><a class="btn btn-success" th:href="@{/login}" th:text="#{screen.pac4j.unauthz.login}"/></p> | ||
</div> | ||
</body> | ||
</html> |