{"id":20524132,"url":"https://github.com/kimi0230/authserver","last_synced_at":"2026-05-29T12:31:41.388Z","repository":{"id":105026349,"uuid":"342817841","full_name":"kimi0230/authServer","owner":"kimi0230","description":"Base on OAuth2 and JWT to implement authorization system.","archived":false,"fork":false,"pushed_at":"2021-02-28T10:16:32.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T00:48:37.427Z","etag":null,"topics":["authentication","go","golang","jwt","oauth2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kimi0230.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-02-27T09:26:40.000Z","updated_at":"2023-05-01T02:19:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"eb38a74a-06cc-4c63-8d57-8bf1289b3d24","html_url":"https://github.com/kimi0230/authServer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kimi0230/authServer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimi0230%2FauthServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimi0230%2FauthServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimi0230%2FauthServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimi0230%2FauthServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kimi0230","download_url":"https://codeload.github.com/kimi0230/authServer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimi0230%2FauthServer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33652979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"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":["authentication","go","golang","jwt","oauth2"],"created_at":"2024-11-15T22:48:05.224Z","updated_at":"2026-05-29T12:31:41.368Z","avatar_url":"https://github.com/kimi0230.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Token Authorization\n\nBase on OAuth2 and JWT to implement authorization system.\n\n### Download Consul\nhttps://www.consul.io/downloads\n\n#### Star consul\n```sh\nmv consul /usr/local/bin/\nconsul agent -dev\n```\n\n####  consul server\nhttp://localhost:8500\n\n### Install package\n```sh\ngo mod tidy\n```\n\n### Acquire Token flow\n#### 1. Create Token\n* Authorization is `clientId:clientSecret` to base64, so it is `Y2xpZW50SWQ6Y2xpZW50U2VjcmV0` \n* username is `simaple` or `admin`\n* both password are `123456`\n\n##### Reqest\n``` bash\ncurl --location --request POST 'http://localhost:10098/oauth/token' \\\n--header 'Content-Type: multipart/form-data' \\\n--header 'Host: localhost:10098' \\\n--header 'Authorization: Basic Y2xpZW50SWQ6Y2xpZW50U2VjcmV0' \\\n--form 'username=\"simple\"' \\\n--form 'password=\"123456\"'\n```\n\n##### Response\n``` json\n{\n    \"access_token\": {\n        \"RefreshToken\": {\n            \"RefreshToken\": null,\n            \"TokenType\": \"jwt\",\n            \"TokenValue\": \"...\",\n            \"ExpiresTime\": \"2021-02-28T22:00:45.703028+08:00\"\n        },\n        \"TokenType\": \"jwt\",\n        \"TokenValue\": \"...\",\n        \"ExpiresTime\": \"2021-02-28T17:30:45.703072+08:00\"\n    },\n    \"error\": \"\"\n}\n```\n\n#### 2. Check Token\n##### Reqest\n``` bash\ncurl --location --request POST 'http://localhost:10098/oauth/check_token?token=...' \\\n--header 'Authorization: Basic Y2xpZW50SWQ6Y2xpZW50U2VjcmV0' \\\n--header 'Host: localhost:10098'\n```\n\n##### Response\n``` json\n{\n    \"o_auth_details\": {\n        \"Client\": {\n            \"ClientId\": \"clientId\",\n            \"ClientSecret\": \"\",\n            \"AccessTokenValiditySeconds\": 1800,\n            \"RefreshTokenValiditySeconds\": 18000,\n            \"RegisteredRedirectUri\": \"http://127.0.0.1\",\n            \"AuthorizedGrantTypes\": [\n                \"password\",\n                \"refresh_token\"\n            ]\n        },\n        \"User\": {\n            \"UserId\": 1,\n            \"Username\": \"simple\",\n            \"Password\": \"\",\n            \"Authorities\": [\n                \"Simple\"\n            ]\n        }\n    },\n    \"error\": \"\"\n}\n```\n\n#### 3. Refresh Token if Token is invalid\n##### Reqest\n``` bash\ncurl --location --request POST 'http://localhost:10098/oauth/token?grant_type=refresh_token\u0026refresh_token=...' \\\n--header 'Authorization: Basic Y2xpZW50SWQ6Y2xpZW50U2VjcmV0' \\\n--header 'Host: localhost:10098' \\\n--header 'Content-Type: multipart/form-data'\n```\n##### Response\n``` json\n{\n    \"access_token\": {\n        \"RefreshToken\": {\n            \"RefreshToken\": null,\n            \"TokenType\": \"jwt\",\n            \"TokenValue\": \"...\",\n            \"ExpiresTime\": \"2021-02-28T17:29:23.65741+08:00\"\n        },\n        \"TokenType\": \"jwt\",\n        \"TokenValue\": \"...\",\n        \"ExpiresTime\": \"2021-02-28T17:26:43.657444+08:00\"\n    },\n    \"error\": \"\"\n}\n```\n\n### Call APIs\n#### Get Simple\n##### Reqest\n``` bash\ncurl --location --request GET 'http://localhost:10098/simple' \\\n--header 'Authorization: ...' \\\n--header 'Cache-Control: no-cache' \\\n--header 'Host: localhost:10098'\n```\n##### Response\n```\n{\n    \"result\": \"hello simple ,simple data, with simple authority\",\n    \"error\": \"\"\n}\n```\n#### Get Admin\n##### Reqest\n``` bash\ncurl --location --request GET 'http://localhost:10098/admin' \\\n--header 'Authorization: ...' \\\n--header 'Cache-Control: no-cache' \\\n--header 'Host: localhost:10098'\n```\n##### Response\n```\n{\n    \"result\": \"hello admin ,admin data, with admin authority\",\n    \"error\": \"\"\n}\n```\n\n### [Prometheus](https://prometheus.io/)\nhttp://localhost:10098/metrics\n\nPrometheus is a systems and service monitoring system. It collects metrics from configured targets at given intervals, evaluates rule expressions, displays the results, and can trigger alerts when specified conditions are observed.Visit [prometheus.io](https://prometheus.io/) for the full documentation, examples and guides.\n\n### Reference\n* https://github.com/longjoy/micro-go-book","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimi0230%2Fauthserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkimi0230%2Fauthserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimi0230%2Fauthserver/lists"}