The titan User Service

The titan User Service can be reached via a REST API that serves under the port number HOST:9000.

UseCaseDiagram

Building/ running

To run the service simply use go run ./cmd/user

or to create an exe go build ./cmd/user

It features the following command line arguments:

Name Options (default) Purpose
port (8085) Port on which the User Service serves
log-level info/debug/warning/error Log level
(info)
config-file (internal/app/user/config.yaml) Configuration file

The default configuration file contains the following items:

Name Type Doc (default value) Constraints
database string URL of the Database (127.0.0.1:27017)
allowed-origins list List of allowed origins for CORS request [not null]
user-manager string URL of the User Service (http://127.0.0.1:9000)

Generally, all settings listed above can be done also via environment
variables, whereby the variables are composed of a prefix (TITAN_UM)
and the argument using snake case:

TITAN_UM_ARGUMENT, e.g. TITAN_UM_LOG_LEVEL

Usage

Generally, all queries to the User Service are formulated by sending a json object with the fields :

{
  "username": "UserName",
  "email": "Email",
  "password": "Password"
}

NewUser

structure of a new user object

Items:

Name Type Doc Constraints
Username string user name [not null]
Email string email [not null]
Password string password [not null]

User

structure of a user object

Items:

Name Type Doc Constraints
Username string username [not null]
Email string email [not null]
IsAdmin boolean flag: admin rights

ChangePassword

structure of a change password request body

Items:

Name Type Doc Constraints
User NewUser newUser [not null]
OldPassword string old_password [not null]

APIS

Signup

To sign up, need the JSON object NewUser

API functions

/userservice/signup Type: POST or PUT

Response

If successful, the response header will contain a token and User object.

To sign up, need the JSON object NewUser

API functions

/userservice/signup?id=<token> Type: POST or PUT

Response

If successful, the response header will contain a token and User object.

Login

To Login, need the JSON object NewUser

API functions

/userservice/login Type: POST or PUT

Response

If successful, the response header will contain a token.

Logout

To Logout a user

API functions

/userservice/logout Type: GET

Response

If successful, the response header will contain a expired cookie that has empty token.

Authentication

To authentication a user need to send the cookie that contain a token

API functions

/userservice/authentication Type: GET

Response

If successful, the response StatusOk in HTTP and list of Users

IsAdmin

To authorize a user need to send the cookie that contain a token

API functions

/userservice/isadmin Type: GET

Response

If successful, the response StatusOk in HTTP and 'true' in body

Get Users

To get all users as Type User. You need admin role for this end point

API functions

/userservice/users Type: GET

Response

If successful, the response StatusOk in HTTP and list of Users

Delete user

Users can only delete themselfs, despite admins, who are also allowed to delete users.

API functions

/userservice/users/<id string> Type: DELETE

Request data

NewUser objects password as JSON need to send in body.

Response

If successful, the response StatusOk in HTTP

Update user

Users can only update themselves

API functions

/userservice/users/<id string> Type: PUT

Request data

NewUser objects in body as JSON type.

Response

If successful, the response StatusOk in HTTP

Change Passwords

Admin can use this API to change the other user passwords. User can change password for his own account.

ChangePassword as JSON need to send in body.

API functions

/userservice/changepassword Type: PUT

Response

If successful, the response StatusOk.

Get platform configuration

API functions

/userservice/platformConfig Type: GET

Response

If successful, the response StatusOk in HTTP and the
Platform configuration as a json object .

Update platform configuration

API functions

/userservice/platformConfig Type: PUT

Send an updated platform configuration as a json object.

Response

If successful, the response StatusOk in HTTP and the platform configuration as a json object .

API functions

/userservice/invite?email=<email> Type: POST

Response

If successful, the response StatusOk in HTTP and the invitation as a json object .

Update User as an Admin

This endpoint provides the facility to update a user in the system for an Administrator.

This endpoint is only accessibly by a user that is already an Admin in the system.

Example: If the Admin wants to make another user admin, they can then use this endpoint

API functions

/userservice/users/toggleUserAdmin Type: PUT

Request data

A user ID that is part of the User Object in body as JSON type.

Example: Admin wants to make user with an ID an Admin

{
  id: "443bafdf-f98c-11ea-a835-98fa9b446af4"
}

Response

If successful, the response StatusOk in HTTP