{"id":26715554,"url":"https://github.com/bmmunga/org-authenticator-api","last_synced_at":"2025-03-27T14:33:17.596Z","repository":{"id":247113096,"uuid":"824773730","full_name":"bmmunga/org-authenticator-api","owner":"bmmunga","description":"A backend API for user authentication, organisation management, and access control. Built with Go, integrating PostgreSQL and JWT for secure operations.","archived":false,"fork":false,"pushed_at":"2024-12-12T19:54:19.000Z","size":11449,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-11T23:33:07.739Z","etag":null,"topics":["go","jwt","postresql","restful-api"],"latest_commit_sha":null,"homepage":"","language":"Go","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/bmmunga.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":"2024-07-05T23:14:16.000Z","updated_at":"2024-12-12T19:54:23.000Z","dependencies_parsed_at":"2024-07-09T09:29:54.872Z","dependency_job_id":"54dc5c1f-d0c9-407b-882b-2a3fcac00d77","html_url":"https://github.com/bmmunga/org-authenticator-api","commit_stats":null,"previous_names":["mungasoftwiz/org-authenticator-api","bmmunga/org-authenticator-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmmunga%2Forg-authenticator-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmmunga%2Forg-authenticator-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmmunga%2Forg-authenticator-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmmunga%2Forg-authenticator-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmmunga","download_url":"https://codeload.github.com/bmmunga/org-authenticator-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245863365,"owners_count":20684836,"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":["go","jwt","postresql","restful-api"],"created_at":"2025-03-27T14:33:16.854Z","updated_at":"2025-03-27T14:33:17.568Z","avatar_url":"https://github.com/bmmunga.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Org-authenticator-api\n\nThis project implements a user authentication and organisation management system using Go.\nThe API supports user registration, login, and organisation management functionalities.\n\n## Table of Contents\n\n- [Features](#features)\n- [Technologies Used](#technologies-used)\n- [Database Setup](#database-setup)\n- [Models](#models)\n- [Endpoints](#endpoints)\n- [Testing](#testing)\n\n## Features\n\n- User Registration and Login\n- JWT Authentication\n- Organisation Creation and Management\n- User Organisation Association\n- Field Validation and Error Handling\n\n## Technologies Used\n\n- Backend Language/Framework: Go\n- Database: PostgreSQL\n- ORM: TBD (optional)\n- Authentication: JWT (JSON Web Tokens)\n\n## Database Setup\n\n1. Install PostgreSQL and create a database.\n2. Configure your application to connect to the PostgreSQL database.\n3. Optionally, set up an ORM of your choice.\n\n## Models\n\n### User Model\n\n```json\n{\n    \"userId\": \"string\", // must be unique\n    \"firstName\": \"string\", // must not be null\n    \"lastName\": \"string\", // must not be null\n    \"email\": \"string\", // must be unique and must not be null\n    \"password\": \"string\", // must not be null\n    \"phone\": \"string\"\n}\n```\n\n### Organisation Model\n\n```json\n{\n    \"orgId\": \"string\", // Unique\n    \"name\": \"string\", // Required and cannot be null\n    \"description\": \"string\"\n}\n```\n\n## Endpoints\n\n### User Authentication \u0026 Register User\n\nEndpoint: POST /auth/register\n\n**Request Body:**\n\n```json\n{\n    \"firstName\": \"string\",\n    \"lastName\": \"string\",\n    \"email\": \"string\",\n    \"password\": \"string\",\n    \"phone\": \"string\"\n}\n```\n\n**Successful Response:**\n\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"Registration successful\",\n    \"data\": {\n        \"accessToken\": \"eyJh...\",\n        \"user\": {\n            \"userId\": \"string\",\n            \"firstName\": \"string\",\n            \"lastName\": \"string\",\n            \"email\": \"string\",\n            \"phone\": \"string\"\n        }\n    }\n}\n```\n\n**Unsuccessful Response:**\n\n```json\n{\n    \"status\": \"Bad request\",\n    \"message\": \"Registration unsuccessful\",\n    \"statusCode\": 400\n}\n```\n\n### Login User\n\nEndpoint: POST /auth/login\n\n**Request Body:**\n\n```json\n{\n    \"email\": \"string\",\n    \"password\": \"string\"\n}\n```\n\n**Successful Response:**\n\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"Login successful\",\n    \"data\": {\n        \"accessToken\": \"eyJh...\",\n        \"user\": {\n            \"userId\": \"string\",\n            \"firstName\": \"string\",\n            \"lastName\": \"string\",\n            \"email\": \"string\",\n            \"phone\": \"string\"\n        }\n    }\n}\n```\n\n**Unsuccessful Response:**\n\n```json\n{\n    \"status\": \"Bad request\",\n    \"message\": \"Authentication failed\",\n    \"statusCode\": 401\n}\n```\n\n## User Endpoints\n\n### Get User Details\n\nEndpoint: GET /api/users/:id\n\n**Successful Response:**\n\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"\u003cmessage\u003e\",\n    \"data\": {\n        \"userId\": \"string\",\n        \"firstName\": \"string\",\n        \"lastName\": \"string\",\n        \"email\": \"string\",\n        \"phone\": \"string\"\n    }\n}\n```\n\n## Organisation Endpoints\n\n### Get All Organisations\n\nEndpoint: GET /api/organisations\n\n**Successful Response:**\n\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"\u003cmessage\u003e\",\n    \"data\": {\n        \"organisations\": [\n            {\n                \"orgId\": \"string\",\n                \"name\": \"string\",\n                \"description\": \"string\"\n            }\n        ]\n    }\n}\n```\n\n### Get Single Organisation\n\nEndpoint: GET /api/organisations/:orgId\n\n**Successful Response:**\n\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"\u003cmessage\u003e\",\n    \"data\": {\n        \"orgId\": \"string\",\n        \"name\": \"string\",\n        \"description\": \"string\"\n    }\n}\n```\n\n### Create Organisation\n\nEndpoint: POST /api/organisations\n\n**Request Body:**\n\n```json\n{\n    \"name\": \"string\",\n    \"description\": \"string\"\n}\n```\n\n**Successful Response:**\n\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"Organisation created successfully\",\n    \"data\": {\n        \"orgId\": \"string\",\n        \"name\": \"string\",\n        \"description\": \"string\"\n    }\n}\n```\n\n**Unsuccessful Response:**\n\n```json\n{\n    \"status\": \"Bad Request\",\n    \"message\": \"Client error\",\n    \"statusCode\": 400\n}\n```\n\n### Add User to Organisation\n\nEndpoint: POST /api/organisations/:orgId/users\n\n**Request Body:**\n\n```json\n{\n    \"userId\": \"string\"\n}\n```\n\n**Successful Response:**\n\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"User added to organisation successfully\"\n}\n```\n\n## Testing\n\n- Unit Testing\n\n- Token generation: Ensure token expires at the correct time and correct user details are found in token.\n\n- Organisation: Ensure users can’t see data from organisations they don’t have access to.\n\n- End-to-End Test Requirements for the Register Endpoint\n\n- Directory Structure: Create a tests folder with the test file named `auth.spec.ext`.\n\n### Test Scenarios:\n\n- Register user successfully with default organisation.\n- Log the user in successfully.\n- Fail if required fields are missing.\n- Fail if there’s a duplicate email or userID.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmmunga%2Forg-authenticator-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmmunga%2Forg-authenticator-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmmunga%2Forg-authenticator-api/lists"}