{"id":23039652,"url":"https://github.com/ckaznocha/go-jwtbearerware","last_synced_at":"2025-09-12T08:38:36.242Z","repository":{"id":57527913,"uuid":"53888122","full_name":"ckaznocha/go-JWTBearerware","owner":"ckaznocha","description":"A Golang library and middleware for using JSON Web Tokens in gRPC and HTTP projects.","archived":false,"fork":false,"pushed_at":"2017-04-22T03:44:42.000Z","size":18,"stargazers_count":12,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-21T03:11:08.920Z","etag":null,"topics":["go","golang","grpc","http","jwt","middleware"],"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/ckaznocha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-14T20:05:57.000Z","updated_at":"2023-07-30T18:42:08.000Z","dependencies_parsed_at":"2022-09-03T19:40:35.173Z","dependency_job_id":null,"html_url":"https://github.com/ckaznocha/go-JWTBearerware","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/ckaznocha%2Fgo-JWTBearerware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckaznocha%2Fgo-JWTBearerware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckaznocha%2Fgo-JWTBearerware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckaznocha%2Fgo-JWTBearerware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ckaznocha","download_url":"https://codeload.github.com/ckaznocha/go-JWTBearerware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229862114,"owners_count":18135887,"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":["go","golang","grpc","http","jwt","middleware"],"created_at":"2024-12-15T18:36:30.854Z","updated_at":"2024-12-15T18:36:31.656Z","avatar_url":"https://github.com/ckaznocha.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bearerware\n\n[![Build Status](http://img.shields.io/travis/ckaznocha/go-JWTBearerware.svg?style=flat)](https://travis-ci.org/ckaznocha/go-JWTBearerware)\n[![Coverage Status](https://coveralls.io/repos/github/ckaznocha/go-JWTBearerware/badge.svg?branch=master)](https://coveralls.io/github/ckaznocha/go-JWTBearerware?branch=master)\n[![License](http://img.shields.io/:license-mit-blue.svg)](http://ckaznocha.mit-license.org)\n[![GoDoc](https://godoc.org/github.com/ckaznocha/go-JWTBearerware?status.svg)](https://godoc.org/github.com/ckaznocha/go-JWTBearerware)\n[![Go Report Card](https://goreportcard.com/badge/ckaznocha/go-JWTBearerware)](https://goreportcard.com/report/ckaznocha/go-JWTBearerware)\n\nPackage bearerware provides a library and middleware to make using [JSON Web Tokens](https://jwt.io/) in gRPC and HTTP requests more convenient. Middleware functions and examples for popular routers are in the `midleware` directory.\n\nThis project was inspire by [auth0/go-jwt-middleware](https://github.com/auth0/go-jwt-middleware).\n\nRequires go1.7 or newer.\n\nFor more info see the example files and the [GoDoc](https://godoc.org/github.com/ckaznocha/go-JWTBearerware) page.\n\n--\n    import \"github.com/ckaznocha/go-JWTBearerware\"\n\n\n## Usage\n\n#### func  JWTFromContext\n\n```go\nfunc JWTFromContext(\n\tctx context.Context,\n\tkeyFunc jwt.Keyfunc,\n\tsigningMethod jwt.SigningMethod,\n) (*jwt.Token, error)\n```\nJWTFromContext **deprecated** use `JWTFromIncomingContext`\n\n#### func  JWTFromHeader\n\n```go\nfunc JWTFromHeader(\n\tr *http.Request,\n\tkeyFunc jwt.Keyfunc,\n\tsigningMethod jwt.SigningMethod,\n) (*jwt.Token, error)\n```\nJWTFromHeader extracts a valid JWT from an http.Request or returns and error\n\n#### func  JWTFromIncomingContext\n\n```go\nfunc JWTFromIncomingContext(\n\tctx context.Context,\n\tkeyFunc jwt.Keyfunc,\n\tsigningMethod jwt.SigningMethod,\n) (*jwt.Token, error)\n```\nJWTFromIncomingContext extracts a valid JWT from a context.Contexts or returns\nand error\n\n#### func  NewJWTAccessFromJWT\n\n```go\nfunc NewJWTAccessFromJWT(jsonKey string) (credentials.PerRPCCredentials, error)\n```\nNewJWTAccessFromJWT creates a JWT credentials.PerRPCCredentials for use in gRPC requests.\n\n#### func  WriteAuthError\n\n```go\nfunc WriteAuthError(w http.ResponseWriter, err error)\n```\nWriteAuthError is a convenience function for setting the WWW-Authenticate header\nand sending an http.Error()\n\n#### type JWTContexter\n\n```go\ntype JWTContexter interface {\n\tWriteJWT(*http.Request, *jwt.Token)\n\tReadJWT(*http.Request) (*jwt.Token, bool)\n\tDeleteJWT(*http.Request)\n}\n```\n\nJWTContexter provides and interface for safe access to a shared map to get a jwt\nfor the current request scope when using net/http.\n\n#### func  NewJWTContext\n\n```go\nfunc NewJWTContext() JWTContexter\n```\nNewJWTContext creates a new JWTContexter\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckaznocha%2Fgo-jwtbearerware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fckaznocha%2Fgo-jwtbearerware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckaznocha%2Fgo-jwtbearerware/lists"}