{"id":26686017,"url":"https://github.com/hensybex/anarkey","last_synced_at":"2026-05-19T06:06:56.582Z","repository":{"id":284448697,"uuid":"954934769","full_name":"hensybex/anarkey","owner":"hensybex","description":"Minimalist authentication and authorization Go library. JWT, RBAC, Gin middleware. Auth without authority. 🏴🔑","archived":false,"fork":false,"pushed_at":"2025-03-26T00:03:14.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-04T20:52:52.496Z","etag":null,"topics":["anarchist","authorization","gin","go","jwt","middleware","minimalist","rbac","security"],"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/hensybex.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-25T21:01:59.000Z","updated_at":"2025-03-26T00:03:18.000Z","dependencies_parsed_at":"2025-03-26T00:29:47.760Z","dependency_job_id":"9fbc5240-1eff-4213-9432-8dacc797103c","html_url":"https://github.com/hensybex/anarkey","commit_stats":null,"previous_names":["hensybex/anarkey"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hensybex/anarkey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensybex%2Fanarkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensybex%2Fanarkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensybex%2Fanarkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensybex%2Fanarkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hensybex","download_url":"https://codeload.github.com/hensybex/anarkey/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensybex%2Fanarkey/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33204126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"online","status_checked_at":"2026-05-19T02:00:06.763Z","response_time":58,"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":["anarchist","authorization","gin","go","jwt","middleware","minimalist","rbac","security"],"created_at":"2025-03-26T11:15:54.068Z","updated_at":"2026-05-19T06:06:56.544Z","avatar_url":"https://github.com/hensybex.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔑 AnarKey\n\n\u003e **Freedom from authoritarian authentication!**\n\nAnarKey is a minimalist Go authentication and authorization library designed with one goal in mind: giving developers total control over tokens, roles, and permissions without unnecessary dependencies and bloated solutions.\n\n## 🏴 AnarKey Philosophy\n\n- **Minimalism**: No unnecessary complexity.\n- **Flexibility**: Extend and integrate painlessly.\n- **Security**: Safe defaults, proven methods.\n- **Transparency**: No magic, just straightforward code.\n\n## ⚙️ Features\n\n- Secure JWT implementation by default.\n- Refresh token rotation and revocation.\n- Simple and intuitive RBAC.\n- Ready-to-use middleware for Gin (easy to adapt for other frameworks).\n- Easy integration into your existing app.\n- Robust error handling.\n- Authentication event hooks (for monitoring or extension).\n\n## 💻 Installation\n\n```bash\ngo get github.com/hensybex/anarkey\n```\n\n🚀 Quick Start\n```go\npackage main\n\nimport (\n    \"time\"\n    \"github.com/gin-gonic/gin\"\n    \"github.com/hensybex/anarkey/authcore\"\n    \"github.com/hensybex/anarkey/middleware/authgin\"\n)\n\nfunc main() {\n    auth, err := authcore.NewWithConfig(authcore.Config{\n        Issuer:        \"my-app\",\n        Audience:      \"my-api\",\n        TokenSecret:   \"change-me-in-production\", // Use env vars in prod!\n        TokenLifetime: 15 * time.Minute,\n    })\n    if err != nil {\n        panic(\"AnarKey init error: \" + err.Error())\n    }\n\n    r := gin.Default()\n    authMw := authgin.New(auth)\n\n    r.POST(\"/login\", func(c *gin.Context) {\n        username, password := c.PostForm(\"username\"), c.PostForm(\"password\")\n\n        if username == \"admin\" \u0026\u0026 password == \"password\" {\n            claims := map[string]interface{}{\n                \"user_id\": \"123\",\n                \"roles\":   []string{\"admin\", \"user\"},\n            }\n\n            at, rt, err := auth.GenerateTokens(claims)\n            if err != nil {\n                c.JSON(500, gin.H{\"error\": \"Token generation failed\"})\n                return\n            }\n\n            c.JSON(200, gin.H{\"access_token\": at, \"refresh_token\": rt, \"token_type\": \"Bearer\"})\n        } else {\n            c.JSON(401, gin.H{\"error\": \"Invalid credentials\"})\n        }\n    })\n\n    r.POST(\"/refresh\", func(c *gin.Context) {\n        rt := c.PostForm(\"refresh_token\")\n        at, rtNew, err := auth.RefreshTokens(rt)\n        if err != nil {\n            c.JSON(401, gin.H{\"error\": \"Invalid refresh token\"})\n            return\n        }\n\n        c.JSON(200, gin.H{\"access_token\": at, \"refresh_token\": rtNew, \"token_type\": \"Bearer\"})\n    })\n\n    protected := r.Group(\"/\")\n    protected.Use(authMw.RequireAuthentication())\n    protected.GET(\"/profile\", func(c *gin.Context) {\n        user, _ := authgin.UserFromGinContext(c, auth.Config.TokenContextKey)\n        c.JSON(200, gin.H{\"user_id\": user.GetClaim(\"user_id\"), \"roles\": user.GetClaim(\"roles\")})\n    })\n\n    admin := r.Group(\"/\")\n    admin.Use(authMw.RequireAuthentication(), authMw.RequireRole(\"admin\"))\n    admin.GET(\"/admin\", func(c *gin.Context) {\n        c.JSON(200, gin.H{\"message\": \"Welcome, admin!\"})\n    })\n\n    r.Run(\":8080\")\n}\n```\n\n🔧 Configuration Options\n```go\n// Environment variables (recommended)\nauth, err := authcore.New()\n\n// YAML file configuration\nauth, err := authcore.NewFromFile(\"./config.yaml\")\n\n// Viper configuration\nv := viper.New()\nv.SetConfigFile(\"./config.yaml\")\nv.ReadInConfig()\nauth, err := authcore.NewFromViper(v)\n```\n\n🔐 Security Recommendations\n\n    Strong secrets, secure storage.\n\n    RS256/ES256 for production.\n\n    User authentication responsibility stays within your app.\n\n📜 License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhensybex%2Fanarkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhensybex%2Fanarkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhensybex%2Fanarkey/lists"}