Wildfly 11.0.0.Final JAAS Security
bartkrul Mar 21, 2018 8:54 AMHi,
I'm having trouble with authentication using JAAS.
I added the following to my standalone.xml
<security-domain name="SecureDomain" cache-type="default">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:/KwetterDB"/>
<module-option name="principalsQuery" value="select password from kwetter_db.profile where email=?"/>
<module-option name="rolesQuery" value="SELECT role_name FROM kwetter_db.profile_role WHERE profile_id = (SELECT profile_id FROM kwetter_db.profile WHERE email =?)"/>
</login-module>
</authentication>
</security-domain>
My query when executed in mySQL gives the following result (basically it returns ADMIN when executing the query with email2@example.com):
my webxml:
<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">
<display-name>Kwetter REST</display-name>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>SecuredRealm</realm-name>
</login-config>
<!--
<login-config>
<auth-method>FORM</auth-method>
<realm-name>SecuredRealm</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/loginerror.xhtml</form-error-page>
</form-login-config>
</login-config>
-->
<security-role>
<role-name>ADMIN</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>Secure Admin Page</web-resource-name>
<url-pattern>/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>