# user-service ## Prerequisites 1. Install [Docker](https://www.docker.com/) by following it's [installation instructions](https://www.docker.com/products/docker-desktop/). 2. Install [Watch](https://watchexec.github.io/#cargo-watch) by running `cargo install cargo-watch`. 3. Install [PostgreSQL](https://www.postgresql.org/) by following it's [installation instructions](https://www.postgresql.org/download/). 4. Install [Diesel](https://diesel.rs/) 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:` - expose the database via `localhos:` 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: ```bash diesel migration generate my_update_name --database-url=postgres://admin:123@db:5432/user_service ``` Pending updates can be applied: ```bash diesel migration run --database-url=postgres://admin:123@db:5432/user_service ``` They can be reverted with: ```bash 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: ```bash 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.