Nimble directory + auth + SSO services for your {web} and {cloud} apps

Nimbus Directory Services

AuthService Web API

AuthService has a simple JSON web interface. It speaks JSON-RPC 2.0, the latest version of the protocol for remote procedure calls (RPC) using JSON-encoded messages. Clients can send their requests to an AuthService instance by HTTP POST.

The following table is an overview of the AuthService web API.

User authentication and details » Web service information »

Each JSON-RPC 2.0 request consists of the following fields:

Example JSON-RPC 2.0 request for simple user authentication:

{
  "method"  : "user.auth",
  "params"  : { "username" : "alice", "password" : "secret" },
  "id"      : "0001",
  "jsonrpc" : "2.0"
}

1. User authentication and details

AuthService provides two methods for user authentication: user.auth which simply verifies the supplied username and password, and user.get which, in addition to that, also retrieves a set of user attributes (such as the person's name, email address, phone numbers, photo, etc.) from the directory.

user.auth

Authenticates a user with the specified username and password. Returns result true on success or false if the credentials are invalid.

Parameters:

Result:

Examples:

Example request to authenticate a user with email alice@wonderland.net and password secret:

{ "method"  : "user.auth",
  "params"  : { "username" : "alice@wonderland.net", 
                "password" : "secret" }
  "id"      : "0001",
  "jsonrpc" : "2.0" }

Response indicating the credentials were valid:

{ "result"  : true,
  "id"      : "0001",
  "jsonrpc" : "2.0" }

Response indicating either the username or the password or both were invalid:

{ "result"  : false,
  "id"      : "0001",
  "jsonrpc" : "2.0" }

If for some reason the AuthService couldn't process the request (due to bad configuration, the LDAP server being down or other exception) a JSON-RPC error is returned to the client. How verbose the returned error message is depends on the authService.clients.exposeExceptions configuration setting. You may also check the full listing of AuthService error codes and messages.

{ "error"   : { "message" : "Client X.509 certificate required",
                "code"    : -1002 },
  "id"      : "0001",
  "jsonrpc" : "2.0" }

user.get

Authenticates a user with the specified username and password.

If the credentials are valid returns the user's directory attributes specified by the authService.userAttributes configuration setting. DN provisioning and Json2Ldap CID provisioning may also be available to clients if configured.

If the username / password combination is invalid this call returns a -1100 "Invalid credentials" error.

Parameters:

Result:

Examples:

Example request to authenticate and retrieve a user with username alice and password secret:

{ "method"  : "user.get",
  "params"  : { "username" : "alice", 
                "password" : "s3cr3t" }
  "id"      : "0001",
  "jsonrpc" : "2.0" }

Example response indicating authentication success and returning a the user attributes according to the authService.userAttributes configuration setting. Multi-valued attributes are specified as arrays, even if they contain a single item.

{ "result"  : { "attributes" : { "userID" : "alice",
                                 "name"   : "Alice Adams",
				 "email"  : [ "alice@wonderland.net" ],
                                 "phone"  : [ "+1 685 622 6202", 
				              "+1 010 154 3228", 
					      "+1 225 216 5900" ] },
  "id"      : "0001",
  "jsonrpc" : "2.0" }

If DN provisioning is enabled that distinguished name (DN) of the user in the directory is also included:

{ "result"  : { "DN"         : "uid=alice,ou=people,dc=wonderland,dc=net",
                "attributes" : { "userID" : "alice",
                                 "name"   : "Alice Adams",
				 "email"  : [ "alice@wonderland.net" ],
                                 "phone"  : [ "+1 685 622 6202", 
				              "+1 010 154 3228", 
					      "+1 225 216 5900" ] } },
  "id"      : "0001",
  "jsonrpc" : "2.0" }

And here if a response with a Json2Ldap URL and connection identifier (CID) bound as the authenticated user:

{ "result"  : { "DN"         : "uid=alice,ou=people,dc=wonderland,dc=net",
                "attributes" : { "userID" : "alice",
                                 "name"   : "Alice Adams",
				 "email"  : [ "alice@wonderland.net" ],
                                 "phone"  : [ "+1 685 622 6202", 
				              "+1 010 154 3228", 
					      "+1 225 216 5900" ] },
                "Json2Ldap" : { "URL" : "http:\/\/ldap.example.com",
		                "CID" : "9163a3c2-d15a-41af-9b7a-114afed7dd80" } },
  "id"      : "0001",
  "jsonrpc" : "2.0" }

Example response error indicating bad username and / or password:

{ "error"   : { "message" : "Invalid credentials",
                "code"    : -1100 },
  "id"      : "0001",
  "jsonrpc" : "2.0" }

2. Web service information

AuthService also provides three JSON-RPC methods to obtain information about the web service itself. There are the ws.getName and ws.getVersion methods to identify the software and its version, as well as the ws.getTime method that reports the local time at the web server.

ws.getName

Reports the name of web service software.

Parameters: none

Result:

Examples:

Example request message:

{ "method"  : "ws.getName",
  "id"      : 1,
  "jsonrpc" : "2.0" }

The response message:

{ "result"  : "AuthService",
  "id"      : 1,
  "jsonrpc" : "2.0" }

ws.getVersion

Reports the version of the web service software.

Parameters: none

Result:

Examples:

Example request message:

{ "method"  : "ws.getVersion",
  "id"      : 1,
  "jsonrpc" : "2.0" }

The response message:

{ "result"  : "1.0 (2011-03-16)",
  "id"      : 1,
  "jsonrpc" : "2.0" }

ws.getTime

Reports the local web service time in ISO 8601 format yyyy-MM-dd'T'HH:mm:ssZZ, for example "2010-03-31T23:59:59+03:00".

Parameters: none

Result:

Examples:

Example request message:

{ "method"  : "ws.getTime",
  "id"      : 1,
  "jsonrpc" : "2.0" }

The response message:

{ "result"  : "2010-11-15T12:14:41+02:00",
  "id"      : 1,
  "jsonrpc" : "2.0" }