user9321096
user9321096

Reputation:

JBoss EAP 7 Basic Authentication not work

I change my application server to JBoss EAP 7.1 and configure JDBC Realm with this configuration :

# 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>

my web.xml file :

<?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>

my jboss-web.xml file :

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <security-domain>web-security-domain</security-domain>
</jboss-web>

My problem is basic authentication not work with my configuration .
actually firefox web browser don't open authentication popup dialog and only receive :
Internal Server Error

without any error in jboss log ! .
How can fix this problem ?
Thank you .

Upvotes: 0

Views: 2440

Answers (1)

user9321096
user9321096

Reputation:

I Fixed this problem .
In Http Section configuration must be same :

<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>       

Now work without any problem .
Thank you .

Upvotes: 1

Related Questions