#1 2015-03-11 00:40:32

BBackSoon
Member
Registered: 2014-11-15
Posts: 41

Custom REST server authentication method

Hello,

I am trying to build my own custom authentication method for my REST server.

I have created my own class (TSQLRestServerAuthenticationHttpToken) derived from yours, and on the server side I register it like this:

  Model:=TSQLModel.Create([Tc2dAuthUser,TSQLauthGroup]);
 // create the main mORMot server
 RestSrv:=TSQLRestServerDB.Create(Model,':memory:',false); // authentication=false

 try
  RestSrv.CreateMissingTables; // create tables or fields if missing
  restSrv.AuthenticationRegister(TSQLRestServerAuthenticationHttpToken);

But on the client side I doesn't seem to be able to specify which auth scheme the server is expected to use. In fact:

  amodel := TSQLModel.Create([TSQLAuthUser],collname);

  aClient := TSQLHttpClientWinHTTP.Create(addr,SERVER_PORT,aModel,false);
  aclient.AuthScheme  //// this one can only be one of the schemes defined by you

  if not aClient.SetUser('Admin','synopse',false) then

In fact the AuthScheme property can only be:

THttpRequestAuthentication = (wraNone,wraBasic,wraDigest,wraNegotiate);

And then based upon the value given to AuthScheme you pick one of your pre-defined auth schemes for the client side.
How can I tell the client to use my own auth scheme on the client side?

Thank you.

Offline

#2 2015-03-11 04:16:26

EgorovAlex
Member
Registered: 2015-02-18
Posts: 43

Re: Custom REST server authentication method

Try this:

TSQLRestServerAuthenticationHttpToken.ClientSetUser(aClient, 'login', 'password');

Offline

Board footer

Powered by FluxBB