{"id":22080157,"url":"https://github.com/teng231/tokenmanager","last_synced_at":"2025-07-24T14:31:56.052Z","repository":{"id":57633099,"uuid":"408308319","full_name":"teng231/tokenmanager","owner":"teng231","description":"Token manager, golang control flow access token.","archived":false,"fork":false,"pushed_at":"2023-03-25T09:52:08.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T11:11:05.198Z","etag":null,"topics":["golang","hmac-authentication","jwt-tokens","rsa-algorithm","token"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teng231.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}},"created_at":"2021-09-20T04:19:20.000Z","updated_at":"2023-04-24T09:15:25.000Z","dependencies_parsed_at":"2024-06-20T05:54:44.688Z","dependency_job_id":"d97ae297-87f4-4359-b50b-8f52aa45050f","html_url":"https://github.com/teng231/tokenmanager","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/teng231/tokenmanager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teng231%2Ftokenmanager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teng231%2Ftokenmanager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teng231%2Ftokenmanager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teng231%2Ftokenmanager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teng231","download_url":"https://codeload.github.com/teng231/tokenmanager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teng231%2Ftokenmanager/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266855792,"owners_count":23995553,"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-07-24T02:00:09.469Z","response_time":99,"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":["golang","hmac-authentication","jwt-tokens","rsa-algorithm","token"],"created_at":"2024-11-30T23:12:41.667Z","updated_at":"2025-07-24T14:31:55.794Z","avatar_url":"https://github.com/teng231.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tokenmanager\nControl flow token generate and parse token.\n\n[![Go](https://github.com/teng231/tokenmanager/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/teng231/tokenmanager/actions/workflows/go.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/princjef/gomarkdoc.svg)](https://pkg.go.dev/github.com/teng231/tokenmanager)\n\n## Installing and Usage\n\n```bash\ngo get github.com/teng231/tokenmanager\n```\nstruct of claims example:\n```json\n{\n  \"exp\": 1632109978,\n  \"iat\": 1632108178,\n  \"payload\": {\n    \"user_id\": 1,\n    \"role_id\": 0\n  }\n}\n```\n\nall data store in payload.\n\n### Alg RSA\n\nGen demo rsa keygen\n```bash\nssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key\n# Don't add passphrase\nopenssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub\ncat jwtRS256.key\ncat jwtRS256.key.pub\n```\n* Genkey\n```go\nfunc GenKey() {\n\tmgr, err := CreateRSAToken(\"\", \"./test/jwtRS256.key\")\n\tif err != nil {\n\t\tt.Fail()\n\t}\n\ttk, err := mgr.GenerateToken(Claims{UserId: 1}, 30*time.Minute)\n\tif err != nil {\n\t\tt.Fail()\n\t}\n\tlog.Println(tk)\n}\n\n```\n\n* Parse\n```go\nfunc ParseKey(tk string) {\n\tmgr, err := CreateRSAToken(\"./test/jwtRS256.key.pub\", \"\")\n\tif err != nil {\n\t\tt.Fail()\n\t}\n\textractor, err := mgr.ParseToken(tk)\n\tif err != nil {\n\t\tt.Fail()\n\t}\n\tbin, err := json.Marshal(extractor[\"payload\"])\n\tif err != nil {\n\t\tt.Fail()\n\t}\n\tclaim := \u0026Claims{}\n\tjson.Unmarshal(bin, claim)\n\tlog.Println(claim)\n\tif claim.UserId != 1 {\n\t\tt.Fail()\n\t}\n}\n```\n\n### Alg HMAC\n\nHmac input need a secret path like: `./test/secret`\n\n* Genkey\n\n```go\nfunc Genkey() {\n\tmgr, err := CreateHMACToken(\"./test/secret\")\n\tif err != nil {\n\t\tt.Fail()\n\t}\n\ttk, err := mgr.GenerateHmacToken(Claims{UserId: 1}, 30*time.Second)\n\tif err != nil {\n\t\tlog.Print(err)\n\t\tt.Fail()\n\t}\n\tlog.Println(tk)\n}\n```\n\n* ParseKey\n\n\n```go\nfunc Genkey(tk string) {\n\tmgr, err := CreateHMACToken(\"./test/secret\")\n\tif err != nil {\n\t\tlog.Print(err)\n\t\tt.Fail()\n\t}\n\textractor, err := mgr.ParseHmacToken(tk)\n\tif err != nil {\n\t\tlog.Print(err)\n\t\tt.Fail()\n\t}\n\tbin, err := json.Marshal(extractor[\"payload\"])\n\tif err != nil {\n\t\tt.Fail()\n\t}\n\tclaim := \u0026Claims{}\n\tjson.Unmarshal(bin, claim)\n\tlog.Println(claim)\n\tif claim.UserId != 1 {\n\t\tt.Fail()\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteng231%2Ftokenmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteng231%2Ftokenmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteng231%2Ftokenmanager/lists"}