Skip to content

Identity Service: Overview

Sid Sethi edited this page Oct 29, 2020 · 1 revision

What is an Audius Identity Service?

The Audius Identity Service maintains all the authentication, social oauth, and relay aspects of the Audius ecosystem. It's an expendable service w/ regards to the overall protocol, but is used to prototype features before integrating them into the Audius protocol, store encrypted auth ciphertexts, perform OAuth and relay transactions on behalf of users. Overall, it's used to improve the user experience.

Note: Under active development with a constantly evolving API.

Staging: identityservice.staging.audius.co
Production: identityservice.audius.co

Table of Contents

Up and Running

Service Dependencies

The Identity Service depends on external services to run:

Docker Compose

Docker Compose is used for a bit more automated management of the service dependencies.
Make sure you have Docker and Docker-compose installed and operational.

To run the application along with its services, run

docker-compose -f docker-compose/docker-compose.yml up

In development, it may be useful to use the --build flag to rebuild changes.

Docker

The Audius Identity Service is an evolving FOSS project. The application is dockerized for the ease of development and deployment of our user community. To use these images you will need to have Docker installed and operational.

Environment Variables

Variables listed in default-config.json can also be overridden via
1.) environment variables using a : delimiter.
2.) Creating a local-config.json file with the : delimited keys as nested fields.

The environment variables take the highest priority, then the local-config.json, then default-config.json

dbUrl Default: postgres://postgres:postgres@localhost:7432/audius_centralized_service
The postgres database connection url

port Default: 7000
The port the application uses to exposes its API

redisHost
The host the application uses to connect to redis

redisPort Default: 7379
The port the application uses to connect to redis

logLevel Default: debug
The log level of the application

twitterAPIKey The twitter api key

twitterAPISecret
The twitter api secret

instagramAPIKey
The instagram api key

instagramAPISecret
The instagram api secret

web3Provider Default: http://localhost:8545/
The web3 provider url

relayerPrivateKey The relayer private key

relayerPublicKey
The relayer public key

userVerifierPrivateKey
The user verifier private key

userVerifierPublicKey
The user verifier public key

blacklisterPrivateKey
The blacklister private key

blacklisterPublicKey
The blacklister public key

rateLimiting:reqLimit Default: 15000
The rate limit on the number of requests per...

rateLimiting:authLimit Default: 5000
The rate limit on the number of auth requests per...

rateLimiting:twitterLimit Default: 5000
The rate limit on the number of twitter requests per...

minimumBalance Default: 1
The minimum balance of the wallet

WAIT_HOSTS Default: docker.for.mac.localhost:7432,docker.for.mac.localhost:7379
The urls to wait for an open TCP connection before starting the applciation

Docker for local dev

NOTE: WORK IN PROGRESS AND NOT YET TESTED

The external services (redis & postgres) must be running and accessible for the identity service to function. The following commands instantiate each service dependecy and the identity service. If a service dependecy is already running, it's setup can be skipping with the host and port correctly passed to the identity service.

A docker network is recommended to isolate the container ports, but the ports are forwarded to the host network for debugging

Create a Docker Network

docker network create identity-service

Start a Redis Instance

docker run -d --network=identity-service \
    --name=identity-service-redis \
    -p 4379:6379 \
    redis:5.0.4

Start a Postgres Instance

docker run -d --network=identity-service \
    --name=identity-service-redis \
    -p 4432:5432 \
    -e "POSTGRES_USER=postgres" \
    -e "POSTGRES_DB=audius_identity_service" \
    -v postgres_data:/var/lib/postgresql/data/ \
    postgres:11.1

Build & Run the Identity Service

# Build the project locally
docker build -t audius/identity-service .

# Run the identity service in docker 
docker run -d --net-host \
    -v $(pwd):/usr/src/app \
    -e "dbUrl=postgres://postgres:postgres@identity-service-postgres:5432/audius_identity_service" \
    -e "redisHost=identity-service-redis" \
    -e "redisPort=6379" \
    -e "WAIT_HOSTS=identity-service-redis:6379,identity-service-postgres:5432"
    audius/identity-service

Overview

Developing

When making changes, nodemon handles auto-restarting to load code changes without having to manually restart the process.

Tests

Tests can be run with the included script ./scripts/run-tests.sh or via npm by running npm test. The CircleCI configuration uses the same testing entry point.

DB and ORM

The identity service currently depends on postgres, but uses the Sequelize ORM which would allow other databases to potentially be used in future. [Migrations](http://docs.sequelizejs.com/manual/tutorial/migrations.html are run every time the identity service starts.

For full documentation on how to interact with the Sequelize models, including migrations, see the extensive documentation provided on the Sequelize website.

Configuration

All available configuration values are listed in default-config.json. The precedence order for loading config values is as follows (in decreasing order of priority):

  1. environment variables
  2. a local-config.jsonfile located in the root of the repository
  3. values set in default-config.json.
    For example, if dbUrl were set via an environment variable and in local-config.json, the value provided in the environment variable would be used.

Usage

TODO: Definitions of each API Endpoint ...

Contributing

TBD

License

TBD