Project

General

Profile

Custom authentication

Mohamad Nachabe
Added about 2 years ago

Hi,

By referring to tigase's documentation I was able to figure out how to implement custom user authentication for my application. (My purpose is to authenticate users from another database).

I therefore added few lines to my init.properties making it look as follows:

--comp-class-1 = tigase.muc.MUCComponent
--virt-hosts = 192.168.2.121
--user-db-uri = jdbc:mysql://localhost/tigasedb?user=tigase&password=tigase12&autoCreateUser=true
--user-db = mysql
--admins = admin@user-pc
--comp-name-4 = message-archive
--comp-name-3 = proxy
config-type = --gen-config-def
--comp-name-2 = pubsub
--comp-name-1 = muc
--cluster-mode = true
--sm-plugins = +message-archive-xep-0136
--debug = server
--comp-class-4 = tigase.archive.MessageArchiveComponent
--comp-class-3 = tigase.socks5.Socks5ProxyComponent
--comp-class-2 = tigase.pubsub.PubSubComponent
--auth-db = tigase-custom
--auth-db-uri = jdbc:mysql://localhost/drupal?user=tigase&password=tigase12

basic-conf/auth-repo-params/user-login-query={ select username from users where (username = ?) AND (password = ?) }

However I'm unsure if this is the right way to do it because I'm getting the following exception:

2017-01-26 15:15:19.468 [main]             ConfiguratorAbstract.setProperties()  SEVERE: Can't initialize auth default repository: 
tigase.db.DBInitException: Problem initializing jdbc connection: jdbc:mysql://localhost/drupal?user=tigase&password=tigase12
    at tigase.db.jdbc.TigaseCustomAuth.initRepository(TigaseCustomAuth.java:583)
    at tigase.db.RepositoryFactory.getAuthRepository(RepositoryFactory.java:387)
    at tigase.conf.ConfiguratorAbstract.addAuthRepo(ConfiguratorAbstract.java:857)
    at tigase.conf.ConfiguratorAbstract.setProperties(ConfiguratorAbstract.java:834)
    at tigase.conf.ConfiguratorAbstract.setup(ConfiguratorAbstract.java:519)
    at tigase.conf.ConfiguratorAbstract.componentAdded(ConfiguratorAbstract.java:152)
    at tigase.conf.Configurator.componentAdded(Configurator.java:50)
    at tigase.conf.ConfiguratorAbstract.componentAdded(ConfiguratorAbstract.java:1)
    at tigase.server.AbstractComponentRegistrator.addComponent(AbstractComponentRegistrator.java:116)
    at tigase.server.MessageRouter.addRegistrator(MessageRouter.java:138)
    at tigase.server.MessageRouter.setConfig(MessageRouter.java:644)
    at tigase.server.XMPPServer.start(XMPPServer.java:142)
    at tigase.server.XMPPServer.main(XMPPServer.java:112)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: FUNCTION TigInitdb does not exist
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.Util.getInstance(Util.java:381)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1383)
    at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1581)
    at com.mysql.jdbc.DatabaseMetaData.getProcedureOrFunctionColumns(DatabaseMetaData.java:4120)
    at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:4057)
    at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:809)
    at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:609)
    at com.mysql.jdbc.JDBC4CallableStatement.<init>(JDBC4CallableStatement.java:46)
    at sun.reflect.GeneratedConstructorAccessor16.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.CallableStatement.getInstance(CallableStatement.java:505)
    at com.mysql.jdbc.ConnectionImpl.parseCallableStatement(ConnectionImpl.java:3881)
    at com.mysql.jdbc.ConnectionImpl.prepareCall(ConnectionImpl.java:3965)
    at com.mysql.jdbc.ConnectionImpl.prepareCall(ConnectionImpl.java:3939)
    at tigase.db.jdbc.DataRepositoryImpl.prepareQuery(DataRepositoryImpl.java:463)
    at tigase.db.jdbc.DataRepositoryImpl.initStatement(DataRepositoryImpl.java:410)
    at tigase.db.jdbc.DataRepositoryImpl.initPreparedStatement(DataRepositoryImpl.java:206)
    at tigase.db.DataRepositoryPool.initPreparedStatement(DataRepositoryPool.java:174)
    at tigase.db.jdbc.TigaseCustomAuth.initRepository(TigaseCustomAuth.java:499)
    at tigase.db.RepositoryFactory.getAuthRepository(RepositoryFactory.java:387)
    at tigase.conf.ConfiguratorAbstract.addAuthRepo(ConfiguratorAbstract.java:857)
    at tigase.conf.ConfiguratorAbstract.setProperties(ConfiguratorAbstract.java:834)
    at tigase.conf.ConfiguratorAbstract.setup(ConfiguratorAbstract.java:519)
    at tigase.conf.ConfiguratorAbstract.componentAdded(ConfiguratorAbstract.java:152)
    at tigase.conf.Configurator.componentAdded(Configurator.java:50)
    at tigase.conf.ConfiguratorAbstract.componentAdded(ConfiguratorAbstract.java:1)
    at tigase.server.AbstractComponentRegistrator.addComponent(AbstractComponentRegistrator.java:116)
    at tigase.server.MessageRouter.addRegistrator(MessageRouter.java:138)
    at tigase.server.MessageRouter.setConfig(MessageRouter.java:644)
    at tigase.server.XMPPServer.start(XMPPServer.java:142)
    at tigase.server.XMPPServer.main(XMPPServer.java:112)

Thanks


Replies (1)

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam about 2 years ago

I think you followed proper way, however you need to either:

  • added to this authentication database in your case drupal database other functions/procedures which are used by @TigaseCustomAuth@, or

  • set SQL statements which will replace each of SQL queries done on autentication database by TigaseCustomAuth

    (1-1/1)