【问题标题】:j_security_check gives 403 page with correct credentialsj_security_check 提供具有正确凭据的 403 页面
【发布时间】:2012-04-01 12:32:32
【问题描述】:

当我在login.jsp 页面中输入正确的凭据时,我收到 403 错误。这是我的web.xml

<security-constraint>
        <web-resource-collection>
            <web-resource-name>Test</web-resource-name>
            <url-pattern>/test/something.jsp</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>*</role-name>
        </auth-constraint>
    </security-constraint>

    <login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/Login.jsp</form-login-page>
            <form-error-page>/LoginError.jsp</form-error-page>
        </form-login-config>
    </login-config>

    <security-role>
    <role-name>administrator</role-name>
  </security-role>

这是我的context.xml

<Context>

  <!-- Together with a corresponding entry in web.xml, this configures -->


  <Resource
    name="jdbc/DB"
    auth="Container"
    type="javax.sql.DataSource"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://something/DB"
    username="user"
    password="pass"
    maxActive="8"
    maxIdle="4"
    maxWait="10000"
   />
  <Realm 
    className="org.apache.catalina.realm.JDBCRealm" 
    driverName="com.mysql.jdbc.Driver" 
    connectionURL="jdbc:mysql://something/DB"
    connectionName="user" 
    connectionPassword="pass" 
    userTable="users" 
    userNameCol="user_name" 
    userCredCol="user_password" 
    userRoleTable="users"
    userRoleCol="role" 
    digest="MD5"
    />
</Context>

当它无效时它会进入错误页面,但它就像我的角色不对。在数据库中,我有administratorstaff 作为角色。

【问题讨论】:

  • 您确定您正确地散列了您的密码吗?显示一个示例纯文本哈希对。
  • 我取出了md5摘要,它仍然认为我的角色有误

标签: jsp tomcat j-security-check


【解决方案1】:

我在这里修复了问题:

userRoleCol="role" 

需要:

roleNameCol="role"

【讨论】:

    猜你喜欢
    • 2012-01-11
    • 2023-03-06
    • 2021-12-21
    • 2011-12-09
    • 2013-05-06
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多