{"id":19045422,"url":"https://github.com/marirs/rocket-jwt","last_synced_at":"2025-04-23T23:46:54.650Z","repository":{"id":84060996,"uuid":"379115541","full_name":"marirs/rocket-jwt","owner":"marirs","description":"Rocket api server with JWT","archived":false,"fork":false,"pushed_at":"2024-05-31T03:54:27.000Z","size":58,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T08:39:36.676Z","etag":null,"topics":["jwt","jwt-auth","jwt-authentication","rocket","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marirs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2021-06-22T02:12:10.000Z","updated_at":"2024-05-31T03:54:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"22ed89b7-8864-493a-8bd2-5182bc423922","html_url":"https://github.com/marirs/rocket-jwt","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/marirs%2Frocket-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Frocket-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Frocket-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Frocket-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marirs","download_url":"https://codeload.github.com/marirs/rocket-jwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535085,"owners_count":21446504,"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":["jwt","jwt-auth","jwt-authentication","rocket","rust","rust-lang"],"created_at":"2024-11-08T22:50:10.943Z","updated_at":"2025-04-23T23:46:54.628Z","avatar_url":"https://github.com/marirs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rocket-jwt\n[![CI](https://github.com/marirs/rocket-jwt/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/marirs/rocket-jwt/actions/workflows/ci.yml)\n[![Build Status](https://travis-ci.com/marirs/rocket-jwt.svg?branch=master)](https://travis-ci.com/marirs/rocket-jwt)\n![GitHub](https://img.shields.io/github/license/marirs/rocket-jwt)\n\nA barebones [Rocket](https://rocket.rs) API with [JWT](https://jwt.io) authentication and \ndatabase integration.\n\nThe database integration can be switched between [sqlite](https://www.sqlite.org/index.html) and [postgres](https://www.postgresql.org/) with a simple feature flag.\n\n## Requirement\n- Rust version 1.52 or newer.\n- Diesel CLI with `postgres` or `sqlite` features.\n- A running [PostgreSQL](https://www.postgresql.org/) or [Sqlite](https://www.sqlite.org/index.html) backend.\n  \n## Setup environment\n\nA `.env.{db}` at the root directory exposes environment both used by `diesel`and the project itself.  \nRename it to `.env` then set all the environment variables before running the following commands :\n\n``` bash\nsource .env\n```\n\n## Build locally\n\nRun the following command to fulfill the requirements :\n\n``` bash\n# Install Rust and cargo alongside rustup\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n\n# Install ORM and query builder\ncargo install diesel_cli --no-default-features --features \"postgres sqlite\"\n\n# Run migrations\ndiesel setup \ndiesel migration run\n```\n\nThen build the project with `default` database `(sqlite)`:\n```bash\ncargo build --release\n```\n\nor build with `postgresql` database:\n\n``` bash\n$ cargo build --release --no-default-features --features postgres\n```\n\n## Create the first user\n```bash\n# Build the create-user binary\ncargo build --release --features create-user-binary\n\n# Execute the binary to create the first admin user\n../target/release/create-user\n```\n\n## Available `feature` flags\nYou can use the feature flag to switch between database use:\n\n- sqlite (default)\n- postgres\n\nTo build the create-user binary\n- create-user-binary\n\n## Switching the database at the backend\n\nAny time you want to perform a database switch, you have to:\n1. Install and run the desired database on your machine if is not already the case\n2. Run migrations\n3. Build the project with the respective feature flag.\n\n## Usage\n\nTo print the project usage, an option `-h` is available.\n\n## API routes\n\n- Get Swagger docs\n``` http\nGET /docs\n```\n\n- Create a new user\n```http\nPOST /users\nAuthorization: Bearer \u003ctoken\u003e\n{\n\"username\": \"string\",\n\"password\": \"string\",\n\"email\": \"string\",\n\"is_admin\": boolean\n}\n```\n\n- Authenticate\n```http\nPOST /auth\n{\n\"username\": \"string\",\n\"password\": \"string\"\n}\n```\n\n- Get a list of users\n```http\nGET /users\nAuthorization: Bearer \u003ctoken\u003e\n```\n\n- Delete an existing user\n```http\nDELETE /users/\u003cusername\u003e\nAuthorization: Bearer \u003ctoken\u003e\n```\n\n---\nLicense: MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarirs%2Frocket-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarirs%2Frocket-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarirs%2Frocket-jwt/lists"}