User Management

Almost every application requires some kind of user management, where a user is required to register for an account, to join a group, or to login to the application. Apstrata makes all that easy for the developer, without having to worry about administering or managing his/her own user directory nor having to worry about writing code to handle each of the previously mentioned features.

Apstrata is a back-end as a service solution, providing the building blocks needed for you to build an application. It provides a set of cloud API services, among which is a set of services for Identity Management. In this post we will be showing code examples to show how easy it is to manage a User in the Apstrata service.

Examples are listed below on how to register a user, authenticate a user, and add/remove a user from a group. Please note that in the following examples, a JSON response is returned for each request indicating its success or failure.  NOTE: These examples use the REST API interface and assume that the REST calls are made via an Apstrata application account and are signed appropriately. User management features are also available via native iOS and Android SDKs. For more details explore our website at apstrata.com.

User Registration

In order to add a user to the directory, you will need to make a REST call to the SaveUser service as follows:

Request URL: 

	https://varick.apstrata.com/apsdb/rest/[authentication_key]/SaveUser

Request Parameters:

	apsws.time: [current time in milliseconds]
	apsws.authSig: [the hash generated as a result of signing the request with the authentication key and secret]
	login: [login of the user]
	password: [password of the user]
	name: [full name of the user]
	email: [email address of the user]

Additional fields can be saved in the user profile as needed. Please refer to the documentation of the SaveUser service for more details.

Moreover, two-steps registration can be easily achieved as follows:

Step 1: User enters his personal info

Request URL:

	https://varick.apstrata.com/apsdb/rest/[authentication_key]/SaveUser

Request Parameters:

	apsws.time: [current time in milliseconds]
	apsws.authSig: [the hash generated as a result of signing the request with the authentication key and secret]
	login: [login of the user]
	password: [password of the user]
	name: [full name of the user]
	email: [email address of the user]
	isSuspended: true

Step 2: User confirms his registration

Request URL: 

	https://varick.apstrata.com/apsdb/rest/[authentication_key]/SaveUser

Request Parameters:

	apsws.time: [current time in milliseconds]
	apsws.authSig: [the hash generated as a result of signing the request with the authentication key and secret]
	login: [login of the user]
	isSuspended: false
	apsdb.update: true

In step 2, we simply activate the user by updating his profile. A user who is suspended has no access to the Apstrata API services.

User Authentication

In order to authenticate a user, you will need to make a call to the VerifyCrendentials service as follows:

Request URL:

	https://varick.apstrata.com/apsdb/rest/[authentication_key]/VerifyCredentials

Request Parameters:

	apsws.time: [current time in milliseconds]
	apsws.user: [login of the user to be authenticated]
	apsws.authSig: [the hash generated as a result of signing the request with the password of the user being authenticated]

User Groups

Groups may be used to specify read, write, and/or delete permissions on the data. A user can be a member of multiple groups.

In order to add a group, you will need to make a REST call to the SaveGroup service as follows:

Request URL:

	https://varick.apstrata.com/apsdb/rest/[authentication_key]/SaveGroup

Request Parameters:

	apsws.time: [current time in milliseconds]
	apsws.authSig: [the hash generated as a result of signing the request with the authentication key and secret]
	groupName: [name of the group]

In order to add a new user to one or more groups, you will need to make a call to the SaveUser service as follows:

Request URL:

	https://varick.apstrata.com/apsdb/rest/[authentication_key]/SaveUser

Request Parameters:

	apsws.time: [current time in milliseconds]
	apsws.authSig: [the hash generated as a result of signing the request with the authentication key and secret]
	login: [login of the user]
	password: [password of the user]
	name: [full name of the user]
	email: [email address of the user]
	groups: [group 1]
	groups: [group 2]
	groups: [group n]

In order to add an existing user to one or more groups, you will need to make a call to the SaveUser service as follows:

Request URL:

	https://varick.apstrata.com/apsdb/rest/[authentication_key]/SaveUser

Request Parameters:

	apsws.time: [current time in milliseconds]
	apsws.authSig: [the hash generated as a result of signing the request with the authentication key and secret]
	login: [login of the user]
	apsdb.update: true
	apsdb.multivalueAppend: [the name of the groups parameter i.e. "groups"; this avoids removing the existing groups membership for the user and appends to the existing ones]
	groups: [group 1]
	groups: [group 2]
	groups: [group n]

In order to remove a user from a specific group, you will need to make a call to the SaveUser service as follows:

Request URL:

	https://varick.apstrata.com/apsdb/rest/[authentication_key]/SaveUser

Request Parameters:

	apsws.time: [current time in milliseconds]
	apsws.authSig: [the hash generated as a result of signing the request with the authentication key and secret]
	login: [login of the user]
	apsdb.update: true
        groups.apsdb.delete = [groupname from which to remove the user]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>