API key plugin - Orgs?

How is the best way to handle orgs via the API key plugin: E.g, if the user has acess to a ressource of a org or not. etc.
10 Replies
bekacru
bekacru2d ago
you can use permissions
kaas
kaasOP2d ago
Yes - But more if the user is assigned to multiple orgs My issue is the way i've done it now, users can "escape" and just query data for all orgs. Pretty sure I am the issue just looking for a general solution
bekacru
bekacru2d ago
you should still be able to assign a permissions that points to a specific orgId. But you can also just add the orgId on a metadata.
kaas
kaasOP2d ago
metadata for the api key?
bekacru
bekacru2d ago
yeah
kaas
kaasOP2d ago
So just include the orgid in the metadata - Then the API key is "only" for that org id. That would work . I assume I'd need to implement logic checking the api key for this
bekacru
bekacru2d ago
yeah. you'd need to check the orgId.
kaas
kaasOP2d ago
My current implementation does this When the user hits the use org, it adds the "activeorg" to the session, and all backend logic just checks what the users activeorg is, as they should't be able to change this other then to what orgs they have access to.
bekacru
bekacru2d ago
if scoping to one org is a hard requirement, you can just assume api key belongs to a user and they can query any org they are a part of.
kaas
kaasOP2d ago
But that would still require me to do custom logic on each route - So the user should query with the ord id. I think having seperate API keys for seperate orgs is the correct way to do it in my workflow

Did you find this page helpful?