Home

IdmAuthFlows.js

cordova-plugin-oracle-idm-auth is a plugin that provides authentication and authorization functionality for cordova based mobile applications, supporting standard protocols for remote authentication such as Basic Auth, OAuth, OpenID Connect and webSSO / Federated auth. The plugin also supports local device level authentication such as PIN and biometric based. The plugin abstracts all aspects of authentication and authorization and enforces security best practices for mobile application developers. Typically an app will use a single remote authentication and possibly local authentication. But the plugin can handle multiple authentication flows in parallel, be it remote or local. The APIs of this plugin are exposed through an object IdmAuthFlows in cordova.plugins namespace. All objects in this documentation be it in "Global" or "Classes" are part of this object. They have to be accessed as cordova.plugins.IdmAuthFlows.<Class> or cordova.plugins.IdmAuthFlows.<Object>.

Usage of this plugin:

Create authentication properties object for the type of authentication to be performed. Use one of the builders for this:

Init the authentication flow using properties. The promise resolves with an object which is subclass of AuthenticationFlow. Preserve this object for further operations.

AuthenticationFlow can be used for performing operations such as login, logout etc. Depending on the type of authentication used, the object returned can be of these types. These support operations specific to the authentication used.

Sample usage:

 // Preserve this authentication flow object to interact with the particular flow.
 var authFlow;

// The plugin will be available in onDeviceReady or an equivalent callback // which is executed after the application is loaded by the device. document.addEventListener("deviceready", onDeviceReady); function onDeviceReady() { // Create the authentication properties var authProperties = cordova.plugins.IdmAuthFlows.newHttpBasicAuthPropertiesBuilder(...).build();

var authPromise = cordova.plugins.IdmAuthFlows.init(authProperties); authPromise.then(function(flow) { authFlow = flow; }); }

// Do login. var loginPromise = authFlow.login(); loginPromise.then(function(resp) { // Perform after login tasks. })

// Retrieve headers - If applicable for the auth type. var getHeadersPromise = authFlow.getHeaders(options); getHeadersPromise.then(function(headers) { // Use headers for setting appropriate headers for performing an XHR request. });

// Find our use's authentication status. var isAuthenticatedPromise = authFlow.isAuthenticated(options); isAuthenticatedPromise.then(function(authenticated) { // Use headers for setting appropriate headers for performing an XHR request. });

// Logout from a particular authentication flow. var logoutPromise = authFlow.logout(); logoutPromise.then(function(resp) { // Do after logout tasks });

Source: