我尝试在wildfly 8.2上使用数据库(Postgresql 9.3上的用户/角色)创建简单的基于表单的身份验证。 我的standalone.xml
<security-domain name="other" cache-type="default">
<authentication>
<login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
<module-option name="dsJndiName" value="java:jboss/Test"/>
<module-option name="principalsQuery" value="Select password from myuser where name=?"/>
<module-option name="rolesQuery" value="select role,'Roles' from user_roles wher name=?"/>
<module-option name="password-stacking" value="useFirstPass"/>
<module-option name="unauthenticatedIdentity" value="guest"/>
</login-module>
</authentication>
</security-domain>
我尝试代码=&#34;数据库&#34;但是没有工作,所以我根据你上面的内容改变了它。我还在
中添加了记录器<subsystem xmlns="urn:jboss:domain:logging:2.0">
<logger category="org.jboss.security">
<level name="TRACE"/>
</logger>
我在webapp / WEB-INF / jboss-web.xml中注册了域名并且它是默认的,所以它不应该是一个问题
<jboss-web>
<security-domain>other</security-domain>
</jboss-web>
我的web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>admin</web-resource-name>
<url-pattern>/addBook.html</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>other</realm-name>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/error.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>ADMIN</role-name>
</security-role>
我在login.html中的表单
<form action="j_security_check" method=post>
<strong>Please Enter Your User Name: </strong></br>
<input type="text" name="j_username"></br>
<strong>Please Enter Your Password: </strong></br>
<input type="password" name="j_password"></br></br>
<input type="submit" value="Login!">
<input type="reset" value="Reset">
最后我的2个人
@Entity(name="Myuser")
public class MyUser {
@Id
@NotNull
@Column(name="name", unique=true)
private String userName;
@NotNull
private String password;
@NotNull
private String email;
//... getters etc.
@Table(name="USER_ROLES")
@Entity(name="UserRoles")
public class UserRoles {
@NotNull
@Column(name="role")
String groupName;
@NotNull
@Id
@Column(name="name", unique=true)
String userName;
//...getters etc.
单击Login!后,它将我转到error.html,没有任何反应。记录器没有给我任何线索,0响应。任何想法为什么它不起作用?