There are three methods for authenticating apstratabase requests:
1- Default signature: This is the most secure method of authentication because it requires hasing all content of a request along with the secret of the account or the password of the user and then sending the hash.
2- Simple signature: This is the easiest method of authentication. It requires hashing a few select parameters along with the secret of the account or the password of the user and then sending the hash. It is recommended for testing and for applications that do not have access to all parameters, like files, in a request.
3- Token-based authentication: This is the recommended method of authentication for applications that make most requests with apstrata users, as opposed to owners, for use with SSL encrypted connections over HTTP POST. It provides a similar experience to sessions since a token is generated and renewed over a period of time, without the need to generate a signature for every request.
The authentication roadmap for the apstrata database includes optional replay prevention.
apstrata database services only accept authenticated requests. Authenticating an apstrata database service request means either sending it with the apsws.authSig parameter or a valid value for the apsdb.token parameter. Creating the signature parameter for owner requests requires the developer to know their authentication key (apsws.authKey) and their authentication secret. Creating the signature parameter for user requests requires the developer to know their authentication key (apsws.authKey), the user login, and the user password. generating tokens requires generating a user request to VerifyCredentials in order to generate a token and then sending the token with every consecutive request in order to authenticate it. The token needs to be constantly renewed and requires re-authentication when its lifetime expires. The authentication key and the secret will be provided upon registration. The user login and the password are chosen when creating an apstrata user. Note that the secret works as a password for accessing our services suite and hence your data.
Never reveal your authentication secret to a third party, an apstrata database affiliate will never ask for your secret. In case you feel that your authentication secret has been compromised, you can create a new one.
Two types of signatures exist, one which is more secure and complex to construct, and another version which is simpler to construct but less secure.
Default Signature Type
By default, apstrata database will use a secure signature which depends on the data sent. It involves most of the data in the request, and it is calculated using the secret authentication key.
To create a signature:
1. Create a standardized string of the query string to be hashed
a. URL encode both the parameters and their values
i. In case of an attachment, the value would be the URL encoded hexadecimal representation of the MD5 hash of the file bytes (all capital letters)
b. Separate the encoded parameters and their values by the equals sign
c. Sort the parameters and their values by natural byte ordering (follow example below)
d. Append the name value pairs with an ampersand
2. Create the string to be hashed:
The HTTP URL will include the scheme, host, port (if present), and the path. It will not include any of the query strings.
3. Calculate the HMAC-SHA1 hash string using the secret authentication key
Please note that spaces and asterisk should be encoded as %20 and %2A respectively
String to hash
Assuming that the secret authentication key is “secret”
Simple Signature Type
In order to use the simple signature, requests should specify the authentication mode by setting the value of the parameter “apsws.authMode” to “simple”. Each request must also specify the action name and the timestamp (apsws.time). A URL example would be:
First, construct the text to hash by doing:
The values are appended without a separator.
The signature is then created by generating the Md5 hash of this text and using Hexadecimal characters:
Please keep in mind that simple signature is secure only when used over a secure connection. It is highly recommended to use SSL connection when using a simple signature to avoid data interception and replay attacks. If you don’t want to use SSL connection, it is advisable to use the default signature.
A token can be used to authenticate a user in place of a signature. This allows the creation of applications that do not need access to the users password which is required for signature generation. Tokens provide a layer of simplicity, but must obey the following restrictions:
1. Token-based authentication is enabled for user requests only. Owner requests must use signatures.
2. Token-based authentication is enabled under secure (https) connections only.
Tokens can be created or renewed using VerifyCredentials and can then be passed as a parameter to requests instead of the signature.
When no longer needed, tokens can be deleted and cleared using DeleteToken