{"id":17273588,"url":"https://github.com/vaijab/gin-tokenauth","last_synced_at":"2026-04-15T16:32:07.216Z","repository":{"id":57608268,"uuid":"108527958","full_name":"vaijab/gin-tokenauth","owner":"vaijab","description":"TokenAuth is an authorization middleware for gin.","archived":false,"fork":false,"pushed_at":"2017-11-28T10:44:57.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-15T03:16:01.164Z","etag":null,"topics":["gin","golang","http","middleware","package"],"latest_commit_sha":null,"homepage":"https://github.com/vaijab/gin-tokenauth","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/vaijab.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}},"created_at":"2017-10-27T09:39:31.000Z","updated_at":"2017-11-28T10:44:35.000Z","dependencies_parsed_at":"2022-09-03T10:22:01.101Z","dependency_job_id":null,"html_url":"https://github.com/vaijab/gin-tokenauth","commit_stats":null,"previous_names":["orendo/gin-tokenauth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vaijab/gin-tokenauth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaijab%2Fgin-tokenauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaijab%2Fgin-tokenauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaijab%2Fgin-tokenauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaijab%2Fgin-tokenauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vaijab","download_url":"https://codeload.github.com/vaijab/gin-tokenauth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaijab%2Fgin-tokenauth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31849728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["gin","golang","http","middleware","package"],"created_at":"2024-10-15T08:51:42.258Z","updated_at":"2026-04-15T16:32:07.199Z","avatar_url":"https://github.com/vaijab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tokenauth\n\nTokenAuth is a authorization middleware for [gin](https://github.com/gin-gonic/gin).\n\n## Installation\n\n```\ngo get github.com/vaijab/gin-tokenauth\n```\n\n## Usage\n\nThis example uses file based token store, see [below](#filestore) for more\ndetails how filestore works.\n\n```Go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/vaijab/gin-tokenauth\"\n\t\"github.com/vaijab/gin-tokenauth/filestore\"\n)\n\nfunc main() {\n\tstore, err := filestore.New(\"tokens.yaml\")\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tr := gin.Default()\n\tr.Use(tokenauth.New(store))\n\n\tr.GET(\"/secrets\", func(c *gin.Context) {\n\t\tc.String(200, \"p4ssw0rd\\n\")\n\t})\n\n\tr.Run()\n}\n```\n\n```shell\n\u003e curl -i http://localhost:8080/secrets -H 'Authorization: Bearer jUyaoAFFZ5Ay3fxXG2boT5'\nHTTP/1.1 200 OK\nContent-Type: text/plain; charset=utf-8\nDate: Fri, 27 Oct 2017 12:11:16 GMT\nContent-Length: 9\n\np4ssw0rd\n```\n\n## Token Stores\n\nDifferent token stores can be implemented quite easily, the API stays the same.\n\n### filestore\n\nThis store is based on a yaml file. During initialization, a file watcher is\nattached which ensures that changes to the tokens file are reflected\nimmediately.\n\nTokens file does not have to exist at first. It can be created or removed and\nfilestore will either create tokens or remove them entirely. Only `token` and\n`is_disabled` fields are used at the moment.\n\n```yaml\n# tokens.yaml\n---\ntokens:\n  - name: foo\n    token: 'jUyaoAFFZ5Ay3fxXG2boT5'\n    is_disabled: false\n    description: 'Token for user foo'\n  - name: bar\n    token: 'jUyaoAFFZ5Ay3fxXG2boT5'\n    is_disabled: true\n    description: 'Disabled token for user bar'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaijab%2Fgin-tokenauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaijab%2Fgin-tokenauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaijab%2Fgin-tokenauth/lists"}