Session HttpApi

Hello

The sample project is attached: HttpAPI_Session.zip (58.9 KB)

As you can see it defines an API method in a service marked with the ServiceRequiresLogin attribute and 2 methods for login and logiut in the LoginService. Note that there is a separate Login method defined for API that returns an access token instead of a boolean value.

The authentication manager is added to the server as simple as

		// Usual initialization
		var dispatcher = new HttpApiDispatcher();
		dispatcher.ApiHost = "localhost:8099";
		dispatcher.Server = server.NetworkServer.ServerChannel as IHttpServer;

		// Login processing
		var authenticationManager = new ApiSimpleAuthenticationManager();
		dispatcher.AuthenticationManager = authenticationManager;

Here’s this server in action. For a just-started service an attempt to access the protected method will fail:

Then we perform a login operation:

After that the server method will become accessible:

Also it is possible to perform log out: