#1 2016-09-28 11:08:28

StxLog
Member
From: France
Registered: 2015-09-14
Posts: 58

Custom authentication

Hi,

I have two mormot servers running currently (let's call them srv1 and srv2), with each having his own User table. I'd like to change that and make Srv2 ask if pair username&password is correct on Srv1.
Right now they both use TSQLRestServerAuthenticationSignedURI as default authenticate scheme.
What is the best (mORMot) way to implement this logic? Should I Inherit from TSQLRestServerAuthenticationSignedURI and just override one or two function, inherit from TSQLRestServerAuthentication as stated in the doc, or other?

Thanks for your time,

Offline

#2 2016-09-28 12:39:37

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

Re: Custom authentication

You can redirect the TSQLAuthUser and TSQLAuthGroup tables to one of the servers, which will actually store the entries.
See http://synopse.info/files/html/api-1.18 … DATACREATE

Offline

#3 2016-09-28 15:22:33

StxLog
Member
From: France
Registered: 2015-09-14
Posts: 58

Re: Custom authentication

Thanks,

but I have a problem with it:
from what I have understood, I have my SRV1 TSQLRestServerDB on localhost:8082 with in his model TSQLUser inheriting from TSQLAuthUser among others TSQLRecord. Everything is working fine the server is running and I can connect to it to query records.
My SRV2 is a TSQLRestServerFullMemory with an empty model, he only handle a few thing. He is the one who need to get TSQLUser from SRV1.
So:

//Init client
fTEST := TSQLHttpClient.Create('localhost', '8084', TSQLModel.Create([TSQLExample1, TSQLUser, TSQLExample2, ...], 'SRV1'));
fTEST.Model.Owner := fTEST;
if not fTEST.ServerTimeStampSynchronize then
      raise Exception.Create('Erreur: Contact');
if not fTEST.SetUser('user', TSQLUser.ComputeHashedPassword('pass'), true) then
      raise Exception.Create('Erreur: Auth');

//Init server
fSRV2 := TSQLRestServerFullMemory.CreateWithOwnModel([], true, 'SRV2');
fSRV2.RemoteDataCreate(TSQLUser, fTEST);
fSRV2.CreateMissingTables;

Now if i execute this, when it come to RemoteDataCreate I have an EModelException "TSQLUser should be part of the TSQLModel 'SRV2'"
And if i set TSQLUser to be part of the model of fSRV2, i have an EORMException "Duplicate TSQLRestServerFullMemory.RemoteDataCreate(TSQLUser)", which make sense.

What did i do wrong? Any hint?


EDIT: In the doc you wrote "The only prerequirement is that all TSQLRecord classes in the main model do exist in the redirected database model."  -> In this context my main model is the empty one (SRV2), and the redirected database model is the one with TSQLUser (SRV1)? So technically they do exists in the redirected database model, doesn't they?

Last edited by StxLog (2016-09-28 15:32:26)

Offline

#4 2016-10-03 11:27:10

StxLog
Member
From: France
Registered: 2015-09-14
Posts: 58

Re: Custom authentication

Hi,

I still cannot figure out how to make RemoteDataCreate to work. But i'm moving on and try with TSQLRestServerRemoteDB:
I have succesfully made it work, i can log in and log out from my client, but if I try MyClient.RetrieveList<TSQLSomething>('...', [...]); he throw me an EAbstractError for the MainEngineList function and indeed she isn't overriden in the TSQLRestServerRemoteDB.
Is this on purpose? Should I make my own implementation? Can i have some advices?

Thanks again

Last edited by StxLog (2016-10-03 11:42:17)

Offline

Board footer

Powered by FluxBB