{"id":18359165,"url":"https://github.com/cihansari/simpleauthentication","last_synced_at":"2025-07-28T20:08:47.922Z","repository":{"id":95977306,"uuid":"418451315","full_name":"CihanSari/SimpleAuthentication","owner":"CihanSari","description":"Authentication example based on NodeJS JWT MongoDB","archived":false,"fork":false,"pushed_at":"2022-01-04T11:07:39.000Z","size":153,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T03:59:12.554Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/CihanSari.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":"2021-10-18T10:28:07.000Z","updated_at":"2022-01-04T11:07:42.000Z","dependencies_parsed_at":"2023-04-26T12:00:42.114Z","dependency_job_id":null,"html_url":"https://github.com/CihanSari/SimpleAuthentication","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CihanSari/SimpleAuthentication","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CihanSari%2FSimpleAuthentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CihanSari%2FSimpleAuthentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CihanSari%2FSimpleAuthentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CihanSari%2FSimpleAuthentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CihanSari","download_url":"https://codeload.github.com/CihanSari/SimpleAuthentication/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CihanSari%2FSimpleAuthentication/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267577976,"owners_count":24110350,"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-07-28T02:00:09.689Z","response_time":68,"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":[],"created_at":"2024-11-05T22:21:11.208Z","updated_at":"2025-07-28T20:08:47.867Z","avatar_url":"https://github.com/CihanSari.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Authentication Example\n\nThis repository contains authentication example with jwt tokens.\n\n## Details\n\n- User can register and login with email and password.\n- Tokens are valid for 5 minutes (can be modified upon specification)\n- Client-side logout can be performed by removing the token. If really required, another lookup table (e.g. on redis or on cockroach) can be issued to blacklist tokens.\n- Server can be started by `docker build --tag docker-goauthserver .` followed by `docker-compose up`\n- Endpoint documentation is provided in openapi3 specification using swagger. Accessible at: http://localhost:8080/api/docs\n- JSON file for endpoints can be accessed by http://localhost:8080/api/swagger.json. If required, https://editor.swagger.io/ can be used to convert it to YAML format.\n\n## Test\n\nRegister\n\n```bash\ncurl -X 'POST' \\\n  'http://localhost:4000/api/auth/register' \\\n  -H 'accept: application/json' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n  \"email\": \"example@mail.com\",\n  \"password\": \"EH62zsK4qb~^.b/@\",\n  \"roles\": [\n    \"user\",\n    \"moderator\",\n    \"admin\"\n  ]\n}'\n```\n\nLogin\n\n```bash\ncurl -X 'POST' \\\n  'http://localhost:4000/api/auth/login' \\\n  -H 'accept: application/json' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n  \"email\": \"example@mail.com\",\n  \"password\": \"EH62zsK4qb~^.b/@\"\n}'\n```\n\n\nGuest API (all access)\n\n```bash\ncurl -X 'GET' \\\n  'http://localhost:4000/api/test/guest' \\\n  -H 'accept: text/plain'\n```\n\n\nUser API **(IMPORTANT: update x-access-token from login response)**\n\n```bash\ncurl -X 'GET' \\\n  'http://localhost:4000/api/test/user' \\\n  -H 'accept: text/plain' \\\n  -H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6IjcyNDg5NzUwOTE5NzMxNjA5OSIsIkVtYWlsIjoiZXhhbXBsZUBtYWlsLmNvbSIsIlJvbGVzIjpbInVzZXIiLCJtb2RlcmF0b3IiLCJhZG1pbiJdLCJleHAiOjE2NDEyOTI5ODUsImlhdCI6MTY0MTI5MjY4NSwiaXNzIjoiYXV0aC1leGFtcGxlIn0.ALyH30EZ-McTmfPxr0mymh-Si9pik1wpTIlMlZs6JAw'\n```\n\n\nModerator API **(IMPORTANT: update x-access-token from login response)**\n\n```bash\ncurl -X 'GET' \\\n  'http://localhost:4000/api/test/moderator' \\\n  -H 'accept: text/plain' \\\n  -H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6IjcyNDg5NzUwOTE5NzMxNjA5OSIsIkVtYWlsIjoiZXhhbXBsZUBtYWlsLmNvbSIsIlJvbGVzIjpbInVzZXIiLCJtb2RlcmF0b3IiLCJhZG1pbiJdLCJleHAiOjE2NDEyOTI5ODUsImlhdCI6MTY0MTI5MjY4NSwiaXNzIjoiYXV0aC1leGFtcGxlIn0.ALyH30EZ-McTmfPxr0mymh-Si9pik1wpTIlMlZs6JAw'\n```\n\nAdmin API **(IMPORTANT: update x-access-token from login response)**\n\n```bash\ncurl -X 'GET' \\\n  'http://localhost:4000/api/test/admin' \\\n  -H 'accept: text/plain' \\\n  -H 'x-access-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJZCI6IjcyNDg5NzUwOTE5NzMxNjA5OSIsIkVtYWlsIjoiZXhhbXBsZUBtYWlsLmNvbSIsIlJvbGVzIjpbInVzZXIiLCJtb2RlcmF0b3IiLCJhZG1pbiJdLCJleHAiOjE2NDEyOTI5ODUsImlhdCI6MTY0MTI5MjY4NSwiaXNzIjoiYXV0aC1leGFtcGxlIn0.ALyH30EZ-McTmfPxr0mymh-Si9pik1wpTIlMlZs6JAw'\n```\n\n\n\n## Known issues\n\n- We have no automation tests. In the future upon request one could automate registration / login and consecutive accesses. \n- We have no protection against denial of service attacks. I assume this will be handled prior to the server connection.\n- DB access differs between go and nodejs. Can't run concurrently.\n- Anyone can register.\n- There are no help on database restoration.\n- Couldn't test on different development environments (tested on WSL only). \n\n## Final thoughts\n\nIf there are any questions, issues or errors, please feel free to get in touch.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcihansari%2Fsimpleauthentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcihansari%2Fsimpleauthentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcihansari%2Fsimpleauthentication/lists"}