{"id":20040862,"url":"https://github.com/saeedmaldosary/go-authentication-jwt","last_synced_at":"2026-05-12T17:45:18.654Z","repository":{"id":189730749,"uuid":"681167171","full_name":"saeedmaldosary/Go-Authentication-JWT","owner":"saeedmaldosary","description":"Go-Authentication-JWT is a robust authentication system built using Go (Golang). It leverages the power of JWT (JSON Web Tokens) to provide secure token-based authentication for applications. The project is designed with modularity in mind, making it easy to integrate with existing Go applications or to use as a foundation for new projects.","archived":false,"fork":false,"pushed_at":"2023-08-24T07:59:55.000Z","size":84532,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-12T19:22:18.270Z","etag":null,"topics":["authentication","gin","go","jwt"],"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/saeedmaldosary.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":"2023-08-21T12:17:22.000Z","updated_at":"2023-08-24T08:02:44.000Z","dependencies_parsed_at":"2024-11-13T10:54:28.281Z","dependency_job_id":null,"html_url":"https://github.com/saeedmaldosary/Go-Authentication-JWT","commit_stats":null,"previous_names":["saeedmaldosary/go-authentication-jwt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saeedmaldosary%2FGo-Authentication-JWT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saeedmaldosary%2FGo-Authentication-JWT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saeedmaldosary%2FGo-Authentication-JWT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saeedmaldosary%2FGo-Authentication-JWT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saeedmaldosary","download_url":"https://codeload.github.com/saeedmaldosary/Go-Authentication-JWT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241470364,"owners_count":19968041,"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":["authentication","gin","go","jwt"],"created_at":"2024-11-13T10:44:22.103Z","updated_at":"2026-05-12T17:45:18.609Z","avatar_url":"https://github.com/saeedmaldosary.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go-Authentication-JWT\n\nA simple Go application that demonstrates user authentication using JWT (JSON Web Tokens).\n\n## Features\n\n- **User Signup**: Allows new users to register.\n- **User Login**: Authenticates users and provides a JWT token.\n- **Token Validation**: Validates the provided JWT token.\n\n## Setup and Initialization\n\n1. **Environment Variables**: Ensure you have a `.env` file with the necessary environment variables. The application uses `godotenv` to load these variables.\n   \n2. **Database Connection**: The application connects to a PostgreSQL database. The connection string is fetched from the environment variable `DB`.\n\n3. **Database Synchronization**: The application uses GORM for ORM and automatically migrates the user model to the database.\n\n## Endpoints\n\n- **Signup**: `POST /signup`\n  - Payload: \n    ```json\n    {\n      \"Email\": \"example@email.com\",\n      \"Password\": \"your_password\"\n    }\n    ```\n  \n- **Login**: `POST /login`\n  - Payload:\n    ```json\n    {\n      \"Email\": \"example@email.com\",\n      \"Password\": \"your_password\"\n    }\n    ```\n  - Response: Returns a JWT token.\n\n- **Validate**: `GET /validate`\n  - Requires JWT token in the `Authorization` cookie. Validates the token and returns the associated user.\n\n## Middleware\n\n- **RequireAuth**: This middleware checks for the `Authorization` cookie in the request, decodes the JWT token, validates it, and attaches the associated user to the request.\n\n## Models\n\n- **User Model**: Represents a user with fields `Email` and `Password`. The email is unique for each user.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaeedmaldosary%2Fgo-authentication-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaeedmaldosary%2Fgo-authentication-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaeedmaldosary%2Fgo-authentication-jwt/lists"}