简体   繁体   English

链接以使用Spring Security登录

[英]Link to log in with spring security

I've got a web application that uses spring security and spring mvc. 我有一个使用Spring Security和Spring MVC的Web应用程序。 Some of the pages are protected using security:intercept-urls, and others are not protected at all. 有些页面使用security:intercept-urls进行保护,而其他页面则完全不受保护。 Of the pages that are not protected, one of them has content for anonymous users and content for authenticated users, which is being differentiated using the spring security tag "authorize". 在未受保护的页面中,其中之一具有匿名用户的内容和已认证用户的内容,这些内容使用spring安全标签“ authorize”进行区分。 On these pages I want to give users the option to log in to view all of the content. 在这些页面上,我希望为用户提供登录选项以查看所有内容。 It seems that if I directly link to my custom login page it doesn't redirect the user to the content page after successful log in. Is there any way to link to the login page so it returns to the referring URL (or a user specified URL) upon successful authentication? 看来,如果我直接链接到我的自定义登录页面,则成功登录后它不会将用户重定向到内容页面。有什么方法可以链接到登录页面,以便它返回到引用URL(或指定的用户) URL)成功认证后?

A similar question has been asked here Spring Security targetUrlParameter does not redirect . 这里已经问过类似的问题, Spring Security targetUrlParameter不会重定向

You can use the parameter spring-security-redirect to pass through the destination URL (your content page) where you want to land after successful login. 您可以使用参数spring-security-redirect来传递成功登录后要到达的目标URL(您的内容页面)。 This parameter would need to be passed to the login form from the content page, and then the login form would need to place it in a hidden field so that it gets propagated to Spring Security with the rest of the login request. 该参数需要从内容页面传递到登录表单,然后该登录表单需要将其放置在隐藏字段中,以便它与其余登录请求一起传播到Spring Security。

More info here 更多信息在这里

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

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