{"id":25110188,"url":"https://github.com/kiwamizamurai/fiber-nextauth","last_synced_at":"2025-10-14T09:04:39.928Z","repository":{"id":285714912,"uuid":"928694517","full_name":"kiwamizamurai/fiber-nextauth","owner":"kiwamizamurai","description":"A Fiber middleware for validating JWT tokens generated by Auth.js (NextAuth).","archived":false,"fork":false,"pushed_at":"2025-02-07T12:58:45.000Z","size":111,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T09:40:22.810Z","etag":null,"topics":["authjs","fiber","golang","jwt","middleware","nextauth"],"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/kiwamizamurai.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},"funding":{"github":"kiwamizamurai","open_collective":"kiwamizamurai","patreon":"kiwamizamurai"}},"created_at":"2025-02-07T04:16:30.000Z","updated_at":"2025-02-07T13:01:04.000Z","dependencies_parsed_at":"2025-04-02T09:40:34.600Z","dependency_job_id":"a1c752fc-644e-4fc0-ab0c-b22e9eb10ebd","html_url":"https://github.com/kiwamizamurai/fiber-nextauth","commit_stats":null,"previous_names":["kiwamizamurai/fiber-nextauth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kiwamizamurai/fiber-nextauth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Ffiber-nextauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Ffiber-nextauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Ffiber-nextauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Ffiber-nextauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiwamizamurai","download_url":"https://codeload.github.com/kiwamizamurai/fiber-nextauth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Ffiber-nextauth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270011194,"owners_count":24511902,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"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":["authjs","fiber","golang","jwt","middleware","nextauth"],"created_at":"2025-02-08T00:36:14.593Z","updated_at":"2025-10-14T09:04:34.893Z","avatar_url":"https://github.com/kiwamizamurai.png","language":"Go","funding_links":["https://github.com/sponsors/kiwamizamurai","https://opencollective.com/kiwamizamurai","https://patreon.com/kiwamizamurai"],"categories":[],"sub_categories":[],"readme":"# fiber-nextauth\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/kiwamizamurai/fiber-nextauth.svg)](https://pkg.go.dev/github.com/kiwamizamurai/fiber-nextauth)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kiwamizamurai/fiber-nextauth)](https://goreportcard.com/report/github.com/kiwamizamurai/fiber-nextauth)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA Fiber middleware for validating JWT tokens generated by Auth.js (NextAuth). Perfect for projects combining Next.js frontend with Fiber backend.\n\n\u003e [!CAUTION]\n\u003e This module was implemented for learning purposes. While it works, it has not been thoroughly security audited. Use in production at your own risk.\n\n## Installation\n\n```bash\ngo get github.com/kiwamizamurai/fiber-nextauth\n```\n\n## Quick Start\n\n### Basic Usage\n\n```go\npackage main\n\nimport (\n    \"github.com/gofiber/fiber/v2\"\n    \"github.com/golang-jwt/jwt/v5\"\n    \"github.com/kiwamizamurai/fiber-nextauth/pkg\"\n)\n\nfunc main() {\n    app := fiber.New()\n\n    // For Auth.js v5\n    auth := nextauthjwt.New(nextauthjwt.DefaultConfig())\n    // For NextAuth.js v4\n    // auth := nextauthjwt.New(nextauthjwt.NewV4Config())\n\n    // Protected route\n    app.Get(\"/protected\", auth.Middleware(), func(c *fiber.Ctx) error {\n        claims := c.Locals(\"user\").(jwt.MapClaims)\n        return c.JSON(fiber.Map{\n            \"message\": \"Protected route accessed successfully!\",\n            \"user\": fiber.Map{\n                \"name\": claims[\"name\"],\n                \"email\": claims[\"email\"],\n            },\n        })\n    })\n\n    app.Listen(\":3000\")\n}\n```\n\n### Custom Configuration\n\n```go\ncfg := nextauthjwt.DefaultConfig()\ncfg.Secret = os.Getenv(\"NEXTAUTH_SECRET\")\ncfg.SecureCookie = true\ncfg.CSRFEnabled = true\ncfg.CheckExpiry = true\n\nauth := nextauthjwt.New(cfg)\n```\n\n## Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `NEXTAUTH_SECRET` | Secret key for JWT validation | - |\n| `NEXTAUTH_URL` | URL to determine secure cookie usage | - |\n\n## Examples\n\nThe [examples](./examples) directory contains complete implementation examples:\n\n- `nextjs/`: Next.js v14 example with NextAuth.js v4\n- `authjs/`: Next.js v14 example with Auth.js v5\n- `fiber/`: Go Fiber backend example\n- `compose.yml`: Docker Compose setup for running all examples\n\n### Running Examples\n\nWith Docker Compose:\n```bash\ncd examples\ndocker compose up\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Reference\n1. https://www.reddit.com/r/nextjs/comments/179shhd/next_auth_with_seprate_backend_golang/\n2. https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/jwt.ts\n3. https://github.com/TCatshoek/fastapi-nextauth-jwt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwamizamurai%2Ffiber-nextauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiwamizamurai%2Ffiber-nextauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwamizamurai%2Ffiber-nextauth/lists"}