https://cerbos.dev logo
#community
Title
# community
v

Viet Au

08/10/2022, 4:33 PM
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

Alex Olivier (Cerbos)

08/10/2022, 4:38 PM
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

Charith (Cerbos)

08/10/2022, 4:43 PM
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

Viet Au

08/10/2022, 4:54 PM
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

Alex Olivier (Cerbos)

08/10/2022, 4:54 PM
Yes that looks to be an oversight - thanks for flagging, we are looking into it now.
c

Charith (Cerbos)

08/11/2022, 7:31 AM
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

Viet Au

08/11/2022, 8:05 AM
nice one, thanks @Charith (Cerbos)
c

Charith (Cerbos)

08/12/2022, 6:51 AM
FYI: just released v0.19.1 with this fix.
4 Views