{"id":23228987,"url":"https://github.com/barcodehub/advanced-authservice-crud-microservices","last_synced_at":"2025-04-05T18:29:43.596Z","repository":{"id":254215482,"uuid":"845027372","full_name":"Barcodehub/advanced-authservice-crud-microservices","owner":"Barcodehub","description":" Microservices-based API provides user advanced authentication and basic product management functionality.","archived":false,"fork":false,"pushed_at":"2024-08-22T02:14:04.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T15:53:27.640Z","etag":null,"topics":["api-gateway","cookie-parser","csrf-protection","jwt-authentication","microservices","product-management"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Barcodehub.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}},"created_at":"2024-08-20T12:47:44.000Z","updated_at":"2024-08-22T18:46:36.000Z","dependencies_parsed_at":"2024-08-22T04:29:43.232Z","dependency_job_id":"4c37a4cc-30d4-43c5-ad07-62811095c6e7","html_url":"https://github.com/Barcodehub/advanced-authservice-crud-microservices","commit_stats":null,"previous_names":["barcodehub/advanced-authservice-crud-microservices"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barcodehub%2Fadvanced-authservice-crud-microservices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barcodehub%2Fadvanced-authservice-crud-microservices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barcodehub%2Fadvanced-authservice-crud-microservices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barcodehub%2Fadvanced-authservice-crud-microservices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Barcodehub","download_url":"https://codeload.github.com/Barcodehub/advanced-authservice-crud-microservices/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247383011,"owners_count":20930196,"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-gateway","cookie-parser","csrf-protection","jwt-authentication","microservices","product-management"],"created_at":"2024-12-19T01:15:49.617Z","updated_at":"2025-04-05T18:29:43.570Z","avatar_url":"https://github.com/Barcodehub.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Microservices-Based JWT Authentication and Product Management API\n\nThis project is a microservices-based API built with Node.js, Express, and MongoDB. It provides a comprehensive authentication system with advanced security features including Two-Factor Authentication (2FA), and basic product management functionality. The system consists of three main services: an API Gateway, an Authentication Service, and a Product Service.\n\n## Table of Contents\n\n- [Architecture](#architecture)\n- [Services](#services)\n- [Environment Variables Setup](#environment-variables-setup)\n- [Installation and Running](#installation-and-running)\n- [API Testing](#api-testing)\n\n\n## Architecture\n\nThe application follows a microservices architecture:\n\n- **API Gateway**: Routes requests to appropriate services\n- **Auth Service**: Handles user authentication and authorization\n- **Product Service**: Manages product-related operations\n\n## Services\n\n### API Gateway\n- Routes requests to auth and product services\n- Handles 404 errors for undefined routes\n\n### Auth Service\n- User registration\n- User login with JWT token generation\n- Role-based access control\n\n### Product Service\n- CRUD operations for products\n- Role-based access to certain operations\n\n\n## Environment Variables Setup\n\nCreate a `.env` file in the root directory and add the following variables:\n\nproduct-services\n```\nMONGO_URI=your-mongodb-uri\nJWT_SECRET=your_jwt_secret_here\n```\n\nauth-services\n```\nMONGODB_URI=your-mongodb-uri\nSESSION_SECRET=your_session_secret_here\nJWT_SECRET=your_jwt_secret_here\nRATE_LIMIT_MAX=100\nRATE_LIMIT_WINDOW_MS=3600000\nBODY_LIMIT=10kb\nSESSION_MAX_AGE=604800000\nADMIN_EMAIL=tu_email_admin@example.com\nADMIN_PASSWORD=tu_contraseña_secreta\n```\napi-gateway\n```\nAUTH_SERVICE_URL=http://localhost:3000\nPRODUCT_SERVICE_URL=http://localhost:3001\n\n```\nor your url.\n\n## Installation and Running\n\nTo run:\n```\nnpm run start\n```\n\n## API Testing\n\n  - GET /api/auth/csrf-token: Retrieve the CSRF token.  \n  - POST /api/auth/register: Register a new user.  \n    ```\n    X-CSRF-Token: token of step 1\n    ```\n    body:\n    ```\n    {\n    \"email\": \"\",\n    \"password\": \"\"\n    }\n    ```\n\n  - POST /api/auth/login: Login a user. \n    ```\n    X-CSRF-Token: token of step 1\n    ```\n    body:\n    ```\n    {\n    \"email\": \"\",\n    \"password\": \"\"\n    }\n    ```\n\n  - POST /api/products: create product\n    ```\n    X-CSRF-Token: token of step 1\n    Authorization: token login admin\n    ```\n    body:\n    ```\n        {\n    \"name\": \"\",\n    \"description\": \"\",\n    \"price\": ,\n    \"stock\": \n        }\n     ```   \n  - GET /api/products: get products\n  - GET /api/products/id: find product \n  - PUT /api/products/id: editar product\n    ```\n    X-CSRF-Token: token of step 1\n    Authorization: token login admin\n    ```\n    body:\n    ```\n        {\n    \"name\": \"\",\n    \"description\": \"\",\n    \"price\": ,\n    \"stock\": \n        }\n     ```  \n  - DELETE /api/products/id: delete product","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarcodehub%2Fadvanced-authservice-crud-microservices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarcodehub%2Fadvanced-authservice-crud-microservices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarcodehub%2Fadvanced-authservice-crud-microservices/lists"}