TokenUtils

TokenUtils{#TokenUtils}

Module with helper functions for the Tokens.

extractServiceTokenFromRequest(request) {#extractServiceTokenFromRequest}⇒ Object

Extracts and decodes a service token from a raw request

Returns: Object - serviceToken - The service token

extractImidTokenFromRequest(request) {#extractImidTokenFromRequest}⇒ String | null

Extracts IMID token from a raw request if present

Returns: String | null - imidToken - The IMID token if present

getSubject(request) {#getSubject}⇒ String

Get the subject from the service token

Returns: String - organization - The subject identifier set on the service token

getOrganization(request) {#getOrganization}⇒ String

Get the subject's organization

Returns: String - organization - The organization the subject belongs to

getUnits(request) {#getUnits}⇒ Array.<String>

Get the subject's mapped units

Returns: Array.<String> - units - An array of all units the subject belongs to

getSelectedUnit(request) {#getSelectedUnit}⇒ null | String

Get the subject's selected unit

Returns: null | String - unit - The subject's selected unit, null if no unit selected

getOrgPermissions(request) {#getOrgPermissions}⇒ Array.<String>

Get the subject's organization permissions

Organization permissions are located under permissions.org

Returns: Array.<String> - } permissions - The subject's org permissions

getUnitPermissions(request, unit) {#getUnitPermissions}⇒ Array.<String>

Get the subject's permissions for the specified unit

Unit permissions are located under permissions.units[unit]

Returns: Array.<String> - permissions - The subject's permissions for the specified unit

isServiceAdmin(request) {#isServiceAdmin}⇒ Boolean

Checks if a token belogs to an admin for the service

Returns: Boolean - isServiceAdmin - True if the token belongs to an admin for the service

getUserinfo(request) {#getUserinfo}⇒ Object

Get the subject's userinfo

Returns: Object - userinfo - The userinfo object set on the subject

Last updated