我将我的应用服务器更改为JBoss EAP 7.1,并使用以下配置配置JDBC Realm:
# In security domains section :
<security-domain name="jdbcdomain" default-realm="jdbc-realm" permission-mapper="default-permission-mapper">
<realm name="jdbc-realm" role-decoder="from-roles-attribute"/>
</security-domain>
# In security realm section :
<jdbc-realm name="jdbc-realm">
<principal-query sql="SELECT PASSWORD FROM USERS WHERE USERNAME = ?" data-source="OracleDS">
<clear-password-mapper password-index="1"/>
</principal-query>
<principal-query sql="select r.rolename from roles r , users u , userrole ur where u.username=? and ur.user_id=u.id and r.id=ur.role_id" data-source="OracleDS">
<attribute-mapping>
<attribute to="roles" index="1"/>
</attribute-mapping>
</principal-query>
</jdbc-realm>
# In http section :
<http-authentication-factory name="http-db-auth" security-domain="jdbcdomain" http-server-mechanism-factory="global"/>
# In Subsystem "urn:jboss:domain:undertow:5.0" section :
<application-security-domains>
<application-security-domain name="web-security-domain" http-authentication-factory="http-db-auth"/>
</application-security-domains>
我的web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<security-role>
<role-name>admin</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>administrator</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
</web-app>
我的jboss-web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>web-security-domain</security-domain>
</jboss-web>
我的问题是基本身份验证无法与我的配置一起使用
实际上 firefox网页浏览器不会打开身份验证弹出对话框并且只会收到:
内部服务器错误
jboss日志中没有任何错误! 。
如何解决这个问题?
谢谢。
答案 0 :(得分:1)
我解决了这个问题 在Http Section中,配置必须相同:
<http-authentication-factory name="http-db-auth" http-server-mechanism-factory="global" security-domain="jdbcdomain">
<mechanism-configuration>
<mechanism mechanism-name="BASIC"/>
</mechanism-configuration>
</http-authentication-factory>
现在没有任何问题 谢谢。