1 unstable release

0.4.1 Apr 11, 2023
0.3.1 Apr 11, 2023

#1186 in HTTP server

28 downloads per month

Apache-2.0

65KB
2K SLoC

user-service

Prerequisites

  1. Install Docker by following it's installation instructions.

  2. Install Watch by running cargo install cargo-watch.

  3. Install PostgreSQL by following it's installation instructions.

  4. Install Diesel by running cargo install diesel_cli --no-default-features --features postgres.

During Development

When developing, ensure cargo watch --clear -x fmt is running in a terminal, where:

  • watch will detect any changes in the repo and refresh commands.
  • --clear will clear the console output each time changes are detected.
  • fmt will format your Rust code to comply with standards and ensure unformatted code is not committed.

To launch the application run docker compose up --build, this will:

  • expose the API via http://localhos:<port>
  • expose the database via localhos:<port>

The individual ports uniquely chosen by Docker can be found through the Docker interface.

Database Schema Updates

New updates can be defined by running the generate command and editing it's corrosponding folder contents in the migrations directory:

diesel migration generate my_update_name --database-url=postgres://admin:123@db:5432/user_service

Pending updates can be applied:

diesel migration run --database-url=postgres://admin:123@db:5432/user_service

They can be reverted with:

diesel migration revert --database-url=postgres://admin:123@db:5432/user_service

It's important to run the redo command after using run to ensure your revert script works correctly:

diesel migration redo --database-url=postgres://admin:123@db:5432/user_service

Dual Internal (Admin) and External (Public) Access Solution

This service contains a public and private set of routes/endpoints to enable Single Sign-On (SSO).

The internal interface is for other internal services to query and run privileged commands, whereas the public interface allows a centralised API to be called from clients for SSO.

These interfaces run on two separate ports, where one port should only be accessible from LAN (Internal Network) and the other should only be accessible from WAN (Internet).

SSO is not yet implemented meaning this dual solution is not currently available, but will be in the future.

Dependencies

~21–37MB
~655K SLoC