SSOToken Class. Used as an interface to decode the Staffbase SSO Token.
Kind: global class
- SSOToken
- new SSOToken(audience, appSecret, tokenData)
- .getTokenData() ⇒ SSOTokenData
Create an instance of SSOToken to parse signed token data received from StaffBase backend.
Param | Type | Description |
---|---|---|
audience | String | Audience param of jwt. This is the your plugin ID registered in StaffBase servers |
appSecret | String | App Secret used to decode the token data |
tokenData | String | Signed Token Data to be decoded |
Get TokenData Object parsed by the SSOToken class.
Kind: instance method of SSOToken
Returns: SSOTokenData - a TokenData object which can be used to get SSO Token inforamtion.
SSOTokenData Class used to host the token data values and provide getter functions to extract correspinding values.
Kind: global class
- SSOTokenData : SSOTokenData
- new SSOTokenData(tokenVals)
- .getSigned(secret, cb) ⇒ String
- ._getSignedWrong(secret, cb) ⇒ String
- .toJSObj() ⇒ Object
- .toJSObjPretty() ⇒ Object
- ._getClaim(claimName) ⇒ String ⎮ number ⎮ null
- .getBranchId() ⇒ null ⎮ string
- .getBranchSlug() ⇒ null ⎮ string
- .getAudience() ⇒ null ⎮ string
- .getExpireAtTime() ⇒ number
- .getNotBeforeTime() ⇒ number
- .getIssuedAtTime() ⇒ number
- .getIssuer() ⇒ null ⎮ string
- .getInstanceId() ⇒ string
- .getInstanceName() ⇒ null ⎮ string
- .getUserId() ⇒ null ⎮ string
- .getUserExternalId() ⇒ null ⎮ string
- .getUserUsername() ⇒ null ⎮ string
- .getUserPrimaryEmailAddress() ⇒ null ⎮ string
- .getFullName() ⇒ null ⎮ string
- .getFirstName() ⇒ null ⎮ string
- .getLastName() ⇒ null ⎮ string
- .getRole() ⇒ null ⎮ string
- .getType() ⇒ null ⎮ string
- .getThemeTextColor() ⇒ null ⎮ string
- .getThemeBackgroundColor() ⇒ null ⎮ string
- .getLocale() ⇒ null ⎮ string
- .isEditor() ⇒ boolean
- .getTags() ⇒ Array.
SSO Token Data
Param | Type | Description |
---|---|---|
tokenVals | Object | TokenVals object wit keys representing possible SSO token values. |
Get signed string representation of the token data
Kind: instance method of SSOTokenData
Returns: String - Signed representation of the token data. Returns
if no callback is specified.
Param | Type | Description |
---|---|---|
secret | String | The Secret to be used for signing the token. The supported algorithm is RS256 so it is important that the secret is read from a private key file. |
cb | function | Optional callback function to get the signed data in a callback pattern. |
Get a wrong signed string representation of the token data with a non supported (by Staffbase) Algotirhm. (Private). Used for tests
Kind: instance method of SSOTokenData
Returns: String - Signed representation of the token data. Returns
if no callback is specified.
Param | Type | Description |
---|---|---|
secret | String | The Secret to be used for signing the token |
cb | function | Optional callback function to get the signed data in a callback pattern. |
Convert Token Data to an internally used keys for Claims
Kind: instance method of SSOTokenData
Returns: Object - With internally represented values for the jwt
Convert Token Data to a CLAIM Represented JS Object
Kind: instance method of SSOTokenData
Returns: Object - with possible Claim Values.
Internally used to get value against the client param string.
Kind: instance method of SSOTokenData
Returns: String ⎮ number ⎮ null - The correspinding value of the Specified claim name.
Param | Type | Description |
---|---|---|
claimName | String | The claim name as defined in the tokenDataConsts |
Get the branch ID for which the token was issued.
Kind: instance method of SSOTokenData
Get the branch slug for which the token was issued.
Kind: instance method of SSOTokenData
Get targeted audience of the token.
Kind: instance method of SSOTokenData
Get the time when the token expires.
Kind: instance method of SSOTokenData
Get the time when the token starts to be valid.
Kind: instance method of SSOTokenData
Get the time when the token was issued.
Kind: instance method of SSOTokenData
Get issuer of the token.
Kind: instance method of SSOTokenData
Get the (plugin) instance id for which the token was issued.
The id will always be present.
Kind: instance method of SSOTokenData
Get the (plugin) instance name for which the token was issued.
Kind: instance method of SSOTokenData
Get the id of the authenticated user.
Kind: instance method of SSOTokenData
Get the id of the user in an external system.
Example use case would be to map user from an external store to the entry defined in the token.
Kind: instance method of SSOTokenData
Get the username of the user accessing.
Kind: instance method of SSOTokenData
Get the primary email address of the user accessing.
Kind: instance method of SSOTokenData
Get either the combined name of the user or the name of the token.
Kind: instance method of SSOTokenData
Get the first name of the user accessing.
Kind: instance method of SSOTokenData
Get the last name of the user accessing.
Kind: instance method of SSOTokenData
Get the role of the accessing user.
If this is set to “editor”, the requesting user may manage the contents of the plugin instance, i.e. she has administration rights. The type of the accessing entity can be either a “user” or a “editor”.
Kind: instance method of SSOTokenData
Get the type of the token.
The type of the accessing entity can be either a “user” or a “token”.
Kind: instance method of SSOTokenData
Get text color used in the overall theme for this audience.
The color is represented as a CSS-HEX code.
Kind: instance method of SSOTokenData
Get background color used in the overall theme for this audience.
The color is represented as a CSS-HEX code.
Kind: instance method of SSOTokenData
Get the locale of the requesting user in the format of language tags.
Kind: instance method of SSOTokenData
Check if the user is an editor.
The user will always have a user role to prevent a bug class on missing values. Only when the editor role is explicitly provided the user will be marked as editor.
Kind: instance method of SSOTokenData
Get User Tags
Kind: instance method of SSOTokenData
Returns: Array. - A String array containing user tags.
Mountable express middleware functions
Kind: global function
Returns: function - Calls the next() handler in the roule handlers chain
Param | Type | Description |
---|---|---|
secret | string | The secret public provided by StaffBase |
audience | String | Audience parma of jwt. This is the your plugin ID registered in StaffBase servers |
Reads public key file from the specified path and returns a string representation of the key to be used to decode token.
Kind: global function
Returns: String - String representation of the key file
Param | Type | Description |
---|---|---|
path | String | The path of the private key file. |
cb | function | Optional callback function to use this in an async way |
asCert converts a binary encoded key to PKCS8 format
Kind: global function
Returns: string - the PKCS8 representation of the key
Param | Type | Default | Description |
---|---|---|---|
cert | string | the binary endoded key string | |
type | string | "PUBLIC KEY" |
the type of key 'PUBLIC KEY' |
Checks if the format of the key is similar to PKCS8 Format.
Kind: global function
Returns: Boolean - true if its similat to PKCS8 otherwise false.
Param | Type | Default | Description |
---|---|---|---|
key | String | The public key file string. | |
type | String | PUBLIC KEY |
the type of key 'PUBLIC KEY' |
Transforms the provided key to PKCS8 format for supported jwt algorithm.
Kind: global function
Returns: String - The public key in PKCS8 format.
Param | Type | Default | Description |
---|---|---|---|
key | String | The public key file string. | |
type | String | PUBLIC KEY |
the type of key 'PUBLIC KEY' |