{"id":24708783,"url":"https://github.com/kimgoetzke/practice-go-jwt-auth","last_synced_at":"2026-07-03T16:32:36.513Z","repository":{"id":273244917,"uuid":"919048033","full_name":"kimgoetzke/practice-go-jwt-auth","owner":"kimgoetzke","description":"Mini-project to experiment using JWTs with a public JWKS endpoint for authentication in Go.","archived":false,"fork":false,"pushed_at":"2025-01-19T17:47:35.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T12:37:45.124Z","etag":null,"topics":["auth-middleware","authentication","golang","golang-jwt","jwks","jwt"],"latest_commit_sha":null,"homepage":"","language":"Go","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/kimgoetzke.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-19T15:24:06.000Z","updated_at":"2025-01-19T17:47:37.000Z","dependencies_parsed_at":"2025-01-19T18:38:24.924Z","dependency_job_id":"45ea45a3-b3f9-4bcf-abd8-e7e9900b82b5","html_url":"https://github.com/kimgoetzke/practice-go-jwt-auth","commit_stats":null,"previous_names":["kimgoetzke/practice-go-jwt-auth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kimgoetzke/practice-go-jwt-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimgoetzke%2Fpractice-go-jwt-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimgoetzke%2Fpractice-go-jwt-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimgoetzke%2Fpractice-go-jwt-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimgoetzke%2Fpractice-go-jwt-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kimgoetzke","download_url":"https://codeload.github.com/kimgoetzke/practice-go-jwt-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimgoetzke%2Fpractice-go-jwt-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35094062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"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":["auth-middleware","authentication","golang","golang-jwt","jwks","jwt"],"created_at":"2025-01-27T06:47:29.893Z","updated_at":"2026-07-03T16:32:36.489Z","avatar_url":"https://github.com/kimgoetzke.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Practice Go JWT authentication\n\nThis is a simple project that provides a protected endpoint that requires a valid JWT. It was my first time writing Go\nand was created as a practice project prior to using Go to write a custom authoriser for an AWS API Gateway. The project\nuses:\n\n- [github.com/golang-jwt/jwt](https://github.com/golang-jwt/jwt) to parse and validate the JWT\n- [github.com/MicahParks/keyfunc](https://github.com/MicahParks/keyfunc) to provide a `jwt.Keyfunc` for the above that\n  fetches the JWKs from a JWKS\n  endpoint\n- [github.com/MicahParks/jwkset](https://github.com/MicahParks/jwkset) to generate and fetch the JWKs from a JWKS\n  endpoint\n\n## Overview\n\n- This application is a simple Go server that provides:\n    - `POST` `/register` - Register a new user with a username and password\n    - `POST` `/login` - Login with a username and password to receive a JWT\n    - `POST` `/protected` - A protected endpoint that requires a valid JWT\n    - `GET` `/.well-known/jwks.json` - The JWKS endpoint called when validating JWTs\n    - `POST` `/logout` - Logout and remove the JWT\n- The server uses a simple in-memory store (no caching) for the users and JWKS\n- On startup, the application generates a new key pair\n- A basic middleware layer is used basic request logging and panic recovery\n- A preconfigured Postman collection is provided in the `assets/postman` directory\n\n## Configuration\n\nThe application will look for the following environment variables:\n\n- `JWKS_BASE_URL` - default: `http://localhost:8080`, will append `/.well-known/jwks.json` to fetch the JWKS\n- `JWK_PRIVATE_KEY` - the private key to sign the JWTs; must be one of the following:\n    - The path to a PEM file containing the private key (e.g. `path/to/private.pem`)\n    - The private key itself in PEM format\n    - Empty or not provided to generate a new key pair on startup\n\n## How to develop\n\n### Using Nix\n\nIf you have direnv installed, use `direnv allow` to start a simple development shell.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimgoetzke%2Fpractice-go-jwt-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkimgoetzke%2Fpractice-go-jwt-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimgoetzke%2Fpractice-go-jwt-auth/lists"}