1
votes

I am working on a Datasnap server with multiple ServerMethods classes. These are then exposed via HTTP/S etc via TDSHTTPService as normal. I'm now trying to implement distinct authentication appropriate to each service area/context/realm. This appears as though it should be possible using the "Context" parameter in the Datasnap TDSAuthenticationManager OnUserAuthenticate event to vary the authentication check employed. However I'm running into problems:

What I've tried:

1) Changed the client side TSQLConnection.Driver.DatasnapContext from "datasnap" to "datasnaptest", and changed the corresponding server side TDSHTTPService.DSContext from "datasnap/" to "datasnaptest/". Attempting to connect succeeds but in the OnUserAuthenticate event the "Context" parameter is empty. Consequently I tried the following:

2) Changed the client side TSQLConnection.Driver.DatasnapContext from "datasnap" to e.g. "datasnap/test", and changed the corresponding server side TDSHTTPService.DSContext from "datasnap/" to "datasnap/test/". Attempting to then connect fails with 'HTTP/1.1 404 Expected datasnap context in request /datasnap/test/tunnel'.

3) Reverted the TSQLConnection.Driver.DatasnapContext and then changed the client side TSQLConnection.Driver.URLPath from "" to "test", and correspondingly changed the server side TDSHTTPService.DSContext to 'test/datasnap/'. Attepmting to then connect similarly fails with 'HTTP/1.1 404 Expected datasnap context in request /test/datasnap/tunnel.'

In short: How does one correctly manage different authentications (related to different/multiple server classes, and therefore exposed under different URLs/Realms from HTTP) in a Delphi 10 Seattle Datasnap server?

Futher background: We have several app servers and web services/interfaces (Webbroker/SOAP and old school datasnap) which we want to unify/modernize under the new style datasnap framework.

1

1 Answers

0
votes

It may be that you can't (or shouldn't) change the 'datasnap' context. It may be that the context parameter to the OnUserAuthenticate event handler wasn't meant to be used that way.

However:

It seems to me you can get along just fine without it by using Custom Attributes, and Authorized and Denied Roles.

Have a look at Bob Swart's tutorial videos (and whitepapers), specifically DataSnap in Action 2 - DataSnap Server Security This will get you on the right track insofar as authentication and authorization is concerned.