Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
782 lines (666 sloc) 23.2 KB

OpenAMJS

OpenAMJS is a JavaScript wrapper around the ForgeRock OpenAM REST APIs. Initially it is leveraging the Authentication and SSO API's but it can be extended to cover the whole set of APIs, inclulding Authorization, OAuth2, OIDC, UMA, STS, etc.

This wrapper is not supported nor endorsed by ForgeRock, but the community is welcome to develop it further.

Table of contents

Methods

authenticate(options)

Authenticates an identity using any authentication module The version of the AM should support the /json/authenticate endpoint.

Parameters:
Name Type Description
options Object The configuration object to use
 The options object is a JSON object, here an example.  
 {
    module: "DataStore",                                         // optional
    service: "ldapService",                                      // optional
    realm: "/",                                                  // optional
    headers: "http://ap.example.com:8880/exampleNRO02.html",     // optional
    data: objectData                                             // optional
 }   
Properties
Name Type Attributes Default Description
module String <optional>
OpenAM realm default The Authentication module to use in the left side of the login box.
service String <optional>
OpenAM realm default The Authentication service chain to use in the left side of the login box. Notice that service takes precedence over module.
realm String <optional>
The one configured in openam.js Realm where the authentication will take place
headers Object Object containing the credentials passed as headers
data Object <optional>
{} The payload to be submitted to the authentication module

Source:

authenticateSimple(options)

Authenticates an identity using a one state authentication module by using the values submitted either in the form containing username and password or by using credentials submitted in the headers object. The version of the AM should support the /json/authenticate endpoint. The realm, module or service can be specified but only modules and services with one state are supported.

Parameters:
Name Type Description
options Object The configuration object to use
 The options object is a JSON object, here an example.  
 {
    module: "DataStore",                                         // optional
    service: "ldapService",                                      // optional
    username: 'usernameField',                                   // optional
    password: 'passwordField',                                   // optional
    headers: myHeaders,                                          // optional
    realm: "/",                                                  // optional
    gotoURL: "https://app.example.com:8080/mypath",              // optional
    gotoOnFail: "https://app.example.com:8080/failed",           // optional
 }   
Properties
Name Type Attributes Default Description
module String <optional>
OpenAM realm default The Authentication module to use in the left side of the login box.
service String <optional>
OpenAM realm default The Authentication service chain to use in the left side of the login box. Notice that service takes precedence over module.
username String <optional>
'username' The id of the field that contains the username in the form. Either username and password or headers must be specified.
password String <optional>
'password' The id of the field that contains the password in the form. Either username and password or headers must be specified.
headers Object Object containing the credentials passed as headers
realm String <optional>
The one configured in openam.js Realm where the authentication will take place
headers Object <optional>
Object containing the credentials passed as headers. Either username and password or headers must be specified.
gotoURL String <optional>
Current page The URL to go to after a successful authentication.
gotoOnFail String <optional>
Current page The URL to go to after an authentication event has failed.

Source:

authNRedirect(options)

Redirects for authentication to an OpenAM using the Authentication module specified

Parameters:
Name Type Description
options Object The configuration object to use
 The options object is a JSON object, here an example.  
 {
    openam: myOpenAMConfigObject,
    module: "DataStore",                                         // optional
    service: "ldapService",                                      // optional
    gotoURL: "http://ap.example.com:8880/exampleNRO02.html",     // optional
    gotoOnFail: "http://ap.example.com:8880/exampleNRO02.html",  // optional
    classic: false,                                              // optional
    windowed: true                                               // optional
 }   
Properties
Name Type Attributes Default Description
openam Object | String The OpenAM Configuration Object. This is a mandatory attribute. See openam.js documentation for more information
module String <optional>
OpenAM realm default The Authentication module to use in the left side of the login box.
service String <optional>
OpenAM realm default The Authentication service chain to use in the left side of the login box. Notice that service takes precedence over module.
gotoURL String <optional>
Current page The URL to go to after a successful authentication.
gotoOnFail String <optional>
Current page The URL to go to after an authentication event has failed.
classic String <optional>
false Boolean attribute to specify if we are using the classic UI (true) or the XUI (false). Default is to use the XUI.
windowed String <optional>
true Boolean attribute to specify if the redirect will happen in a pop-up window or not.

Source:

createCookie(name, value, hours, domainName)

