IDP

IDP

Provides methods to connect to and manage the IDP. It assumes that the user has already been authenticated by the IDP. This will typically have been done by the Apache OIDC module on the server before the page is served.

Dependencies

  • The Keycloak JavaScript adapter must have been loaded from the IDP via a script tag:
<script src="https://idp.leadershipfactor.com/auth/js/keycloak.js"></script>
  • A page must exist at site_root/status/silent-check-sso.html with the following code:
<html>
<body>
<script>
   parent.postMessage(location.href, location.origin);
</script>
</body>
</html>

See Keycloak JavaScript Adapter for details.

Constructor

new IDP(root, realm, client)

Source:
Example
const idp = new IDP("https://idp.leadershipfactor.com", "Company X", "portal1");
Parameters:
Name Type Description
root string

Root URL for the IDP that manages this client

realm string

The name of the IDP realm that controls this client

client string

The name of this "client" i.e. the application or site name as defined on the IDP

Methods

(inner) del(url, data) → {Promise}

Source:

Deletes a resource asynchronously from the IDP via an HTTP DELETE method.

Example
idp.del(`users/${userid}/role-mappings/realm`, [oldRole]).catch(err => console.log(err));
Parameters:
Name Type Description
url string

URL of the endpoint to invoke on the IDP. Omit the root, including its traling slash

data object

Data identifying the resource to be removed

Returns:
Type
Promise

(inner) get(url) → {Promise}

Source:

Fetches a resource asynchronously from the IDP via an HTTP GET method. This is an idempotent method.

Example
idp.get("roles")
   .then(roles => {
      // Do something with roles here
   }
   .catch(err => {
      // Something went wrong
      console.log(err);
   });
Parameters:
Name Type Description
url string

URL of the endpoint to invoke on the IDP. Omit the root, including its traling slash

Returns:
Type
Promise

(inner) post(url, data) → {Promise}

Source:

Creates a new resource asynchronously on the IDP via an HTTP POST method.

Example
idp.post(`users/${userid}/role-mappings/realm`, [newRole]).catch(err => console.log(err));
Parameters:
Name Type Description
url string

URL of the endpoint to invoke on the IDP. Omit the root, including its traling slash

data object

Data to apply as the update

Returns:
Type
Promise

(inner) put(url, data) → {Promise}

Source:

Updates a resource asynchronously on the IDP via an HTTP PUT method. This is an idempotent method.

Example
idp.put(`users/${userid}`, { enabled: true }).catch(err => console.log(err))
Parameters:
Name Type Description
url string

URL of the endpoint to invoke on the IDP. Omit the root, including its traling slash

data object

JSON-encoded data to apply as the update

Returns:
Type
Promise