{"id":23141672,"url":"https://github.com/zekrotja/jwt","last_synced_at":"2025-04-04T11:22:42.502Z","repository":{"id":41870951,"uuid":"485047166","full_name":"zekroTJA/jwt","owner":"zekroTJA","description":"A very simplistic implementation of JWT taking advantage of Go 1.18 generic type parameters for parsing claim objects.","archived":false,"fork":false,"pushed_at":"2023-10-09T11:41:47.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T17:53:31.237Z","etag":null,"topics":["generic","go","go118","hacktoberfest","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/zekroTJA.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}},"created_at":"2022-04-24T14:17:42.000Z","updated_at":"2022-10-01T16:14:55.000Z","dependencies_parsed_at":"2022-08-11T19:50:29.409Z","dependency_job_id":null,"html_url":"https://github.com/zekroTJA/jwt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zekroTJA%2Fjwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zekroTJA%2Fjwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zekroTJA%2Fjwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zekroTJA%2Fjwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zekroTJA","download_url":"https://codeload.github.com/zekroTJA/jwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166880,"owners_count":20894808,"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":["generic","go","go118","hacktoberfest","jwt"],"created_at":"2024-12-17T14:14:09.811Z","updated_at":"2025-04-04T11:22:42.451Z","avatar_url":"https://github.com/zekroTJA.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jwt\n\nThis is a very simplistic implementation of JWT using hashing algorithms like `HS256` or `HS512` and taking advantage of Go 1.18 generic type parameters for parsing claim objects.\n\nThis package is very much inspired and influenced by [robbert229's JWT implementation](https://github.com/robbert229/jwt). [Here](https://github.com/robbert229/jwt/blob/master/LICENSE) you can find the projects License.\n\n## Usage\n\n```go\nconst signingSecret = \"3U5o3Z#XqfLpr3pjGknwWa^u6)CCo\u0026\u0026G\"\n\nalgorithm := jwt.NewHmacSha512([]byte(signingSecret))\nhandler := jwt.NewHandler[Claims](algorithm)\n\nclaims := new(Claims)\nclaims.UserID = \"221905671296253953\"\nclaims.Iss = \"jwt example\"\nclaims.SetIat()\nclaims.SetExpDuration(15 * time.Minute)\nclaims.SetNbfTime(time.Now())\n\ntoken, err := handler.EncodeAndSign(*claims)\nif err != nil {\n\tlog.Fatalf(\"Token generation failed: %s\", err.Error())\n}\n\nlog.Printf(\"Token generated: %s\", token)\n\nrecoveredClaims, err := handler.DecodeAndValidate(token)\nif err != nil {\n\tlog.Fatalf(\"Token validation failed: %s\", err.Error())\n}\n\nlog.Printf(\"Recovered claims: %+v\", recoveredClaims)\n```\n\nGo to [example](example) to see the full example.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzekrotja%2Fjwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzekrotja%2Fjwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzekrotja%2Fjwt/lists"}