{"id":19225890,"url":"https://github.com/thoriqdharmawan/go-jwt-mux","last_synced_at":"2026-06-26T13:30:17.416Z","repository":{"id":257566584,"uuid":"858616799","full_name":"thoriqdharmawan/go-jwt-mux","owner":"thoriqdharmawan","description":"REST API project built with Golang, featuring JWT authentication, Gorilla Mux routing","archived":false,"fork":false,"pushed_at":"2024-09-17T10:15:57.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-04T21:32:42.199Z","etag":null,"topics":["golang","gorilla","jwt","mux"],"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/thoriqdharmawan.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-09-17T08:20:01.000Z","updated_at":"2024-09-17T10:18:03.000Z","dependencies_parsed_at":"2024-09-17T12:57:15.961Z","dependency_job_id":"f69ed0e0-3af5-4420-ab0c-1a109c4e049c","html_url":"https://github.com/thoriqdharmawan/go-jwt-mux","commit_stats":null,"previous_names":["thoriqdharmawan/go-jwt-mux"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoriqdharmawan%2Fgo-jwt-mux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoriqdharmawan%2Fgo-jwt-mux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoriqdharmawan%2Fgo-jwt-mux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoriqdharmawan%2Fgo-jwt-mux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thoriqdharmawan","download_url":"https://codeload.github.com/thoriqdharmawan/go-jwt-mux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240298798,"owners_count":19779338,"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":["golang","gorilla","jwt","mux"],"created_at":"2024-11-09T15:16:43.835Z","updated_at":"2026-06-26T13:30:17.334Z","avatar_url":"https://github.com/thoriqdharmawan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛡️ Golang JWT Authentication with Gorilla Mux\n\nThis project is a simple REST API built with Golang, using JWT (JSON Web Token) for authentication and Gorilla Mux as the HTTP router. \n\n## 🚀 Features\n\n- 🔒 **User Authentication (Login \u0026 Register)** with JWT\n- 🍪 **JWT Token stored in Cookies** for secure access\n- 📦 **Dummy Products API** for demonstration purposes\n- 🛡️ **JWT Middleware** to protect certain routes\n\n## 🔧 Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/thoriqdharmawan/go-jwt-mux.git\n   cd go-jwt-mux\n   ```\n\n2. Install the required dependencies:\n   ```bash\n   go mod tidy\n   ```\n\n3. Set up your database connection in the `models` package.\n\n4. Run the project:\n   ```bash\n   go run main.go\n   ```\n\n## 🛠️ Endpoints\n\n| Method | Endpoint      | Description                 | Auth Required? |\n|--------|---------------|-----------------------------|----------------|\n| POST   | `/login`       | Login user and generate JWT | ❌              |\n| POST   | `/register`    | Register new user           | ❌              |\n| GET    | `/logout`      | Logout user                 | ❌              |\n| GET    | `/api/products`| Get dummy product data      | ✅              |\n\n## 🛡️ JWT Middleware\n\nThe `/api/products` route is protected by the JWT middleware, ensuring that only authenticated users can access it.\n\n## 📦 Dummy Product Data\n\nThe `productscontroller` currently serves static, dummy product data for demonstration purposes. This can be replaced with real data from a database in the future.\n\n## 🔐 Authentication Flow\n\n1. **Register**: Create a new user by sending a `POST` request to `/register` with a `username` and `password`.\n2. **Login**: After registering, login via `/login`. This will return a JWT token in a cookie.\n3. **Access Protected Routes**: Use the JWT token to access protected routes such as `/api/products`.\n4. **Logout**: Clear the token by hitting `/logout`.\n\n## 🔑 Technologies Used\n\n- **Golang** 🐹\n- **Gorilla Mux** 🦍\n- **JWT** 🔑\n- **GORM** 🗄️\n\n## ✨ Future Improvements\n\n- Integrate with a real product database.\n- Improve error handling.\n- Add more user roles and permissions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoriqdharmawan%2Fgo-jwt-mux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoriqdharmawan%2Fgo-jwt-mux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoriqdharmawan%2Fgo-jwt-mux/lists"}