{"id":24489687,"url":"https://github.com/rahulc0dy/micro-auth","last_synced_at":"2025-10-11T21:14:26.184Z","repository":{"id":273347761,"uuid":"919332252","full_name":"rahulc0dy/micro-auth","owner":"rahulc0dy","description":"This is an authentication microservice built using Hono. [ WORK IN PROGRESS ]","archived":false,"fork":false,"pushed_at":"2025-06-09T07:03:31.000Z","size":298,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-11T21:14:25.149Z","etag":null,"topics":["authentication","authentication-backend","bun","honojs","nodejs","open-source"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/rahulc0dy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-20T07:44:07.000Z","updated_at":"2025-06-09T07:03:36.000Z","dependencies_parsed_at":"2025-01-20T11:31:44.743Z","dependency_job_id":"1bfb52ed-a2e6-4fdd-8992-2c8ddd5219bf","html_url":"https://github.com/rahulc0dy/micro-auth","commit_stats":null,"previous_names":["rahulc0dy/micro-auth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rahulc0dy/micro-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulc0dy%2Fmicro-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulc0dy%2Fmicro-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulc0dy%2Fmicro-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulc0dy%2Fmicro-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahulc0dy","download_url":"https://codeload.github.com/rahulc0dy/micro-auth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulc0dy%2Fmicro-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008744,"owners_count":26084495,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["authentication","authentication-backend","bun","honojs","nodejs","open-source"],"created_at":"2025-01-21T17:15:24.367Z","updated_at":"2025-10-11T21:14:26.144Z","avatar_url":"https://github.com/rahulc0dy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"media/logo.png\" alt=\"Authentication Microservice Logo\" style=\"padding:10px\" width=\"200\"\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://github.com/rahulc0dy/micro-auth/releases\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/1.0.0-teal?label=version\" alt=\"Release Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/rahulc0dy/micro-auth/issues\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues/rahulc0dy/micro-auth\" alt=\"GitHub Issues\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/rahulc0dy/micro-auth\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/rahulc0dy/micro-auth\" alt=\"GitHub Stars\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n# Micro Auth\n\nA robust authentication microservice built with [Bun](https://bun.sh/) and [Hono](https://hono.dev/).  \nThis microservice provides essential authentication features, including support for **JWT**, **OAuth**, **Email/Phone\nand Password Login**, and **Two-Factor Authentication (2FA)**.\n\n---\n\n[![Tests](https://github.com/rahulc0dy/micro-auth/actions/workflows/run-tests.yml/badge.svg)](https://github.com/rahulc0dy/micro-auth/actions/workflows/run-tests.yml)\n[![Builds](https://github.com/rahulc0dy/micro-auth/actions/workflows/lint.yml/badge.svg)](https://github.com/rahulc0dy/micro-auth/actions/workflows/lint.yml)\n\n---\n\n## 🚀 Features\n\n- **🔒 JWT (JSON Web Tokens)**: Secure token-based authentication for stateless session management.\n- **🌐 OAuth**: Simplified third-party authentication using providers like Google, Facebook, and GitHub.\n- **📧 Email/Phone and Password Login**: Standard user authentication using email or phone.\n- **🛡️ Two-Factor Authentication (2FA)**: Enhanced security with OTP-based verification.\n\n---\n\n## 📋 Table of Contents\n\n- [Prerequisites](#-prerequisites)\n- [Setup](#-setup)\n- [Environment Variables](#-environment-variables)\n- [API Endpoints](#-api-endpoints)\n- [Usage](#-usage)\n- [Technologies Used](#-technologies-used)\n- [License](#-license)\n- [Contributing](#contributing)\n\n---\n\n## ✅ Prerequisites\n\n- [Bun](https://bun.sh/) (v1.2 or higher)\n- [Git](https://git-scm.com/) (v2.0 or higher)\n- [Docker](https://www.docker.com/) (optional, for containerized deployment)\n- [Node.js](https://nodejs.org/) (if using scripts/tools that require Node)\n\n---\n\n## ⚙️ Setup\n\n1. **Clone the repository:**\n\n   ```bash\n   git clone https://github.com/rahulc0dy/micro-auth.git\n   cd micro-auth\n   ```\n\n2. **Set up environment variables:**\n\n   Create a `.env.production` or `.env` file in the root directory, using variables outlined in `.env.example`.\n\n3. **Install dependencies:**\n\n   ```bash\n   bun install\n   ```\n\n4. **Run the application:**\n   ```bash\n   bun run index.ts\n   ```\n   Or use Docker Compose:\n   ```bash\n   docker-compose up --build\n   ```\n\n---\n\n## 🛠️ Environment Variables\n\nCreate a `.env.production` or `.env` file in the root of your project with variables specified in the `.env.example`\nfile.  \nWhen deploying with Docker Compose, environment variables are injected at runtime and **not bundled in the image** (see\n`.dockerignore`).\n\n---\n\n## 🌐 API Endpoints\n\n### Authentication\n\n#### **POST** `/auth/register`\n\n- **Description**: Register a new user with email/phone and password.\n- **Request Body:**\n  ```json\n  {\n    \"email\": \"user@example.com\",\n    \"password\": \"securepassword\"\n  }\n  ```\n\n#### **POST** `/auth/login`\n\n- **Description**: Login with email/phone and password.\n- **Request Body:**\n  ```json\n  {\n    \"email\": \"user@example.com\",\n    \"password\": \"securepassword\"\n  }\n  ```\n\n#### **POST** `/auth/refresh`\n\n- **Description**: Refresh the JWT token.\n\n#### **POST** `/auth/logout`\n\n- **Description**: Logout and invalidate the current session.\n\n### OAuth\n\n#### **GET** `/oauth/:provider`\n\n- **Description**: Redirect to the OAuth provider's login page (e.g., Google).\n\n#### **GET** `/oauth/callback`\n\n- **Description**: Handle the OAuth callback and issue a JWT token.\n\n### 2FA\n\n#### **POST** `/auth/2fa/setup`\n\n- **Description**: Generate a 2FA QR code for the user.\n\n#### **POST** `/auth/2fa/verify`\n\n- **Description**: Verify the OTP code for 2FA.\n- **Request Body:**\n  ```json\n  {\n    \"otp\": \"123456\"\n  }\n  ```\n\n---\n\n## 📌 Usage\n\n### Register a New User\n\n```bash\ncurl -X POST http://localhost:8000/auth/register\n    -H \"Content-Type: application/json\"\n    -d '{ \"email\": \"user@example.com\", \"password\": \"securepassword\" }'\n```\n\n### Login\n\n```bash\ncurl -X POST http://localhost:8000/auth/login\n    -H \"Content-Type: application/json\"\n    -d '{ \"email\": \"user@example.com\", \"password\": \"securepassword\" }'\n```\n\n### Set Up 2FA\n\n```bash\ncurl -X POST http://localhost:8000/auth/2fa/setup\n    -H \"Authorization: Bearer \u003cJWT_TOKEN\u003e\"\n```\n\n### Verify 2FA Code\n\n```bash\ncurl -X POST http://localhost:8000/auth/2fa/verify\n    -H \"Authorization: Bearer \u003cJWT_TOKEN\u003e\"\n    -d '{ \"otp\": \"123456\" }'\n```\n\n---\n\n## 🛠️ Technologies Used\n\n- **Bun**: Ultra-fast JavaScript runtime\n- **Hono**: Lightweight and fast web framework\n- **Drizzle ORM**: SQL ORM for type-safe database access\n- **PostgreSQL**: Database backend (with support for `DATABASE_URL`)\n- **JWT**: Secure token management\n- **OAuth**: Third-party authentication\n- **Two-Factor Authentication**: Enhanced user security\n\n---\n\n## 📜 License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Contributing\n\nWe welcome contributions to make Micro Auth better for everyone.  \nPlease review our [Contributing Guidelines](https://github.com/rahulc0dy/micro-auth/blob/master/docs/CONTRIBUTING.md) to\nget started.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulc0dy%2Fmicro-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahulc0dy%2Fmicro-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulc0dy%2Fmicro-auth/lists"}