Building the JWT response
When it receives a JWT authentication request, your application must generate a JWT response. The response should include a HS256-signed token containing these fields:
iat: The integer time the response was created in seconds since the Unix epoch.
jti: A randomly created token that uniquely identifies this response.
first_name: The first name of the user that was authenticated.
last_name: The last name of the user that was authenticated.
email: The email address of the user that was authenticated.
The name and email fields are not used by the knowledge base, so any values can be used in these fields.
Here is sample Ruby code to generate the JWT payload which is signed and base 64 encoded:
iat = Time.now.utc.to_i
jti = "#{iat}/#{rand(36**64).to_s(36)}"
payload = JWT.encode(
{
iat: iat,
jti: jti,
first_name: "John",
last_name: "Doe",
email: "john.doe@aha.io",
},
secret_key)
An example JWT input looks like this. Note that the iat is a number and the other fields are strings:
{ "iat": 158258345634, "jti": "1234567890abcdefg", "first_name": "John", "last_name": "Doe", "email": "john.doe@aha.io" }
The URL the user should be redirected back to for login will look like this:
https://#{account_domain}.identity.aha.io/idea_portal_provider/jwt_callback/123456?jwt=#{payload}&state=#{state}
If the request contains state query parameter then the value of that parameter should also be included in the redirect. The state query parameter ensures the user is redirected back to the correct knowledge base.
Top