#1 2012-09-10 12:16:23

Bascy
Member
From: The Netherlands
Registered: 2012-06-22
Posts: 108

AdaptSQLLimitForEngineList() not called when using Client.SetUser

I'm trying to use the Authentication build into mormot, with the AuthGroup and AuthUser tables external in  my own database ..
But calling SetUser results in an error because the LIMIT 1 addition is not corrected by a call to my own implementation of AdaptSQLLimitForEngineList() ..

See callstack below:

SQLite3DB.TSQLRestServerStaticExternal.ExecuteInlined('SELECT RowID,LogonName,DisplayName,PasswordHashHexa,GroupRights FROM AuthUser WHERE LogonName=:(''Guest''): LIMIT 1;',True)
SQLite3DB.TSQLRestServerStaticExternal.EngineList('SELECT RowID,LogonName,DisplayName,PasswordHashHexa,GroupRights FROM AuthUser WHERE LogonName=:(''Guest''): LIMIT 1;',False,nil)
SQLite3Commons.TSQLRestServer.InternalListJSON(TSQLAuthUser,'SELECT RowID,LogonName,DisplayName,PasswordHashHexa,GroupRights FROM AuthUser WHERE LogonName=:(''Guest''): LIMIT 1;')
SQLite3Commons.TSQLRest.Retrieve('LogonName=:(''Guest''):',$2643290)
SQLite3Commons.TSQLRecord.Create($2596260,'LogonName=?',(...))
SQLite3Commons.TSQLRestServer.Auth($18F464)
SQLite3Commons.TSQLRestServer.LaunchCallBack($18F464,'',400)
SQLite3Commons.TSQLRestServer.URI('root/auth?UserName=Guest&Password=2e4a799a589f4381206254b31517a86d5274bb3d39cd60f72c906d90a2bddbdc&ClientNonce=999a42861b620c0ee361d432c044b5bac72d39f6f89474f962a31fc99b3d8077','GET','','','',$99564D)
SQLite3.TSQLRestClientDB.InternalURI('root/auth?UserName=Guest&Password=2e4a799a589f4381206254b31517a86d5274bb3d39cd60f72c906d90a2bddbdc&ClientNonce=999a42861b620c0ee361d432c044b5bac72d39f6f89474f962a31fc99b3d8077','GET',$18F674 {''},$18F578 {''},$18F574 {''})
SQLite3Commons.TSQLRestClientURI.URI('root/auth?UserName=Guest&Password=2e4a799a589f4381206254b31517a86d5274bb3d39cd60f72c906d90a2bddbdc&ClientNonce=999a42861b620c0ee361d432c044b5bac72d39f6f89474f962a31fc99b3d8077','GET',$18F674 {''},nil {''},nil {''})
SQLite3Commons.TSQLRestClientURI.CallBackGet('auth',(...),'',nil,0,nil {''})
SQLite3Commons.TSQLRestClientURI.CallBackGetResult('auth',(...),nil,0)
SQLite3Commons.TSQLRestClientURI.SetUser('Guest','synopse',False)

Offline

#2 2012-09-10 12:40:41

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: AdaptSQLLimitForEngineList() not called when using Client.SetUser

What do you call your "own implementation of AdaptSQLLimitForEngineList()"?

The one included in TSQLRestServerStaticExternal should be enough, right?

Offline

#3 2012-09-10 12:44:02

Bascy
Member
From: The Netherlands
Registered: 2012-06-22
Posts: 108

Re: AdaptSQLLimitForEngineList() not called when using Client.SetUser

But that one isnt called either ...

I have my own implementation in the TSQLDBNexusDBConnectionProperties class, so  I don't have to change any code that is directly delivered by you. This means i have no merging to do when you publish a new version

Last edited by Bascy (2012-09-10 12:46:29)

Offline

#4 2012-09-10 13:43:45

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: AdaptSQLLimitForEngineList() not called when using Client.SetUser

AFAIK TSQLRestServerStaticExternal.AdaptSQLLimitForEngineList is always called, and will redirect to the TSQLDB*ConnectionProperties only for creating the SQL.
Use step-by-step debugging to see what the code does.

Offline

#5 2012-09-10 13:54:11

Bascy
Member
From: The Netherlands
Registered: 2012-06-22
Posts: 108

Re: AdaptSQLLimitForEngineList() not called when using Client.SetUser

As you can see in the Callstack in the initial post, SQLite3Commons.TSQLRestServer.URI() is called, but before it reaches the call to AdaptSQLLimitForEngineList on line 18316 you see a call to SQLite3Commons.TSQLRestServer.LaunchCallBack($18F464,'',400) happening ...

Stepping through the code, the call to LaunchCallBack is made when executing line 18289

      if (Method<>mLOCK) and
          // GET ModelRoot/MethodName + parameters sent in URI
         ((URI.MethodIndex<0) or not LaunchCallBack(URI,Resp,result.Lo)) then

Last edited by Bascy (2012-09-10 14:02:38)

Offline

#6 2012-09-10 14:41:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: AdaptSQLLimitForEngineList() not called when using Client.SetUser

LaunchCallBack is made on purpose: it will call TSQLRestServer.Auth() method.
No problem here.

Within TSQLRestServer.Auth(), there is a request of TSQLRest.Retrieve('LogonName=:(''Guest''):',$2643290)
This will run on the server side directly, so it will call TSQLRestServerStaticExternal.EngineRetrieve() which will execute the statement.

I think there was an issue in this case: calling direct EngineList() will by-pass the AdaptSQLLimitForEngineList() call.

I've added a protected TSQLRestServer.InternalAdaptSQL method, extracted from URI() process to also be called by TSQLRestServer.InternalListJSON() for proper TSQLRestServerStatic.AdaptSQLForEngineList(SQL) call.
See http://synopse.info/fossil/info/c1285b2bee

Should fix the problem.

Offline

Board footer

Powered by FluxBB