#1 2018-11-12 11:48:47

Daniel
Member
Registered: 2016-12-08
Posts: 23

Minimal SessionID implementation

Hello,

I'm planning to use Mormot in scenario similar to the chat demo 31. Clients send messages and Server should send it to all other clients.
So basically the only thing I need to do is make sure I don't send the message back to same client that sent it.

I suppose to do this I have to identify sessions, but I don't want full fledged authentication system, I only want each connection to get unique SessionID.
How would I go about doing this ?

Offline

#2 2018-11-12 13:59:47

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

Re: Minimal SessionID implementation

You can use the TSQLRestURIParams.LowLevelConnectionID value, to be retrieved from TSQLRestServerURIContext.Call.

Offline

#3 2018-11-21 20:40:24

JD
Member
Registered: 2015-08-20
Posts: 118

Re: Minimal SessionID implementation

Hi there ab,

I am interested in this also. How do I implement it? I am not using any authentication at all and my REST server is a memory server like this

fModel     := TSQLModel.Create([], ROOT_NAME);
fRestServer := TSQLRestServerFullMemory.Create(fModel, false);

In addition, my interface methods have the following format:

function TRESTMethods.Partenaires(ID, List, DTO, Mfd, ContentType: RawUTF8): RawJSON;
var
  Res: ISQLDBRows;
  aObj: TSQLPartenaire;
  Ctxt: TServiceRunningContext;
begin
  Result := '';
  //
  if aServer.fDBProps = nil then
    raise Exception.Create(SQLCONNECTIONINACTIVE);
  // Set the current service context
  Ctxt := CurrentServiceContext;
  // Get/set the parameter values
  UrlDecodeValue(Ctxt.Request.Parameters, 'id=', ID);
  UrlDecodeValue(Ctxt.Request.Parameters, 'list=', List);
  if List = EmptyStr
    then List := 'Y';
  UrlDecodeValue(Ctxt.Request.Parameters, 'dto=', DTO);
  UrlDecodeValue(Ctxt.Request.Parameters, 'mfd=', Mfd);  
  if Mfd = EmptyStr
    then Mfd := 'Non';

  // REST OF THE CODE HERE
end;

Thanks a lot in advance.

JD

Last edited by JD (2018-11-21 20:41:59)

Offline

#4 2018-11-22 09:19:50

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

Re: Minimal SessionID implementation

Why are you marshaling by hand the parameters?

Offline

#5 2018-11-22 12:52:44

JD
Member
Registered: 2015-08-20
Posts: 118

Re: Minimal SessionID implementation

ab wrote:

Why are you marshaling by hand the parameters?

Because at one time, the values sent by the client did not seem to be getting to the server. Why? I don't know. So I inserted all the UrlDecodeValue code to test it and I kind of left it like that. It works OK now though.

JD

Last edited by JD (2018-11-22 12:53:43)

Offline

Board footer

Powered by FluxBB