{"id":25023184,"url":"https://github.com/eser/jwtauth-svc","last_synced_at":"2025-07-04T09:08:13.483Z","repository":{"id":273205832,"uuid":"917545068","full_name":"eser/jwtauth-svc","owner":"eser","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-21T22:26:38.000Z","size":13,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T09:50:04.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eser.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":"2025-01-16T07:34:35.000Z","updated_at":"2025-01-16T07:35:08.000Z","dependencies_parsed_at":"2025-01-19T13:44:34.803Z","dependency_job_id":null,"html_url":"https://github.com/eser/jwtauth-svc","commit_stats":null,"previous_names":["eser/jwtauth-svc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eser/jwtauth-svc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eser%2Fjwtauth-svc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eser%2Fjwtauth-svc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eser%2Fjwtauth-svc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eser%2Fjwtauth-svc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eser","download_url":"https://codeload.github.com/eser/jwtauth-svc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eser%2Fjwtauth-svc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263480902,"owners_count":23473165,"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":[],"created_at":"2025-02-05T14:37:18.215Z","updated_at":"2025-07-04T09:08:13.443Z","avatar_url":"https://github.com/eser.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Playground\n\nA Go application demonstrating JWT-based authentication with support for both service and user authentication flows.\n\n## Features\n\n- Service authentication with JWT (RSA-based)\n- User authentication with JWT (HMAC-based)\n- Token refresh mechanism\n- Audience-based token differentiation\n- Protected routes with JWT middleware\n- Multiple authentication strategies (Secret Key and Service Account)\n- Comprehensive test coverage\n\n## Setup\n\n1. Clone the repository\n2. Copy `.env.example` to `.env` and configure your environment variables\n3. Install dependencies:\n   ```bash\n   make mod\n   ```\n4. Run the application:\n   ```bash\n   make run\n   ```\n\n## Available Make Commands\n\n- `make build` - Build the binary\n- `make test` - Run unit tests\n- `make coverage` - Generate test coverage report\n- `make lint` - Run linters\n- `make fmt` - Format code\n- `make vet` - Run go vet\n- `make mod` - Download and tidy dependencies\n- `make clean` - Clean build files\n- `make help` - Display help information\n\n## API Endpoints\n\n### Authentication\n\n- `POST /auth/service/token` - Generate service token\n  ```json\n  {\n    \"service_id\": \"your-service-id\"\n  }\n  ```\n\n- `POST /auth/user/token` - Generate user token\n  ```json\n  {\n    \"user_id\": \"your-user-id\"\n  }\n  ```\n\n- `POST /auth/token/refresh` - Refresh token\n  ```json\n  {\n    \"token\": \"your-existing-token\"\n  }\n  ```\n\n### Protected Routes\n\n- `GET /protected` - Example protected route\n  - Requires Authorization header: `Bearer your-token`\n\n## Token Types\n\n### Service Tokens\n- Audience: \"service\"\n- Longer expiration time (24 hours)\n- Uses RSA-based signing (when using ServiceAccountStrategy)\n- Includes read/write permissions\n- Intended for service-to-service communication\n\n### User Tokens\n- Audience: \"user\"\n- Shorter expiration time (1 hour)\n- Uses HMAC-based signing (when using SecretKeyStrategy)\n- Includes read-only permissions\n- Intended for user authentication\n\n## Authentication Strategies\n\n### Secret Key Strategy (HMAC)\n- Default strategy for simple deployments\n- Uses symmetric encryption with a shared secret key\n- Suitable for user authentication\n\n### Service Account Strategy (RSA)\n- Advanced strategy for service-to-service communication\n- Uses asymmetric encryption with public/private key pairs\n- Supports multiple service accounts with different permissions\n- Requires RSA key pair configuration\n\n## Security Notes\n\n1. Change the JWT secret key in production\n2. Use HTTPS in production\n3. Implement rate limiting for token generation endpoints\n4. Consider implementing token revocation mechanism for production use\n5. Properly secure and rotate RSA private keys when using service accounts\n6. Configure appropriate CORS and security headers in production\n\n## Dependencies\n\n- Go 1.23.4\n- github.com/golang-jwt/jwt/v5 v5.2.1\n\n## License\n\nLicensed under the Apache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feser%2Fjwtauth-svc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feser%2Fjwtauth-svc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feser%2Fjwtauth-svc/lists"}