Hi, I am trying to use scopes in a golang project....
# community
v
Hi, I am trying to use scopes in a golang project. After defining the policies with scope. I don't see how I can set the scope on the resource I am validating, e.g. when you call the IsAllowed method of the PrincipalContext, how does it know what scope to start from?
a
Hey are you using the Go Client SDK? There is a
Scope
attribute on both the Principal and Resource types. Let me see if I can find an example
c
Hmm..I could swear there was a
WithScope
method on both principal and resource objects but I don't see it in the docs. I am not near a computer right now. Will double check when I am back.
v
There is scope in both cases for the underlying struct but for the client model they are both encapsulated.
Copy code
type Resource struct {
    r   *enginev1.Resource
    err error
}
no way of getting to r. Similar with principal too.
a
Yes that looks to be an oversight - thanks for flagging, we are looking into it now.
c
This is now fixed in trunk. We'll try to get a tagged release out very soon. In the mean time, you can try it out with
Copy code
go get <http://github.com/cerbos/cerbos/client@main|github.com/cerbos/cerbos/client@main>
Thanks for reporting the issue.
v
nice one, thanks @Charith (Cerbos)
c
FYI: just released v0.19.1 with this fix.