๐ฎโโ๏ธ Authentication
Authentication
To ensure security and confidentiality of our services, it is required to verify the user's identity for each request.
These pieces of information are stored in an access token. This token is delivered by our authentication service.
Below are detailed the API endpoints used for this service.
method
url
params
description
GET
returns a challenge in exchange of the user's email address.
POST
challenge, userId
returns the access token if the user id and the corresponding challenge are correct.
How to obtain a token
In order to obtain a token, the client must be authenticate by the service. This authentication is performed using a challenge (i.e. a unique string forged using the information contained in our database):
First the client requests a challenge from the server.
Using the user credentials (i.e. the password) the client tries to solve the challenge.
The client posts its response to the server.
The server effectively solves the challenge with the credentials stored in its database and compares the two responses.
If the responses match, the server returns a token.
This approach ensures a certain level of security because the password is not sent during the authentication process.
Each of the authentication steps is defined in the sections below.
Requesting the challenge
Description
In order to obtain a token, the client is responsible for requesting a challenge. This challenge can be requested using the following API endpoint:
[GET] https://kligo.medeo.io/auth?email=<your@mail.com>
This endpoint expects an email address to be passed.
Response
Depending on the email provided, different responses can be expected:
status
body
description
200 - OK
userId, challenge
This response is composed of the challenge to solve and the id associated with the user.
404 - Not Found
message
The email provided is not associated with a known user.
500 - Internal Error
message
Something went wrong on our end.
Here are some example response:
Here is a comprehensive example for requesting a challenge:
Solving the challenge
description
Once fetched, the challenge must be solved using the user credentials. The expected solution is computed as follows:
First, concatenate the challenge string with the user password.
Then hash the concatenated string using a SHA256 hashing method.
Send back the hashed string along with the userId
response
The authentication service will responds depending on the solution passed. There are three cases:
The
userId
is incorrectThe
solution
is incorrectEverything is correct
status
body
description
200 - OK
token
The authorization token
404 - Not Found
message
The userId provided is not known
400 - Bad Request
message
Incorrect password
500 - Internal Error
message
Something went wrong on our end
Once you receive the token, its TTL attribute is set to 1 day. Passed this date, the token will no longer authenticate your requests and our services will automatically respond with a401 UnauthorizedHTTP response.
In other words, it will be required to start again an authentication process to continue to use our services.
Here are some example responses:
Here is the first method required for getting the token:
Eventually, here is an example of posting the solution to the authentication service :
Last updated