This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

API definition

Aura Authentication API definition

Definition of APIs in aura-authentication-api component

Introduction

This section includes the API definition files that affects to the authentication processes in Aura:

1 - Aura Authentication API

Aura authentication API definition

Description of Aura Authentication API swagger

Download swagger file

2 - Terms and conditions API

Aura Terms and Conditions API

Description of Aura Terms and Conditions API

Introduction

Temporary implementation of the Kernel TermsAndConditions API.

This is an internal, privileged API that allows Aura to save the user’s acceptation. As this API is not inside any secured deployment, an x-api-key header should be sent in every request.

This service is available in all the deployments with services needing Terms and Conditions handling, such as WhatsApp

Acceptance criteria

  • There may be different versions for the service T&C.
  • Only acceptations, not revocations, should be stored.
  • There should be a way to allow deleting all acceptations for a user.

Database schema

Terms and Conditions database contains the services collection with the following structure:

API

Create an acceptation for a service version T&C POST /v0/users/:user_id/services

POST /v0/users/9a47b037-825f-4ae7-bf55-6290efd5d036/services
Content-Type: application/json
x-api-key: 58e76225-d275-495b-a232-fdf3364ac277
{
	"version": "1",
	"name": "aura"
}

HTTP/1.1 201 Created
Content-Type: application/json
{
  "user_id": "9a47b037-825f-4ae7-bf55-6290efd5d036",
  "name": "aura",
  "version": "1",
  "status": "accepted",
  "created_at": "2019-08-08T15:19:48.259Z"
}

List user acceptations GET /v0/users/:user_id/services

GET /v0/users/9a47b037-825f-4ae7-bf55-6290efd5d036/services
x-api-key: 58e76225-d275-495b-a232-fdf3364ac277

HTTP/1.1 200 OK
Content-Type: application/json
[
  {
    "user_id": "9a47b037-825f-4ae7-bf55-6290efd5d036",
    "name": "aura",
    "version": "1",
    "status": "accepted",
    "created_at": "2019-08-08T15:19:48.259Z"
  }
]

get specific user acceptation GET /v0/users/:user_id/services/:name/:version

GET /v0/users/9a47b037-825f-4ae7-bf55-6290efd5d036/services/aura/1
x-api-key: 58e76225-d275-495b-a232-fdf3364ac277

HTTP/1.1 200 OK
Content-Type: application/json
{
  "user_id": "9a47b037-825f-4ae7-bf55-6290efd5d036",
  "name": "aura",
  "version": "1",
  "status": "accepted",
  "created_at": "2019-08-08T15:19:48.259Z"
}

delete all user acceptations DELETE /v0/users/:user_id/services

DELETE /v0/users/9a47b037-825f-4ae7-bf55-6290efd5d036/services
x-api-key: 58e76225-d275-495b-a232-fdf3364ac277

HTTP/1.1 204 No Content

Create an entry with custom status for a service version T&C POST /v0/users/:user_id/services/:status

POST /v0/users/9a47b037-825f-4ae7-bf55-6290efd5d036/services/pending
Content-Type: application/json
x-api-key: 58e76225-d275-495b-a232-fdf3364ac277
{
	"version": "1",
	"name": "aura"
}

HTTP/1.1 201 Created
Content-Type: application/json
{
  "user_id": "9a47b037-825f-4ae7-bf55-6290efd5d036",
  "name": "aura",
  "version": "1",
  "status": "pending",
  "created_at": "2019-08-08T15:19:48.259Z"
}

Update an entry with custom status for a service version T&C PUT /v0/users/:user_id/services/:status

PUT /v0/users/9a47b037-825f-4ae7-bf55-6290efd5d036/services/newStatus
Content-Type: application/json
x-api-key: 58e76225-d275-495b-a232-fdf3364ac277
{
	"version": "1",
	"name": "aura"
}

HTTP/1.1 201 Created
Content-Type: application/json
{
    "n": 1,
    "nModified": 1,
    "ok": 1
}

Metrics

prometheus

GET /metrics
HTTP/1.1 200 OK

...txt...

liveness prove

GET /ping
HTTP/1.1 200 OK
Content-Type: application/json

{
  "timestamp": 1567693845103,
  "uptime": 7026,
  "service": {
    "name": "tac",
    "version": "1.0.5"
  }
}

Development

docker-compose up

To clean database and start from scratch

docker-compose down -v

Configuration

The configuration comes from environment variables.

# the mongodb uri, including user/password and ssl configuration
export TAC_MONGODB_URI=mongodb://db:27017/tac
# API key that should be sent in every request in the `x-api-key` header
export TAC_APIKEY=58e76225-d275-495b-a232-fdf3364ac277

3 - Aura Services API in Kernel

Aura Services API published in Kernel

Description of Aura Authentication API endpoints published in Kernel

Introduction

As mentioned in the endpoints section, some of the endpoints of the aura-authentication-api are published in Kernel, while others are only for internal usage and others are published in Internet because they can be called by any other service, with the proper credentials.

This section is dedicated to those published in Kernel.

aura-services API definition in Kernel

The API published in Kernel is not strictly the same as the one published in aura-authentication-api. In the end, they represent the very same service, but the former needs to provide the layer of Kernel authentication.

The API definition can be found in Kernel developers site, where both the different versions deployed in every environment are presented.

How to consume this API

This is a regular Kernel API, so in order to consume it, just follow the same instructions as for the rest of Kernel APIs: consuming APIs.