我在JBoss 7上的webapp中使用基于表单的身份验证,由LdapLoginModule支持。
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Resources</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>ldap</realm-name>
<form-login-config>
<form-login-page>login.html</form-login-page>
<form-error-page>login.html</form-error-page>
</form-login-config>
</login-config>
访问/我已发送到login.html,如果我将无效密码添加到/ j_security_check。如果我输入正确的密码虽然我已发送到/但在浏览器中出现以下错误:
HTTP Status 403 - Access to the requested resource has been denied
成功协商登录表单后,为什么我会被拒绝访问index.html?没有任何日志输出的迹象。
答案 0 :(得分:1)
这似乎已经归结为基于角色的身份验证。它现在使用以下web.xml(现在作为2.5而不是2.3 web-app):
<security-role>
<role-name>*</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Resources</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>ldap</realm-name>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/login.html</form-error-page>
</form-login-config>
</login-config>
以下JBoss登录模块:
<login-module code="org.jboss.security.auth.spi.LdapExtLoginModule" flag="required">
<module-option name="java.naming.provider.url" value="ldap://localhost:389"/>
<module-option name="java.naming.security.authentication" value="simple"/>
<module-option name="bindDN" value="cn=Manager,dc=domain,dc=com"/>
<module-option name="baseCtxDN" value="ou=people,dc=domain,dc=com"/>
<module-option name="baseFilter" value="(cn={0})"/>
<module-option name="bindCredential" value="password"/>
<module-option name="principalDNPrefix" value="cn="/>
<module-option name="principalDNSuffix" value=",ou=people,dc=domain,dc=com"/>
<module-option name="rolesCtxDN" value="ou=groups,dc=domain,dc=com"/>
<module-option name="uidAttributeID" value="uid"/>
<module-option name="matchOnUserDN" value="true"/>
<module-option name="roleAttributeID" value="cn"/>
<module-option name="roleAttributeIsDN" value="false"/>
<module-option name="roleRecursion" value="-1"/>
<module-option name="roleFilter" value="(member={1})"/>
<module-option name="allowEmptyPasswords" value="false"/>
<module-option name="Context.REFERRAL" value="follow"/>
<module-option name="throwValidateError" value="true"/>
</login-module>