diff options
| author | mo khan <mo@mokhan.ca> | 2025-04-02 13:32:22 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-04-02 13:32:22 -0600 |
| commit | 894e270ab5a15de2b664cc6f4ee6fd8369985f75 (patch) | |
| tree | d778e426fcd1666dd35d978215434103e78acee8 /pkg/gid | |
| parent | 2a37de4a34552feac221771278236fb23f8e83c0 (diff) | |
refactor: combine cedar policies and add tests
Diffstat (limited to 'pkg/gid')
| -rw-r--r-- | pkg/gid/gid.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/gid/gid.go b/pkg/gid/gid.go new file mode 100644 index 0000000..e82b073 --- /dev/null +++ b/pkg/gid/gid.go @@ -0,0 +1,20 @@ +package gid + +import ( + "net/url" + "strings" + + "github.com/cedar-policy/cedar-go" +) + +func NewEntityUID(globalID string) cedar.EntityUID { + url, err := url.Parse(globalID) + if err != nil { + return cedar.NewEntityUID("User", cedar.String(globalID)) + } + + return cedar.NewEntityUID( + cedar.EntityType(url.Hostname()), + cedar.String(strings.TrimPrefix(url.Path, "/")), + ) +} |
