#1 2016-08-14 12:17:27

MiniMatrix
Member
Registered: 2016-03-21
Posts: 4

Cannot authenticate from client. Why?

I'm using mORMot on a server and a client. Now I implemented Authentication using TSQLAuthUser und TSQLAuthGroup.
From server side I can access all the users, add or delete them.

Now I liked to use this from client side. On Serverside I created:

  aDB := TSQLRestServerDB.Create( aModel, 
                                                 ChangeFileExt( ExeVersion.ProgramFileName, '.db3' ),
                                                 True );        //Authentication is active

On client side I created:

  aClient:= TSQLRestClientURINamedPipe.Create( aModel,
                                                                  cStrNamedPipeName );
  Result := Assigned( aClient );
  if( Result )
  then Result := aClient.SetUser( sUserName, sPassword );

But the result of aClient.SetUser is always false. I started debugging and found out, that the first IF of "class function TSQLRestServerAuthentication.ClientGetSessionKey" is executed, not the ELSE. The resp of "Sender.CallBackGet('Auth',aNameValueParameters,resp)" includes "Errorcode":403 regardless if I use NamedPipe or HTTP client connection.
What is wrong with my code?

Offline

#2 2016-08-14 13:25:26

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

Re: Cannot authenticate from client. Why?

Please look at the samples, and the doc.

Did you call "CreateMissingTables" to initialize User and Group tables in the SQlite3 database?

Offline

#3 2016-08-17 12:39:15

MiniMatrix
Member
Registered: 2016-03-21
Posts: 4

Re: Cannot authenticate from client. Why?

Yes, AB, I read the fuc.. manual ;-)
Yes, I called "CreateMissingTables". As I wrote, on serverside everthing works fine. I changed the default passwords "synopse" for all std. users (user, admin, supervisor). But regardless of "synopse" or new generated passwords, login (setUser) from client does not work for me using namedpipe or http connection. Everythings seems to be standard as expected.

On server side I recorgnized today two little messages, I do not understand why they occure, because I dont use services until now.

First message is: Exception of class EHTTPApiServer. Message 'HTTPSetServiceConfiguration failed: Access denied (5)

Second message after "continue" is: Exception of class EHTTPServerException. Message 'TSQLHttpServer: http.sys URI registration error #5 for http://+:8080/ (administrator rights needed). Same if I use a root path (http://+:8080/root).

I think, last time these messages arent there (I used today the latest available version from your website/nightlybuild).

Anyway, my basic problem still exists. Which sample shows the server and client side with  authentication using .SetUser(...,...) as you mentioned?

Offline

#4 2016-08-17 13:27:01

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,544
Website

Re: Cannot authenticate from client. Why?

Your URL (http://+:8080/root) is not registered in the HTTP.SYS URLs list.
Read 11.4.2.2. URI authorization as Administrator
In short - run your application ONCE as Administrator or complete the steps from topic 11.4.2.2.3. Manual URI authorization

Last edited by mpv (2016-08-17 13:28:32)

Offline

#5 2016-08-17 15:10:28

MiniMatrix
Member
Registered: 2016-03-21
Posts: 4

Re: Cannot authenticate from client. Why?

Thanx @mpv

Your hint helped to eliminates both error messages. Now my server application did not start, if it is not started with "run as administrator". This should help to prevent this problem in the future.

Offline

#6 2016-08-18 10:21:32

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

Re: Cannot authenticate from client. Why?

Are you sure you are using useHttpApiRegisteringURI?
Are you sure the port or the URI is not already registered by another application?

This is not a framework expectation, but how http.sys works in Windows.
See e.g. https://msdn.microsoft.com/en-us/librar … p/cc307236
and https://msdn.microsoft.com/en-us/librar … p/aa364673

Offline

Board footer

Powered by FluxBB