wildfly13 login-module database $local problem
tbw Jun 7, 2018 2:51 PMProperties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
props.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
props.put(Context.URL_PKG_PREFIXES, "org.wildfly.naming.client.WildFlyInitialContextFactory");
props.put("org.jboss.ejb.client.scoped.context", true);
props.put("jboss.naming.client.ejb.context", true);
props.put("remote.connections", "default");
props.put("remote.connection.default.host", "localhost");
props.put("remote.connection.default.port", "8080");
props.put("remote.connection.default.protocol", "http-remoting");
props.put("remote.connection.default.username", String.valueOf(userId));
props.put("remote.connection.default.password", "123");
context = new InitialContext(props);
<security-domain name="JSsecurity" cache-type="default">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/DS"/>
<module-option name="principalsQuery" value="select key from client where id = cast(? as int)"/>
<module-option name="rolesQuery" value="select role, 'userroles' from userroles where username=?"/>
<module-option name="unauthenticatedIdentity" value="nobody"/>
</login-module>
</authentication>
</security-domain
21:50:07,458 TRACE [org.jboss.security] (default task-2) PBOX00236: Begin initialize method
21:50:07,458 TRACE [org.jboss.security] (default task-2) PBOX00237: Saw unauthenticated indentity: nobody
21:50:07,459 TRACE [org.jboss.security] (default task-2) PBOX00262: Module options [dsJndiName: java:jboss/datasources/DS, principalsQuery: select key from client where id = cast(? as int), rolesQuery: select role, 'userroles' from userroles where username=?, suspendResume: true]
21:50:07,461 TRACE [org.jboss.security] (default task-2) PBOX00240: Begin login method
21:50:07,467 DEBUG [jboss.jdbc.spy] (default task-2) java:jboss/datasources/DS [DataSource] getConnection()
21:50:07,469 TRACE [org.jboss.security] (default task-2) PBOX00263: Executing query select key from client where id = cast(? as int) with username $local
21:50:07,469 DEBUG [jboss.jdbc.spy] (default task-2) java:jboss/datasources/DS [Connection] prepareStatement(select key from client where id = cast(? as int))
21:50:07,471 DEBUG [jboss.jdbc.spy] (default task-2) java:jboss/datasources/DS [PreparedStatement] setString(1, $local)
21:50:07,472 DEBUG [jboss.jdbc.spy] (default task-2) java:jboss/datasources/DS [PreparedStatement] executeQuery()
21:50:07,523 DEBUG [jboss.jdbc.spy] (default task-2) java:jboss/datasources/DS [PreparedStatement] close()
21:50:07,524 DEBUG [jboss.jdbc.spy] (default task-2) java:jboss/datasources/DS [Connection] isClosed()
21:50:07,524 DEBUG [jboss.jdbc.spy] (default task-2) java:jboss/datasources/DS [Connection] close()
I think problem is in "$local", but how to fix this?