title: "Forbidden", cannot authenticate using JAAS (WildFly)
body: <p>I've done it as it is described in all the tutorials.</p>
  
  <ol>
  <li>Add MySql connetion jar as a module to WildFly (mySql-conn-driver.jar)</li>
  </ol>
  
  <p><code>module add --name=com.mysql --resources=/path/to/mysql-connector-java-5.1.24-bin.jar --dependencies=javax.api,javax.transaction.api</code></p>
  
  <p><code>/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-class-name=com.mysql.jdbc.Driver)</code></p>
  
  <ol start="2">
  <li>Added DataSource</li>
  </ol>
  
  <p><code>[standalone@localhost:9990 /] /subsystem=datasources/data-source=niwads:add(
      driver-name=mysql,
      user-name=db_user,
      password=secret,
      connection-url=jdbc:mysql://localhost:3306/appdb,
      min-pool-size=5,
      max-pool-size=15,
      jndi-name=java:/jdbc/niwads,
      enabled=true,
      validate-on-match=true,
      valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker,
      exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter
  )</code></p>
  
  <ol start="3">
  <li><p>Created Security Domain with GUI in Browser, not CLI. With final result was like this:</p>
  
  <pre><code>&lt;security-domain name="niwasdnew" cache-type="default"&gt;
  &lt;authentication&gt;
      &lt;login-module code="Database" flag="required"&gt;
          &lt;module-option name="dsJndiName" value="java:/jbdc/niwads" /&gt; 
          &lt;module-option name="principalsQuery" value="select password as 'Password' from user_account where nickname=?" /&gt;
          &lt;module-option name="rolesQuery" value="select r.rolname as 'Role', r.rolname as 'RoleGroup' from user_account u, role r where r.id=u.role_key and u.nickname=?" /&gt;
      &lt;/login-module&gt;
  &lt;/authentication&gt;
  </code></pre>
  
  <p></p></li>
  <li><p>Created and added <em>jboss-web.xml</em> to WEB-INF:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jboss-web&gt;
          &lt;security-domain&gt;niwasdnew&lt;/security-domain&gt;
  &lt;/jboss-web&gt;
  </code></pre></li>
  <li><p>My <em>web.xml</em> with <em>FORM</em> authentication roles and so so:</p>
  
  <pre><code>&lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;pages for masters&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/sections/master/*&lt;/url-pattern&gt;
          &lt;http-method&gt;GET&lt;/http-method&gt;
          &lt;http-method&gt;POST&lt;/http-method&gt;
       &lt;/web-resource-collection&gt;
      &lt;auth-constraint&gt;
          &lt;role-name&gt;admin&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
  &lt;/security-constraint&gt;
  &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;pages for gardeners&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/sections/gardener/*&lt;/url-pattern&gt;
          &lt;http-method&gt;GET&lt;/http-method&gt;
          &lt;http-method&gt;POST&lt;/http-method&gt;
      &lt;/web-resource-collection&gt;
      &lt;auth-constraint&gt;
          &lt;role-name&gt;gardener&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
  &lt;/security-constraint&gt;
  
  &lt;login-config&gt;
      &lt;auth-method&gt;FORM&lt;/auth-method&gt;
      &lt;form-login-config&gt;
          &lt;form-login-page&gt;/login.xhtml&lt;/form-login-page&gt;
          &lt;form-error-page&gt;/error.xhtml&lt;/form-error-page&gt;
      &lt;/form-login-config&gt;
  &lt;/login-config&gt;
  
  &lt;security-role&gt;
      &lt;role-name&gt;admin&lt;/role-name&gt;
  &lt;/security-role&gt;
  &lt;security-role&gt;
      &lt;role-name&gt;gardener&lt;/role-name&gt;
  &lt;/security-role&gt;
  </code></pre></li>
  </ol>
  
  <p>After all this, I start my project on WildFly, I see my welcome page, go to login page, fill needed fields press Login Button <strong>and it redirects me to appropriate place depend on user's role</strong></p>
  
  <p>BUT I see only the "Forbidden" error page!</p>
  
  <p>What I'm doing wrong? What I've missed?</p>