{"id":26820505,"url":"https://github.com/nmrshll/auth-rs-warp","last_synced_at":"2025-04-24T03:44:27.499Z","repository":{"id":91315978,"uuid":"258485209","full_name":"nmrshll/auth-rs-warp","owner":"nmrshll","description":"Authentication / Authorization server example with Rust, Warp, Postgres","archived":false,"fork":false,"pushed_at":"2020-11-09T10:42:01.000Z","size":76,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T03:44:23.733Z","etag":null,"topics":["api","async","async-await","auth","await","email","futures","hyper","login","logout","password","postgres","rust","tokio","warp"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nmrshll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-24T10:50:22.000Z","updated_at":"2025-02-19T19:25:50.000Z","dependencies_parsed_at":"2023-03-11T13:30:24.352Z","dependency_job_id":null,"html_url":"https://github.com/nmrshll/auth-rs-warp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmrshll%2Fauth-rs-warp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmrshll%2Fauth-rs-warp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmrshll%2Fauth-rs-warp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmrshll%2Fauth-rs-warp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nmrshll","download_url":"https://codeload.github.com/nmrshll/auth-rs-warp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250559522,"owners_count":21450167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","async","async-await","auth","await","email","futures","hyper","login","logout","password","postgres","rust","tokio","warp"],"created_at":"2025-03-30T06:33:01.421Z","updated_at":"2025-04-24T03:44:27.485Z","avatar_url":"https://github.com/nmrshll.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Docker-build-push](https://github.com/nmrshll/auth-rs-warp/workflows/Docker-build-push/badge.svg)](https://github.com/nmrshll/auth-rs-warp/actions?query=workflow%3ADocker-build-push)\n\n# auth-rs-warp\n\nAuthentication / Authorization server example with Rust, Warp, Postgres\n\n## Features\n\n- **Register users with email/password**\n- **Get an exsisting user / Check if an email is already taken**\n- **Login / Logout with email/password**\n- **Access / modify protected resources**: one example included: creating posts that belong to a user\n\nand also:\n\n- **Great performance and minimal footprint** thanks to async Rust\n- **Users database** using Postgres\n\n### Limitations\n\n- As of now, this example is usable for writing API routes in Rust (i.e. starting from this code and extending). Usage with an other stack might be possible but wasn't yet taken into consideration for this project.\n\n## Usage\n\n### Prerequisites\n\n- **Docker** daemon running\n- **Rust nightly 1.41+** (auto-installs if missing)\n\n### Running the auth server\n\nThree options: On your local machine with Docker, from the Docker image, or using kubernetes\n\n#### On your local machine\n\nRun `make`\n\nThis will start docker containers for: the API, the postgres database,\n\n#### From the docker image\n\nRun\n\n```shell\ndocker run -p 0.0.0.0:8080:8080 -e DATABASE_URL=postgres://user:pass@postgres/db docker.pkg.github.com/nmrshll/auth-rs-warp/api:latest\n```\n\nIn this configuration you need to provide your own postgres server, and run the migrations onto it manually.\n\n#### With Kubernetes\n\nA Kubernetes deployment file is [included](./deploy/k8s.dply.cue). It needs to be applied with [CUE](https://cuelang.org/). Examples commands to do that are included in the [makefile](./makefile)\n\nFor instance for a complete deployment on the current kubernetes context:\n\n```shell\nmake k.all\n```\n\n### Configuration options\n\nConfiguration is applied, from highest to lowest priority, through:\n\n- Environment variables\n- Config file located at `./.config/api_config(.ext)?` (relative to the binary). The config format (and extension `(.ext)?`) can be `json`,`yaml`,`toml`,`hcl`, `ini` or none (autodetected).\n- Hardcoded defaults\n\nThese options are:\n\n| Option            | ENV_VAR name        | Config name         | Default              |\n| ----------------- | :------------------ | :------------------ | -------------------- |\n| Postgres DSN      | `DATABASE_URL`      | `database_url`      |                      |\n| Postgres user     | `POSTGRES_USER`     | `postgres_user`     |                      |\n| Postgres password | `POSTGRES_PASSWORD` | `postgres_password` |                      |\n| Postgres database | `POSTGRES_DB`       | `postgres_db`       |                      |\n| Postgres host     | `POSTGRES_HOST`     | `postgres_db`       |                      |\n| HTTP port         | `HTTP_PORT`         | `http_port`         | `8080`               |\n| Log level         | `RUST_LOG`          | `postgres_db`       | `auth-rs-warp=debug` |\n| Enable backtraces | `RUST_BACKTRACE`    | `rust_backtrace`    | `1`                  |\n\nNote: At least one of `database_url` / `postgres_host/user/pw/db` must be defined. If both defined they must be compatible\n\n## Testing\n\n### Automated\n\nLocal testing is available by running\n\n```shell\nmake test\n```\n\n### Manual\n\nTest requests are included in the makefile (using `curl`)\n\n- **Register a user** using `make users/register`\n- **Check if an email is already taken** using `make users/check`\n- **Login** using `make users/login`\n- **Access a dummy protected route** using `make protected`\n\n## TODO and contributing\n\nDon't hesitate to file a bug, request a feature, or simply comment using issues.\n\nIf you want to help here's a few useful tasks I have in mind for this project:\n\n- [ ] Email verification and email invitations\n- [ ] CI\n- [ ] example deployment instructions\n- [ ] Write a tutorial to re-create this repo from scratch\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmrshll%2Fauth-rs-warp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmrshll%2Fauth-rs-warp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmrshll%2Fauth-rs-warp/lists"}