简体   繁体   English

成功登录后将CAS重定向到URL

[英]CAS redirect to URL on succesfull login

Here a solution is described to handle redirects to a custom URL based on a condition via use of AccessStrategy . 这里描述了一种解决方案,该解决方案用于通过使用AccessStrategy根据条件处理到自定义URL的重定向。

This however is part of the unauthorized login logical flow therefore results into a still not-logged in user arriving at the end url we redirect to. 但是,这是未经授权的登录逻辑流程的一部分,因此导致仍然没有登录的用户到达我们重定向到的最终URL。 (via getUnauthorizedUrl ) (通过getUnauthorizedUrl

If we want to redirect the user based on a condition, say via injecting an action to the webflow, how can we manipulate the return URL to be changed into a custom one? 如果我们想基于某种条件重定向用户,例如通过向Webflow注入一个动作,我们如何处理将返回URL更改为自定义URL?

WebUtils.getService(requestContext) include getters of the source/originalUrl but no obvious way to set/manipulate said value through an action bean. WebUtils.getService(requestContext)包含source / originalUrl的getter,但是没有通过操作bean设置/操纵所述值的明显方法。

ps Currently using CAS version 5.3.x ps当前使用CAS版本5.3.x

Responses for normal web applications from CAS are built using WebApplicationServiceResponseBuilder . 来自CAS的普通 Web应用程序的响应是使用WebApplicationServiceResponseBuilder构建的。

If you examine this block you will find that the final response is built using WebApplicationServiceResponseBuilder bean. 如果检查此块 ,则会发现最终响应是使用WebApplicationServiceResponseBuilder bean构建的。 It is only created conditionally, if an existing bean is not already found in the context by the same name. 如果在上下文中尚未找到同名的现有bean,则仅有条件地创建它。 So to provide your own, you just need to register a bean with the same name using your own @Configuration class. 因此,要提供您自己的,只需使用自己的@Configuration类注册具有相同名称的bean。

@Bean
public ResponseBuilder<WebApplicationService> webApplicationServiceResponseBuilder() {
    return new MyOwnWebApplicationServiceResponseBuilder(...);
}

...and then proceed to design your own MyOwnWebApplicationServiceResponseBuilder , perhaps even by extending WebApplicationServiceResponseBuilder and overriding what you need where necessary to build the final redirect logic conditionally. ...然后继续设计您自己的MyOwnWebApplicationServiceResponseBuilder ,甚至可以扩展WebApplicationServiceResponseBuilder并覆盖在有条件的情况下构建最终重定向逻辑所需的内容。

To learn about how @Configuration classes work in general, you can: 要了解@Configuration类的一般工作原理,您可以:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM