spring-security

spring security 3.1. custom authentication-failure-url with url parameters

纵然是瞬间 提交于 2020-01-01 10:12:31
问题 I googled and tried lot of variants for some hours but without any success. Please help me to find a solution. Spring version: Spring 3.1 I have login page. Login page depends on URL parameter: /login?code=client1 or /login?code=client2 So client1 and client2 has different login pages. security.xml: <sec:form-login login-page="/login" default-target-url="/start" authentication-failure-url="/login"/> So if user make wrong authentication I show him /login page... But point is I have to show

Get original request url in Spring Security form-login page

亡梦爱人 提交于 2020-01-01 09:22:23
问题 I have the following declared in my spring security configuration file (http://www.springframework.org/schema/security/spring-security-2.0.1.xsd): <form-login login-page="/login.html" /> What Spring Security does is redirect the user to that page if they don't have the correct authentication credentials. How can I get the url of the page the user was trying to get to? 回答1: Original request is represented by the SavedRequest object, which can be accessed as a session attribute named SPRING

How to make @PreAuthorize having higher precedence than @Valid or @Validated

不想你离开。 提交于 2020-01-01 08:35:12
问题 I am using spring boot, and I have enabled the global method security in WebSecurityConfigurerAdapter by @EnableGlobalMethodSecurity(prePostEnabled = true, order = Ordered.HIGHEST_PRECEDENCE) And Below is my controller code @PreAuthorize("hasAnyRole('admin') or principal.id == id") @RequestMapping(value = "/{id}", method = RequestMethod.PUT) public User updateUser(@PathVariable("id") String id, @Valid @RequestBody UserDto userDto) { ....} However, when a non-admin user try to do a PUT request

SecurityContextHolder.getContext().getAuthentication() returning null

蓝咒 提交于 2020-01-01 08:33:35
问题 I want to manually bypass the user from spring Security using the following code: User localeUser = new User(); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(localeUser ,null, localeUser .getAuthorities()); SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(auth); // Create a new session and add the security context. HttpSession session = request.getSession(true); session.setAttribute("SPRING_SECURITY

SecurityContextHolder.getContext().getAuthentication() returning null

你。 提交于 2020-01-01 08:33:26
问题 I want to manually bypass the user from spring Security using the following code: User localeUser = new User(); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(localeUser ,null, localeUser .getAuthorities()); SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(auth); // Create a new session and add the security context. HttpSession session = request.getSession(true); session.setAttribute("SPRING_SECURITY

SecurityContextHolder.getContext().getAuthentication() returning null

和自甴很熟 提交于 2020-01-01 08:33:12
问题 I want to manually bypass the user from spring Security using the following code: User localeUser = new User(); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(localeUser ,null, localeUser .getAuthorities()); SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(auth); // Create a new session and add the security context. HttpSession session = request.getSession(true); session.setAttribute("SPRING_SECURITY

SecurityContextHolder.getContext().getAuthentication() returning null

。_饼干妹妹 提交于 2020-01-01 08:33:07
问题 I want to manually bypass the user from spring Security using the following code: User localeUser = new User(); UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(localeUser ,null, localeUser .getAuthorities()); SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(auth); // Create a new session and add the security context. HttpSession session = request.getSession(true); session.setAttribute("SPRING_SECURITY

Error using Spring authorize tag to check to see if user is logged in?

若如初见. 提交于 2020-01-01 08:04:40
问题 Trying to test to see if a user is logged in I am using the following code: <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> <sec:authorize access="isAuthenticated()"> YES, you are logged in! </sec:authorize> But I am getting the following erorr? javax.servlet.jsp.JspException: No visible WebSecurityExpressionHandler instance could be found in the application context. There must be at least one in order to support expressions in JSP 'authorize' tags. at org

Spring security 3 + JCIFS ntlm

北城余情 提交于 2020-01-01 05:48:16
问题 Can they work together? Some project sample would be great. I have a web-app on Spring3. And i need to implement NTLM. Spring stopped NTLM support in 3rd version. Is there any possibilities to implement it? Looking for a sample project. 回答1: They can be used together. Essentially what you want to do is hook into the SPNEGO protocol and detect when you receive an NTLM packet from the client. A good description of the protocol can be found here: http://www.innovation.ch/personal/ronald/ntlm

Add custom UserDetailsService to Spring Security OAuth2 app

社会主义新天地 提交于 2020-01-01 04:55:08
问题 How do I add the custom UserDetailsService below to this Spring OAuth2 sample? The default user with default password is defined in the application.properties file of the authserver app. However, I would like to add the following custom UserDetailsService to the demo package of the authserver app for testing purposes: package demo; import java.util.List; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.AuthorityUtils; import org