Create a Cookie for the domain specified in domainName

Parameters:
Name Type Description
name type Name of the cookie to be created
value type Value for the cookie
hours type Time that the cookie will exist
domainName type Domain in which the cookie will be created

Source:

debug(message) → {undefined}

Displays a message in the browser's console (if possible)

Parameters:
Name Type Description
message type Message to display in the console

Source:

Returns:

Type
undefined

deleteCookie(name, domainName)

Deletes the coookie

Parameters:
Name Type Description
name type Name of the cookie to be deleted
domainName type Domain where the cookie resides

Source:

getCookie(name) → {String}

Get's the value of the cookie specified

Parameters:
Name Type Description
name type The name of the coookie whose value we want to retrieve

Source:

Returns:

The value of the cookie

Type
String

getIdentityAttributes(options) → {JSON}

Obtains the values of the profile attributes specified as a comma separated list

Parameters:
Name Type Description
options Object The configuration object to get the attributes
 The options object is a JSON object, here an example.  
 {
    attributes: "cn, givenName,sn,mail",          
    realm: "/",                          // optional
    prettyprint: true                    // optional
 }   
Properties
Name Type Attributes Default Description
attributes String Comma separated list of attributes
realm String <optional>
The one configured in openam.js Realm where the identity resides.
prettyprint Boolean <optional>
false Return formatted with pretty print(true or false)

Source:

Returns:
  • Returns the value of the profile attributes requested from the OpenAM

Type
JSON

getLocal(storageKey) → {type}

Gets the value stored in the Local session store. Using the key specified by

Parameters:
Name Type Description
storageKey type The key of the value to retrive

Source:

Returns:

data The value of the value retrieved

Type
type

getMyURL() → {String}

Gets the URL of the page running the script

Source:

Returns:

Type
String

getMyURLDir() → {String}

Gets the path/dir of the page running the script

Source:

Returns:

Type
String

isSessionValid(tokenId) → {Boolean}

Checks if the session that the tokenID represents is valid

Parameters:
Name Type Description
tokenId String The SSO Token ID (a.k.a the identifier of the session)

Source:

Returns:
  • True if the session is valid

Type
Boolean

isUserAuthenticated() → {Boolean}

Checks if a user is authenticated

Source:

Returns:
  • True if a user is authenticated

Type
Boolean

logout(optionsopt) → {undefined}

Log out the user from the OpenAM

Parameters:
Name Type Attributes Description
options Object <optional>
The object describing the options for the logout
 The options object is a JSON object, here an example.  
 {
    gotoURL: "https://app.example.com:8080/mypath",              // optional
    gotoOnFail: "https://app.example.com:8080/failed",           // optional
 }   
Properties
Name Type Attributes Default Description
gotoURL String <optional>
Current page The URL to go to after a successful authentication.
gotoOnFail String <optional>
Current page The URL to go to after an authentication event has failed.

Source:

Returns:

Type
undefined

openamConfig(options) → {openamConfig}

OpenAM Configuration instance

Parameters:
Name Type Description
options Object The OpenAM Configuration JSON object.
 Here an example.  
 {
      baseurl: "http://openam1.example.com:8080/openam",
      realm: "/",                                        // optional    
      cachetime: 3,                                      // optional 
      debugenabled: true                                 // optional
 }   
Properties
Name Type Attributes Default Description
baseurl String The URL where OpenAM is running, example: "https://openam.example.com:443/openam"
realm String <optional>
The default realm for the baseurl used Name of the realm to be used, example: "/"
cachetime String <optional>
3 Time in minutes the session valid response and attributes are cached in the session store (if possible). To disable caching set the time to 0. Example of caching for 3 minutes: 3
debugenabled String <optional>
false Enable debug, works for some browser, not for all. Example: true

Source:

Returns:

An instance of the OpenAM Configuration.

Type
openamConfig

removeAlllocal() → {undefined}

Removes the whole local session storage

Source:

Returns:

Type
undefined

storeLocal(storageKey, data)

Stores a value "data" in the key "storageKey" in the local session storage

Parameters:
Name Type Description
storageKey type The key to be used to store the value
data type The value of the data to be stored

Source:

Documentation generated by JSDoc 3.4.0 and converted to markdown with pandoc 1.17.0.3 and some Patience.

You can’t perform that action at this time.