Authentication 更改经过身份验证的用户';s在spring security中授予的角色和身份验证令牌
我正在尝试在会话中更改身份验证令牌 Scenerio是 匿名用户到达主页,并将Authentication 更改经过身份验证的用户';s在spring security中授予的角色和身份验证令牌,authentication,spring-security,Authentication,Spring Security,我正在尝试在会话中更改身份验证令牌 Scenerio是 匿名用户到达主页,并将AnonymousAuthenticationToken保存到与ROLE\u ANONYMOUS授予权限的会话中。。但当他/她想要创建项目时,应用程序会强制他/她登录。在他/她使用openId帐户登录后,我将创建一个OpenIDAuthenticationToken,该token具有ROLE\u USER授予的权限,并用它替换存储的token。他/她可以使用ROLE\u USER访问任何允许的地方 当他想注销时,我正在
AnonymousAuthenticationToken
保存到与ROLE\u ANONYMOUS
授予权限的会话中。。但当他/她想要创建项目时,应用程序会强制他/她登录。在他/她使用openId帐户登录后,我将创建一个OpenIDAuthenticationToken
,该token具有ROLE\u USER
授予的权限,并用它替换存储的token。他/她可以使用ROLE\u USER
访问任何允许的地方
当他想注销时,我正在从上下文中删除令牌,这没关系
但是强>
当他/她再次登录时,我可以观察到令牌正在上下文中替换,他/她无法访问ROLE\u USER
允许的部分
登录前先登录
Current authentication is org.springframework.security.authentication.AnonymousAuthenticationToken@6fabe8e0: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffe9938: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: B1F6870C9FF93DCB50A6FD71302A9090; Granted Authorities: ROLE_ANONYMOUS
登录后的日志
After refreshing authentication: [org.springframework.security.openid.OpenIDAuthenticationToken@c9e3a81c: Principal: Hugo Weaving; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffe9938: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: B1F6870C9FF93DCB50A6FD71302A9090; Granted Authorities: ROLE_USER, attributes : null]
我现在没有分配开放id属性,但我认为这不是问题所在
这是我的web.xml
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/security-context.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
上下文配置位置
/WEB-INF/security-context.xml
org.springframework.web.context.ContextLoaderListener
这是我的security.xml
<http auto-config="true">
<intercept-url pattern="/first.jsp" access="ROLE_USER" />
<intercept-url pattern="/second.jsp" access="ROLE_USER" />
<openid-login login-page="/index.html"></openid-login>
</http>
**基本上,我是在强迫想要访问
first.jsp
和second.jsp
的客户使用他们的开放id帐户登录。最后我解决了这个问题。这个问题不在auth令牌中,而是在我的工作流程中。更改了一行代码,就完成了。最后我解决了它。这个问题不在auth令牌中,而是在我的工作流程中。更改了一行代码,就完成了。您对哪一行进行了注释?