{"id":21141429,"url":"https://github.com/influx6/jwtkit","last_synced_at":"2025-03-14T13:14:48.297Z","repository":{"id":138759781,"uuid":"115160338","full_name":"influx6/jwtkit","owner":"influx6","description":"A JWT(JSON Web Token) code gen for quick jwt api for backend SSO Login.","archived":false,"fork":false,"pushed_at":"2018-05-10T23:07:44.000Z","size":1802,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T07:08:17.488Z","etag":null,"topics":["annotated-structs","gen","golang-jwt","jwt","jwt-gen","jwt-go-gen","refresh-tokens"],"latest_commit_sha":null,"homepage":null,"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/influx6.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}},"created_at":"2017-12-23T00:42:28.000Z","updated_at":"2019-10-12T07:44:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"add3317f-bf5c-48ee-9525-75ccc92bdc93","html_url":"https://github.com/influx6/jwtkit","commit_stats":null,"previous_names":["gokit/jwtkit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influx6%2Fjwtkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influx6%2Fjwtkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influx6%2Fjwtkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influx6%2Fjwtkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/influx6","download_url":"https://codeload.github.com/influx6/jwtkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243581094,"owners_count":20314167,"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":["annotated-structs","gen","golang-jwt","jwt","jwt-gen","jwt-go-gen","refresh-tokens"],"created_at":"2024-11-20T07:29:08.451Z","updated_at":"2025-03-14T13:14:48.267Z","avatar_url":"https://github.com/influx6.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"JWTKit\n--------\n[![Go Report Card](https://goreportcard.com/badge/github.com/gokit/jwtkit)](https://goreportcard.com/report/github.com/gokit/jwtkit)\n\nJWTKit implements a code generator which automatically generates go packages for jwt implementations for annotated structs.\nIt focuses around generating API code for a giving struct which would contain all data to be attached to a giving [jwt.Claims](https://godoc.org/github.com/dgrijalva/jwt-go#Claims).\n\nIt generates all necessary code to issue jwt access and refresh tokens for use in your application.\n\n## Install\n\n```\ngo get -u github.com/gokit/jwtkit\n```\n\n## Examples\n\nSee [Examples](./examples) for demonstrations of jwtkit code generation.\n\n## Usage\n\nRunning the following commands instantly generates all necessary files and packages for giving code gen.\n\n```go\n\u003e jwit generate\n```\n\n## How It works\n\n### Struct Annotation\n\nYou annotate any giving struct with `@mongoapi` which marks giving struct has a target for code generation. \n\nSample below:\n\n```go\n// UserClaim embodies data to be attached with a jwt claim.\n// @jwt(Contract =\u003e UserContract)\ntype UserClaim struct {\n\tUser User `json:\"user\"`\n\tRoles map[string]string `json:\"roles\"`\n\tPermissions map[string]string `json:\"permissions\"`\n}\n\n// UserContract embodies the data needed for authenticating a user.\ntype UserContract struct{\n\tUsername string `json:\"user_name\"`\n\tPassword string `json:\"password\"`\n}\n```\n\nJWTKit generates specific interfaces to allow extensibility and also \nwhat underline backend technology would be used for either storing jwt\nrecords and blacklist/active refresh tokens and associated records.\n\nThe JWTKit expects that the provided annotation must have a `Contract`\nattribute pointing to a local exported struct which contains expected \ndata to be received to authenticate a login session by the user to \nauthenticate itself for access to the jwt authorization system.\n\n```go\n\nblacklist := mock.TokenBackend()\nwhitelist := mock.TokenBackend()\nidb := mock.IdentityBackend()\n\njwter := userclaimjwt.NewJWTIdentity(userclaimjwt.JWTConfig{\n\tMaker:               noSecureUser,\n\tSigner:              \"wellington\",\n\tSigningSecret:       \"All we want is to sign this\",\n\tMethod:              jwt.SigningMethodHS256,\n\tAccessTokenExpires:  700 * time.Millisecond,\n\tRefreshTokenExpires: 4 * time.Second,\n}, blacklist, whitelist, idb)\n\nvar cred pkg.CreateUserSession\nif jsnerr := json.Unmarshal([]byte(contractDataJSON), \u0026cred); jsnerr != nil {\n\tpanic(jsnerr)\n}\n\nauth, err := jwter.Grant(context.Background(), cred)\nif err != nil {\n\tpanic(jsnerr)\n}\n\n```\n\nWhere `auth` is:\n```json\n{\n\t\"expires\": 323231,\n\t\"refresh_token\":\"\",\n\t\"access_token\":\"\",\n\t\"token_type\": \"Bearer\",\n\t\"refresh_expires\": 323231,\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finflux6%2Fjwtkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finflux6%2Fjwtkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finflux6%2Fjwtkit/lists"}