{"id":16926073,"url":"https://github.com/databus23/goslo.policy","last_synced_at":"2025-06-26T08:04:26.291Z","repository":{"id":46705697,"uuid":"45250508","full_name":"databus23/goslo.policy","owner":"databus23","description":"A go implementation of OpenStack's oslo.policy library","archived":false,"fork":false,"pushed_at":"2025-03-26T13:49:18.000Z","size":39,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T17:15:43.919Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/databus23.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,"zenodo":null}},"created_at":"2015-10-30T12:48:14.000Z","updated_at":"2025-03-26T13:49:23.000Z","dependencies_parsed_at":"2025-04-11T17:11:58.907Z","dependency_job_id":"915beee6-1270-431c-8b4d-bae6cba2b5d0","html_url":"https://github.com/databus23/goslo.policy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/databus23/goslo.policy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fgoslo.policy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fgoslo.policy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fgoslo.policy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fgoslo.policy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/databus23","download_url":"https://codeload.github.com/databus23/goslo.policy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databus23%2Fgoslo.policy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262026982,"owners_count":23246954,"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":"2024-10-13T20:28:57.932Z","updated_at":"2025-06-26T08:04:26.270Z","avatar_url":"https://github.com/databus23.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/databus23/goslo.policy/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/databus23/goslo.policy/actions/)\n\nA go implementation of OpenStack's oslo.policy\n==============================================\n\nThis repository provides a reimplementation of the original [oslo.policy](https://github.com/openstack/oslo.policy) library written in python. It is meant to provide the same RBAC semantics for OpenStack enabled applications written in go.\n\nYou can view the API docs here:\nhttps://pkg.go.dev/github.com/databus23/goslo.policy\n\nUsage\n-----\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\tpolicy \"github.com/databus23/goslo.policy\"\n)\n\nfunc main() {\n\trules := map[string]string{\n\t\t\"admin_required\": \"role:admin\",\n\t\t\"cloud_admin\":    \"rule:admin_required and domain_id:default\",\n\t\t\"owner\":          \"user_id:%(user_id)s\",\n\t}\n\t//Load and parse policy\n\tenforcer, err := policy.NewEnforcer(rules)\n\tif err != nil {\n\t\tlog.Fatal(\"Failed to parse policy \", err)\n\t}\n\t//Context provides the current token \u0026 request information needed for enforcement\n\tctx := policy.Context{\n\t\tAuth: map[string]string{\n\t\t\t\"user_id\":   \"u-1\",\n\t\t\t\"domain_id\": \"default\",\n\t\t},\n\t\tRoles: []string{\"admin\"},\n\t\tRequest: map[string]string{\n\t\t\t\"user_id\": \"u-1\",\n\t\t},\n\t}\n\n\tif enforcer.Enforce(\"cloud_admin\", ctx) {\n\t\tlog.Println(\"user is a cloud admin\")\n\t}\n\tif enforcer.Enforce(\"owner\", ctx) {\n\t\tlog.Println(\"user is owner\")\n\t}\n}\n```\n\nThe package includes optional debug logging that can be enabled per context:\n\n```go\nif os.Getenv(\"DEBUG\") == \"1\" {\n    ctx.Logger = log.Printf //or any other function with the same signature\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabus23%2Fgoslo.policy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatabus23%2Fgoslo.policy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabus23%2Fgoslo.policy/lists"}