JBoss Wildfly - database login module -


jboss wildfly 8.0.0-final
jsf 2.2.4

first created login using application-users.properties , application-roles.properties. added user add-user.bat

web.xml

<security-constraint>     <web-resource-collection>         <web-resource-name>admin resource</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>  <login-config>     <auth-method>form</auth-method>     <form-login-config>         <form-login-page>/login.xhtml</form-login-page>         <form-error-page>/error.xhtml</form-error-page>     </form-login-config> </login-config>  <security-role>     <role-name>admin</role-name> </security-role> 

standalone.xml

<login-module code="remoting" flag="optional"> <module-option name="password-stacking" value="usefirstpass"/> </login-module> <login-module code="realmdirect" flag="required"> <module-option name="password-stacking" value="usefirstpass"/> </login-module> 

login.xhtml

    <?xml version="1.0" encoding="utf-8"?> <ui:composition xmlns="http://www.w3.org/1999/xhtml"     xmlns:ui="http://xmlns.jcp.org/jsf/facelets"     xmlns:f="http://xmlns.jcp.org/jsf/core"     xmlns:h="http://xmlns.jcp.org/jsf/html"     xmlns:p="http://primefaces.org/ui">     <div class="center">         <form method="post" action="j_security_check" id="">             <h:panelgrid id="panel" columns="2" border="1" cellpadding="4" cellspacing="4">                 <h:outputlabel for="j_username" value="username:" />                 <input type="text" name="j_username" />                 <h:outputlabel for="j_password" value="password:" />                 <input type="password" name="j_password" />                 <h:panelgroup>                     <input type="submit" value="login" />                 </h:panelgroup>             </h:panelgrid>         </form>     </div> </ui:composition> 

so worked fine.. want use database authentication.. change standalone.xml.

<login-module code="database" flag="sufficient">     <module-option name="dsjndiname" value="java:jboss/jsi/garagexadatasource"/>     <module-option name="principalsquery" value="select encode(password, 'hex') principal username=?"/>     <module-option name="rolesquery" value="select r.role, r.role_group role r inner join principal p on r.role = p.role p.username=?"/>     <module-option name="hashalgorithm" value="sha-512"/>     <module-option name="hashencoding" value="hex"/> </login-module> 

i use sql insert role , user in database ( postgresql 9.3 )

insert role(role, role_group) values ('admin', 'roles');
insert principal(username, email, password, role) values ('kris', 'xx@gmail.com', digest('pass', 'sha512'), 'admin');

but login not work. see no errors in log. have used approach before on 7.1.1 worked.

thanks help.

firstly databaseserverloginmodule logs trace level, should set org.jboss.security log levels trace in standalone.xml follows. should see errors in server.log

<logger category="org.jboss.security">     <level name="trace"/> </logger> 

you need add realm-name within jboss-web.xml

<jboss-web>     <security-domain>java:/jaas/myrealm</security-domain> </jboss-web> 

you have not supplied surrounding tags around login-module configuration snippet. should have below. realm name needs match in web.xml

<subsystem xmlns="urn:jboss:domain:security:1.0">   <security-domains>       <security-domain name="myrealm">          <authentication>            <login-module code="database" flag="required">            ....       </authentication>       </security-domain>     </security-domains>   </subsystem>  

once have done post errors server.log.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -