{"id":31738151,"url":"https://github.com/robert076/auth-service","last_synced_at":"2025-10-09T09:53:22.629Z","repository":{"id":298859236,"uuid":"1000998471","full_name":"Robert076/auth-service","owner":"Robert076","description":"A standalone microservice that implements authorization using a PostgreSQL database and implemented in Go. Plug and play your own db (uses strategy pattern, easily scalable).","archived":false,"fork":false,"pushed_at":"2025-07-02T06:23:44.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-02T07:23:41.214Z","etag":null,"topics":["api","authentication","bcrypt","golang","microservice","rest-api","scalable","strategy-design-pattern"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Robert076.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":"2025-06-12T16:42:19.000Z","updated_at":"2025-07-02T06:23:47.000Z","dependencies_parsed_at":"2025-07-02T07:21:20.465Z","dependency_job_id":"3804dfe4-f711-407c-b323-351426e674a7","html_url":"https://github.com/Robert076/auth-service","commit_stats":null,"previous_names":["robert076/auth-service"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Robert076/auth-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Robert076%2Fauth-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Robert076%2Fauth-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Robert076%2Fauth-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Robert076%2Fauth-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Robert076","download_url":"https://codeload.github.com/Robert076/auth-service/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Robert076%2Fauth-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001068,"owners_count":26083022,"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-09T02:00:07.460Z","response_time":59,"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":["api","authentication","bcrypt","golang","microservice","rest-api","scalable","strategy-design-pattern"],"created_at":"2025-10-09T09:53:16.677Z","updated_at":"2025-10-09T09:53:22.624Z","avatar_url":"https://github.com/Robert076.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔐 auth-service\n\nA standalone microservice that implements authorization using a PostgreSQL database and implemented in Go.\n\nJust clone the repo and run it on your machine, plug in your database and just have fun with it.\n\nIf you have a different users table please do modify the register DTO to include everything you need. Apart from that you can easily change the db type since it's using the strategy pattern making adjusting the db easy.\n\n## ✍🏻 Diagram\n\n\u003cimg width=\"600\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/df9176bd-2de7-420d-803b-33977e86e2f5\" /\u003e\n\n---\n\n## 🚀 Run command\n\n```bash\ndocker compose up --build\n```\n\n### ⚙️ Example .env file\n\n```\nENDPOINT_PORT=5656\nDB_TYPE=postgres\nDB_HOST=postgres-service\nPOSTGRES_USER=admin\nPOSTGRES_PASSWORD=admin\nDB_PORT=5432\nPOSTGRES_NAME=authservicedb\nDB_SSLMODE=disable\nENVIRONMENT=PRODUCTION\n```\n\n## 💻 How it works\n\nMake a `POST` request to the `/register` endpoint with the corresponding body (check the register dto) and the account gets created\n\nMake a `POST` request to the `/login` endpoint with email and password, and if password hash matches (from db) it returns 200 (this is how you will know the login was succesful)\n\nMake a `POST` request to the `/authorize` endpoint with the email attached and if the session token + csrf token match (include csrf token in header when making the request) you get 200\n\nMake a `POST` request to `/logout` with the email attached. (You must have the `cookies` and the header with the `csrf token` for the request)\n\n## 🧩 Adding another database\n\nYou can easily swap out db's with one another since the code is not coupled to a certain database, it actually makes use of interfaces using the strategy pattern to enable you to add whatever db you prefer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobert076%2Fauth-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobert076%2Fauth-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobert076%2Fauth-service/lists"}