v

    Viet Au

    1 month ago
    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?
    Alex Olivier (Cerbos)

    Alex Olivier (Cerbos)

    1 month ago
    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
    Charith (Cerbos)

    Charith (Cerbos)

    1 month ago
    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

    1 month ago
    There is scope in both cases for the underlying struct but for the client model they are both encapsulated.
    type Resource struct {
        r   *enginev1.Resource
        err error
    }
    no way of getting to r. Similar with principal too.
    Alex Olivier (Cerbos)

    Alex Olivier (Cerbos)

    1 month ago
    Yes that looks to be an oversight - thanks for flagging, we are looking into it now.
    Charith (Cerbos)

    Charith (Cerbos)

    1 month ago
    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
    go get <http://github.com/cerbos/cerbos/client@main|github.com/cerbos/cerbos/client@main>
    Thanks for reporting the issue.
    v

    Viet Au

    1 month ago
    nice one, thanks @Charith (Cerbos)
    Charith (Cerbos)

    Charith (Cerbos)

    1 month ago
    FYI: just released v0.19.1 with this fix.