Authentication Token requirements for SSO with HI application
Token Format: Company=<tenant_name>|username=<username>|role=<role1,role2..>|profilename1=<profilevalue1,profilevalue2>|profilename2=<profilevalue3,profilevalue4>expTime=<timestamp>
Company=<organization_name>|username=<username>|role=<role1,role2..> |expTime=<timestamp>
Token mainly comprises of 5 parts separated by a “|” (pipe separator).
Token Encryption
Token generated in the given format, has to be encrypted to make it secure.
Chosen Encryption Algorithm details:
- Algorithm – AES
- Mode – ECB
- Padding – PKCS5Padding
- Secret Key – HSpnzzfCLqrBn8Lk(This is the secret key which is shared between the encryptor and the decryptor applications)
- Encrypted token is Base64 URL Safe encoded
Encryption logic used (java code snippet)
key = "HSpnzzfCLqrBn8Lk"; algorithm = "AES"; mode = "ECB"; padding = "PKCS5Padding"; Cipher cipher = Cipher.getInstance(algorithm + "/" + mode + "/" + padding); SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), algorithm); cipher.init(1, secretKey); return Base64.encodeBase64URLSafeString(cipher.doFinal(strToEncrypt.getBytes()));
Token Samples for Testing
Below are few tokens and its encrypted form (using the shared secret key). This is to enable you to test your token generation and encryption logic. If the below tokens, when encrypted from your ruby code, match the provided encrypted values, it will mean that those tokens will get successfully decoded on the reporting application(Helical Insights) side.
Additional Information about the SSO Token
- username – loggedInUsername (mandatory parameter in the token)
- At present,
- if a Company is not provided in the token, a user will be created in the organization mentioned in the properties file (Default Value)
- if the Company is present, a Company will be created in the DB, by default ROLE_USER mapped with given Company name and user will be created in that Company (organization) and ROLE_USER will be assigned to that user
- we can assign multiple roles separated by a comma. By default ROLE_USER will be assigned to loggedInUser
- expTime –
- Optional parameter in the token
- If provided in the token, the token will be valid up to the date and time provided
- If the zone is not provided in the token, by default it will take IST timezone (IST)
Note: After encrypting the token, it needs to be appended with Helical Insight URL, as shown in below example:
Application URL -> http://localhost:8085/hi-ee/
Encrypted_Token->fK2Nhi2JeqjcxJgOGBYKYLxYClDWRd5ysz6WWyyULIepW5kgZ7oFgoQB6PFTVHB9P3Iod6IBobUGcoVXIhh_Mg782DNbmtVbaGEjpnBS6no
Concatednated_URL:http://localhost:8085/hi-ee/hi.html?authToken=fK2Nhi2JeqjcxJgOGBYKYLxYClDWRd5ysz6WWyyULIepW5kgZ7oFgoQB6PFTVHB9P3Iod6IBobUGcoVXIhh_Mg782DNbmtVbaGEjpnBS6no