{"id":21235961,"url":"https://github.com/lddl/fiber-jwt","last_synced_at":"2025-07-10T17:31:49.916Z","repository":{"id":57548602,"uuid":"275443843","full_name":"LdDl/fiber-jwt","owner":"LdDl","description":"JWT for fiber","archived":false,"fork":false,"pushed_at":"2024-07-02T08:37:05.000Z","size":65,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T15:51:09.993Z","etag":null,"topics":["auth","fiber","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/LdDl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-06-27T19:56:05.000Z","updated_at":"2024-07-02T08:36:10.000Z","dependencies_parsed_at":"2022-08-28T11:30:34.164Z","dependency_job_id":"6e408cf5-67a2-4f7d-bd35-ad68c5a75275","html_url":"https://github.com/LdDl/fiber-jwt","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/LdDl/fiber-jwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Ffiber-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Ffiber-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Ffiber-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Ffiber-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LdDl","download_url":"https://codeload.github.com/LdDl/fiber-jwt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Ffiber-jwt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264619108,"owners_count":23638407,"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":["auth","fiber","jwt"],"created_at":"2024-11-21T00:05:08.350Z","updated_at":"2025-07-10T17:31:49.061Z","avatar_url":"https://github.com/LdDl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/LdDl/fiber-jwt?status.svg)](https://godoc.org/github.com/LdDl/fiber-jwt) [![Build Status](https://travis-ci.com/LdDl/fiber-jwt.svg?branch=master)](https://travis-ci.com/LdDl/fiber-jwt) [![Sourcegraph](https://sourcegraph.com/github.com/LdDl/fiber-jwt/-/badge.svg)](https://sourcegraph.com/github.com/LdDl/fiber-jwt?badge) [![Go Report Card](https://goreportcard.com/badge/github.com/LdDl/fiber-jwt)](https://goreportcard.com/report/github.com/LdDl/fiber-jwt) [![GitHub tag](https://img.shields.io/github/tag/LdDl/fiber-jwt.svg)](https://github.com/LdDl/fiber-jwt/releases)\n# JWT Middleware for Fiber Framework\n## *preamble: this is port of [appleyboy's](https://github.com/appleboy/gin-jwt/tree/v2.6.4) JWT middleware adapted for [Fiber framework](https://github.com/gofiber/fiber)*\n\n### This is a middleware for [Fiber](https://github.com/gofiber/fiber) framework, which built on top of [fasthttp](https://github.com/valyala/fasthttp)\n\nIt uses [golang-jwt/jwt](https://github.com/golang-jwt/jwt#jwt-go) to provide a jwt authentication middleware. It provides additional handler functions to provide the `doauth` api that will generate the token and an additional `refresh_token` handler that can be used to refresh tokens.\n\n## Usage\n\nDownload and install using [go module](https://blog.golang.org/using-go-modules):\n\n```sh\nexport GO111MODULE=on\ngo get github.com/LdDl/fiber-jwt\n```\n\nImport it in your code:\n\n```go\nimport (\n    jwt \"github.com/LdDl/fiber-jwt/v2\"\n)\n```\n\n## Example\n\nPlease see [the example file](example/main.go)\n```bash\ngo run example/main.go\n```\nDemo server will start on port 8080.\n\n### Login API\n\nCorrect username/password and user access\n```bash\ncurl -X POST 'http://localhost:8080/api/doauth' -d '{\"username\": \"user\", \"password\": \"pass\"}'\ncurl -X GET 'http://localhost:8080/api/v0.0.1/secret_page?token=PUT_RECIEVED_TOKEN'\n```\n\nCorrect username/password but user has no access (banned)\n```bash\ncurl -X POST 'http://localhost:8080/api/doauth' -d '{\"username\": \"user2\", \"password\": \"pass\"}'\n```\n\nWrong user or password\n```bash\ncurl -X POST 'http://localhost:8080/api/doauth' -d '{\"username\": \"user\", \"password\": \"pass333\"}'\n```\n\n### Refresh token API\n\n```bash\ncurl -X GET 'http://localhost:8080/api/v0.0.1/refresh_token?token=PUT_RECIEVED_TOKEN'\n```\n\n### Login Flow\n\n1. Authenticator: handles the login logic. On success LoginResponse is called, on failure Unauthorized is called.\n2. LoginResponse: optional, allows setting a custom response such as a redirect.\n\n### JWT Flow\n\n1. PayloadFunc: maps the claims in the JWT.\n2. IdentityHandler: extracts identity from claims.\n3. Authorizator: receives identity and handles authorization logic.\n4. Unauthorized: handles unauthorized logic.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Ffiber-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flddl%2Ffiber-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Ffiber-jwt/lists"}