HPCloud-JS

API Docs for: 1.0.0
Show:

IdentityServices Class

Module: hpcloud

Interact with Identity Services (a.k.a. Keystone) for authentication, obtaining the service catalog, etc.

Constructor

IdentityServices

(
  • endpoint
)

Parameters:

  • endpoint String

    An identity services url endpoint.

Methods

$basicHeaders

() Object private

The basic headers to use when making calls.

This is an internal method that should not be called by other methods.

Returns:

Object: An object with the basic headers.

$request

(
  • opts
  • body
  • fn
)
private async

Do an identity request.

This is an internal method that should not be called by other methods.

Parameters:

  • opts Object

    An object with the opts to pass to the transport layer.

  • body String

    The body of the request. If JSON than in string form.

  • fn Function

    A callback function to execute after the request. The callback accepts two params. The first is error and contains the error if there is one. If the request was successful the first param is false and the second param is an Identity object.

$tenant

(
  • obj
)
private

Attach a tenant to an object. This is a helper method used when authenticating.

This is an internal method that should not be called by other methods.

Parameters:

  • obj Object

    The object to attach tenant information to.

authenticate

(
  • options
  • fn
)
async

Authenticate to a server.

This is a raw authentication method. It users ONLY the options passed in to authenticate.

The autheticateAs* methods are recommended.

Parameters:

  • options Object

    The options to use when authenticating.

  • fn Function

    The callback function to execute after authentication. The callback accepts two params. The first is error and contains the error if there is one. If the request was successful the first param is false and the second param is an Identity object.

authenticateAsAccount

(
  • account
  • secret
  • fn
)
async

Authenticate using account/secret keys.

To attach to a project (tenant), use setTenantId() or setTenantName() first.

Parameters:

  • account String

    The account to authenticate with.

  • secret String

    The secret key associated with the account.

  • fn Function

    A callback function to execute after a user authenticates. The callback accepts two params. The first is error and contains the error if there is one. If the request was successful the first param is false and the second param is an Identity object.

authenticateAsUser

(
  • username
  • password
  • fn
)
async

Authenticate using user/password.

To attach to a project (tenant), use setTenantId() or setTenantName() first.

Parameters:

  • username String

    The username to authenticate with.

  • password String

    The users password associated with the username.

  • fn Function

    A callback function to execute after a user authenticates. The callback accepts two params. The first is error and contains the error if there is one. If the request was successful the first param is false and the second param is an Identity object.

rescope

(
  • identity
  • fn
)
async

Rescope a user from one tenant to another.

Parameters:

  • identity Identity

    The Identity object

  • fn Function

    A callback function to execute after rescoping the identity.

setTenantId

(
  • id
)
Object chainable

Set the tenant ID.

Only one of tenant name and tenant ID should be set.

This should be done before an authentication call.

Parameters:

  • id String

    The tenantId to be used.

Returns:

Object: The current object so this can be used in chaining.

setTenantName

(
  • name
)
Object chainable

Set the tenant Name.

Only one of tenant name and tenant ID should be set.

This should be done before an authentication call.

Parameters:

  • name String

    The tenantName to be used.

Returns:

Object: The current object so this can be used in chaining.

tenantId

() String

Get the tenantId.

Returns:

String: The tenantId.

tenantName

() String

Get the tenantName.

Returns:

String: The tenantName.

tenants

(
  • identity
  • fn
)
Array async

Get the list of tenants for an identity.

A tenant object looks like this:

Parameters:

  • identity Object

    An identity object.

  • fn Function

    The callback function. This will be invoked with a list of tenant objects: fn(error, tenants)

Returns:

Array: An array of tenant objects.

Example:

{ id: 'TENANT_ID', name: 'TENANT NAME', enabled: true, created: TIMESTAMP, updated: TIMESTAMP }

url

() String

Get the endpoint URL.

Returns:

String: The endpoint URL to Identity Services.