/account_service

gRPC service for creating accounts (name, email, password etc)

Primary LanguageGoMIT LicenseMIT

Account Service

Build Status GoDoc

An account microservice that speaks gRPC made with the Lile generator, backed by PostgreSQL.

service AccountService {
  rpc List (ListAccountsRequest) returns (ListAccountsResponse) {}
  rpc GetById (GetByIdRequest) returns (Account) {}
  rpc GetByEmail (GetByEmailRequest) returns (Account) {}
  rpc AuthenticateByEmail (AuthenticateByEmailRequest) returns (Account) {}
  rpc GeneratePasswordToken (GeneratePasswordTokenRequest) returns (GeneratePasswordTokenResponse) {}
  rpc ResetPassword (ResetPasswordRequest) returns (Account) {}
  rpc ConfirmAccount (ConfirmAccountRequest) returns (Account) {}
  rpc Create (CreateAccountRequest) returns (Account) {}
  rpc Update (UpdateAccountRequest) returns (Account) {}
  rpc Delete (DeleteAccountRequest) returns (google.protobuf.Empty) {}
}

Details

Authentication

Passwords are stored hashed with bcrypt, no RPC method returns passwords or hashed passwords.

You can do simple authentication with the AuthenticateByEmail RPC method to roll your own authentication logic. I.e you can auth with email and password, but managing password length or auth tokens is up to you.

Validations

At the moment the service will reject account create and update requests have either a blank name or email. "" is considered blank.

There is no email validation other than 'present' so to speak as I've never seen it done quite right.

Docker

A pre build Docker container is available at:

docker pull lileio/account_service

Commands

Usage:
  account_service [command]

Available Commands:
  migrate     Run database migrations
  server      Run the gRPC server
  client      Interact with a running server

Environment Setup

Setup is configured via environment variables, depending on the database chosen.

The app provides migrations, but does create the databases itself.

PostgreSQL

PostgreSQL is configured using the single ENV variable POSTGRESQL_URL and can be a url like string e.g.

POSTGRESQL_URL="postgres://host/database"

The PostgreSQL driver uses UUID's as primary key and a single table.

Image Service

Uploading and attaching an image is supported via the lile image_service via an Image Operation. To do so, you will need to set the IMAGE_SERVICE_ADDR variable. Account Service will run fine without this, but you'll need to leave the image upload nil.

IMAGE_SERVICE_ADDR="10.0.0.1:8000"

Test

The docker-compose.yml file will run PostgreSQL and Cassandra for testing purposes, but you will need create the test databases yourself. Migrations are run automatically by the test suite.

For PostgreSQL (using psql):

CREATE DATABASE account_service_test;