{"id":26895418,"url":"https://github.com/SonicRoshan/scope","last_synced_at":"2025-04-01T02:01:19.270Z","repository":{"id":65134348,"uuid":"210330925","full_name":"ThundR67/scope","owner":"ThundR67","description":"Easily Manage OAuth2 Scopes In Go","archived":false,"fork":false,"pushed_at":"2021-05-25T13:48:05.000Z","size":10,"stargazers_count":38,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-29T14:18:44.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ThundR67.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":"2019-09-23T10:48:14.000Z","updated_at":"2024-08-30T22:05:31.000Z","dependencies_parsed_at":"2022-12-31T07:31:21.543Z","dependency_job_id":null,"html_url":"https://github.com/ThundR67/scope","commit_stats":null,"previous_names":["sonicroshan/scope"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThundR67%2Fscope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThundR67%2Fscope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThundR67%2Fscope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThundR67%2Fscope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThundR67","download_url":"https://codeload.github.com/ThundR67/scope/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246569001,"owners_count":20798341,"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","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":[],"created_at":"2025-04-01T02:00:45.131Z","updated_at":"2025-04-01T02:01:19.250Z","avatar_url":"https://github.com/ThundR67.png","language":"Go","readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/SonicRoshan/scope)](https://goreportcard.com/report/github.com/SonicRoshan/scope) [![GoDoc](https://godoc.org/github.com/SonicRoshan/scope?status.svg)](https://godoc.org/github.com/SonicRoshan/scope) [![GoCover](https://gocover.io/_badge/github.com/SonicRoshan/scope)](https://gocover.io/github.com/SonicRoshan/scope)\n\n# Scope\nEasily Manage OAuth2 Scopes In Go\n\n## Scope Matching Using Wildcard Strategy\n```go\nimport \"github.com/SonicRoshan/scope\"\n\nscopeA := \"read:user:*\"\nscopeB := \"read:user:username\"\n\ndoesMatch := scope.MatchScopes(scopeA, scopeB)\n```\nThis strategy will work like this :-\n* `users.*` matches `users.read`\n* `users.*` matches `users.read.foo`\n* `users.read` matches `users.read`\n* `users` does not match `users.read`\n* `users.read.*` does not match `users.read`\n* `users.*.*` does not match `users.read`\n* `users.*.*` matches `users.read.own`\n* `users.*.*` matches `users.read.own.other`\n* `users.read.*` matches `users.read.own`\n* `users.read.*` matches `users.read.own.other`\n* `users.write.*` does not match `users.read.own`\n* `users.*.bar` matches `users.baz.bar`\n* `users.*.bar` does not `users.baz.baz.bar`\n\n## Filtering Struct For Read Request\nWhen a client request certain data, this function will eliminate any data in the struct for which the client does not have a read scope.\n```go\ntype user struct {\n    username string `readScope:\"user:read:username\"`\n    email string `readScope:\"user:read:email\"`\n}\n\n\nfunc main() {\n    output := user{username : \"Test\", email : \"Test@Test.com\"}\n    scopesHeldByClient := []string{\"user:read:username\"}\n    scope.FilterRead(output, scopesHeldByClient)\n\n    // Now output.email will be nil as client does not have scope required to read email field\n\n    output := user{username : \"Test\", email : \"Test@Test.com\"}\n    scopesHeldByClient := []string{\"user:read:*\"}\n    scope.FilterRead(\u0026output, scopesHeldByClient)\n\n    // Now none of the field in output will be nil as client has scopes to read everything in user struct\n}\n\n```\n","funding_links":[],"categories":["Authentication and Authorization","Authentication and OAuth","身份验证和OAuth","认证和OAuth授权","Uncategorized"],"sub_categories":["Contents"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSonicRoshan%2Fscope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSonicRoshan%2Fscope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSonicRoshan%2Fscope/lists"}