# AppWebsocket cross-service authentication

The login for appwebsocket connections can be done in two ways.

- Using the service username and password (as done by the PBX).
- Asking the PBX for a login. For that the client user or service needs to have access to the target service, configured in the PBX.

The IAppWebsocketAuthenticator interface is used by IAppWebsocketClient for the latter option.

## File information

File | common/interface/services.h
Classes | IAppWebsocketAuthenticator UAppWebsocketAuthenticator

# Classes

## IAppWebsocketAuthenticator

    class IAppWebsocketAuthenticator {
    public:
        virtual ~IAppWebsocketAuthenticator() {};
        virtual void SetUser(class UAppWebsocketAuthenticator * user) = 0;
        virtual void GetLogin(const char * app, const char * challenge) = 0;
    };

### Overview

The interface provides the GetLogin function for getting a login for the desired service.

### Public functions

SetUser
  Sets the UAppWebsocketAuthenticator object that shall receive the callbacks.

  #### Parameters

  class UAppWebsocketAuthenticator * user | The UAppWebsocketAuthenticator object that shall receive the callbacks.

GetLogin
  Requests an appwebsocket login for a specified app instance. Will result in one of the callbacks defined by UAppWebsocketAuthenticator.

  #### Parameters

  cconst char * app | The SIP URI of the remote app service.
  cconst char * challenge | The challenge specified by the remote app service.

## UAppWebsocketAuthenticator

    class UAppWebsocketAuthenticator {
    public:
        virtual void AppWebsocketAuthenticatorClosed(class IAppWebsocketAuthenticator * authenticator) = 0;
        virtual void AppWebsocketAuthenticatorGetLoginResult(class IAppWebsocketAuthenticator * authenticator,
            const char * domain,
            const char * sip,
            const char * guid,
            const char * dn,
            const char * pbxObj,
            const char * app,
            const char * info,
            const char * digest,
            const char * salt,
            const char * key) = 0;
        virtual void AppWebsocketAuthenticatorGetLoginError(class IAppWebsocketAuthenticator * authenticator) = 0;
    };

### Overview

Base class for applications that use the library.

### Public functions

AppWebsocketAuthenticatorClosed
  The connection used for authentication was closed during the request. Thus the authentication has failed.

  #### Parameters

  class IAppWebsocketAuthenticator * authenticator | A pointer to the source of the callback.

AppWebsocketAuthenticatorGetLoginResult
  The PBX granted access to the remote app instance and returned the given parameters for login.

  #### Parameters

  class IAppWebsocketAuthenticator * authenticator | A pointer to the source of the callback.
  const char * domain | The domain of the client.
  const char * sip | The SIP URI of the client.
  const char * guid | The GUID of the client.
  const char * dn | The display name of the client.
  const char * pbxObj | The name of the PBX object of the remote app instance.
  const char * app | The app name of the remote app instance.
  const char * info | A JSON structure containing additional info about the client.
  const char * digest | The response digest prooving the successful authentication.
  const char * salt | A salt that is used for the encryption of the key parameter.
  const char * key | An encrypted session key for the connection between the client and the remote app service.

  #### Remarks

  All the paramters are protected by the digest. They must not be modified before passing them to the remote app service. Otherwise the authentication will fail.