gpt4 book ai didi

spring-security - 403-验证后拒绝访问

转载 作者:行者123 更新时间:2023-12-03 12:06:28 25 4
gpt4 key购买 nike

问候!

当我尝试对现有数据库进行身份验证时,我得到了身份验证,但我得到了403页。如果我尝试输入错误的密码,则会收到“错误的凭证”消息,这与预期的一样。
我尝试对SpringSecurity附带的每个示例应用程序进行身份验证,效果很好。

security-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">

<global-method-security secured-annotations="enabled"></global-method-security>

<http auto-config="true" >
<intercept-url pattern="/admin/**" access="ROLE_TEST" />
<intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />

<form-login
login-page="/login/index.jsp"
default-target-url="/admin/test.jsp"
authentication-failure-url="/login/index.jsp?login_error=1" />
</http>

<authentication-provider user-service-ref="jdbcUserService">
<password-encoder ref="passwordEncoder">
<salt-source system-wide="n103df"/>
</password-encoder>
</authentication-provider>


<beans:bean id="jdbcUserService" class="org.springframework.security.userdetails.jdbc.JdbcDaoImpl">
<beans:property name="rolePrefix" value="" />
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="enableAuthorities" value="true"/>
<beans:property name="enableGroups" value="false"/>
<beans:property name="authoritiesByUsernameQuery" value="SELECT username,authority FROM authorities WHERE username = ?" />
<beans:property name="usersByUsernameQuery" value="SELECT username,password,enabled as enabled FROM users WHERE username = ?" />
<beans:property name="groupAuthoritiesByUsernameQuery" value="" />

</beans:bean>

<beans:bean id="passwordEncoder" class="org.springframework.security.providers.encoding.Md5PasswordEncoder"/>

将不胜感激:-)
提前致谢!

最佳答案

如果获取的是403代码,则意味着用户没有所需的角色。因此,弱化不是问题,是授权。
知道正在发生什么的唯一方法是将日志记录级别调试,应该有更多信息。张贴在这里。
您的角色是否具有“ROLE_”前缀?

关于spring-security - 403-验证后拒绝访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1279083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com