1. Home
  2. Kore.ai Conversational Platform
  3. Advanced Topics
  4. Bot SDKs
  5. SDK Security

SDK Security

The Kore.ai Bots Platform only accepts clients that are authorized to connect and exchange messages. You must register your SDK app with the Kore.ai Bots Platform in the Bot Builder tool and acquire client credentials. You can then use your client credentials to authorize the app and communication exchange between your user, bot, and the Bots Platform.

Securing Your SDKs

Using Kore.ai SDKs, you can create secure interactions with the Kore.ai Bots Platform.

Kore.ai SDK libraries can be embedded with web or mobile applications to make HTTPS calls and establish web socket connections with the Kore.ai Bots Platform on behalf of a user of your application chatting with a Kore.ai bot.

To establish identity and initiate a secure web session:

  • Your application SDK should sign and send the identity of the user to the Kore.ai Bots Platform
  • The Kore.ai Bots platform verifies the signature to establish trust with your application using:
    • JSON Web Token (JWT) – Used to send the user identity to Kore.ai Bots Platform
    • Bearer Token – Your application SDK exchanges the JWT for a bearer token used for subsequent calls

About JWT

Kore.ai uses the JWT (JSON Web Token) mechanism to handle the authentication.

JWT Flow

The following diagram depicts a typical JWT flow in Kore.ai Bots Platform.

JWT Tokens

JSON Web Tokens consist of three parts separated by dots ” .  ” as:

  • Header
  • Payload
  • Signature

using the hhhhh.ppppp.sssss syntax where h represents the header, p the payload, and s representing the signature.

JWT Header

The JWT Header defines the token type, which is JWT, and the security algorithm, for example,

{
   "alg": "HS256",
   "typ": "JWT"
}

The JWT type can be one of:

  • HS256 (HMAC with SHA-256) – This algorithm uses a Secret Key to sign the token. The Secret Key is generated when the app is registered in Bot Builder when defining the Web/Mobile Client channel for your bot.
  • RS256 (RSA signature with SHA-256) – This is an RSA public/private key based algorithm to sign and verify the token. The client Public Key is defined when the app is registered in the Bot Builder tool on the Kore.ai Platform. The client app signs the token using a Private Key, and the Kore.ai Bots Platform verifies this token using the Public Key.

To use these JWT types for your bot, you need to register your application and select the algorithm type. For more information, see Registering an Application. For more information about using JWT, see  https://tools.ietf.org/html/rfc7519 and https://jwt.io/introduction/.

JWT Payload

The SDK client needs to assert the user by generating unique JSON Web Token using your app registration credentials created in Bot Builder when you defined the Web/Mobile Client channel for your bot and the identity of your app user. The following example shows a sample payload used to generate the JWT.

Sample Header

{
    "alg": "RS256",
    "typ": "JWT"
}

Sample Payload

{
    "iat": 1466684723,
    "exp": 1466684783,
    "aud": "https://idproxy.kore.ai/authorize",
}

The following table describes the parameters for the JWT Header and Payload.

ParameterDescriptionType
algA drop-down list of security algorithms. One of:

  • RS256 - Select to enable the Public Key field. The Public Key is used by the Kore.ai Bots Platform to authenticate the client application.

  • HS256 - Select to generate a Secret Key, and a Client ID. The Client ID is required for SDK initialization, and the Secret Key used by the Kore.ai Bots Platform to authenticate the client application.

string
typThe token type. For JSON Web Token, enter JWT.string
iatThe date/time that the token was issued in milliseconds timestamp format.integer
exp The date/time that the token expires in in milliseconds timestamp format.integer
audThe audience that the token is intended for. For Kore.ai, the audience is https://idproxy.kore.com/authorize.string
issThe ClientID of the client application. The ClientID is generated when the app is registered in the Kore.ai Bot Builder.string
subThe token subject which is represented by the email ID or phone number for users who are logged in the client application system. For anonymous users, the client app can generate a unique random ID and assign that ID to this field.string
isAnonymousWhen set to true, the user is an anonymous user for the client application system. Anonymous users are not persisted on the Kore.ai Platform. Default setting is false.boolean

Hosting the JWT Generation Web Service

The Kore.ai SDK libraries and UI widgets are integrated directly into your client applications, and you will need to generate the JWT from your server.

  • For the Web SDK, the SDK libraries are run from the user’s browser.
  • For mobile SDKs, the SDK libraries are run from a user’s mobile phone.

You need to host the JWT generation as a REST web service for security because the Client Secret or RSA Private Key is required for JWT generation and should not be hosted at the client application. You can make the REST web service directly available to SDK libraries or have your application call the JWT generation web service at the backend to make the JWT available to the SDK libraries.

When making the JWT generation web service available to the SDK libraries, you should keep the Client ID, Client Secret, and any key expiration logic on the server-side and expect only the user ID from the client.

There are several open source libraries available to generate JWT, for example,

Next Steps

To generate credentials for your clients, you must register your client app in the Bot Builder tool. For more information, see SDK App Registration.

You can also try out our tutorial using a Kore.ai sample bot, a test application, and configuring your localhost server for JWT generation. For more information, see the Kore.ai Web SDK Tutorial.

Was this article helpful to you? Yes No