Checking effective permissions before you act - Techy Tuesday (003)

Happy Tuesday everyone! This week’s tip is a small one, but it’s the kind of thing that saves you a stack of failed requests and confused error handling once you know it exists: EffectivePermissions.

If you have ever built an integration that tries to update a presentation, approve a comment, or moderate content, and you weren’t sure whether the current user actually has permission to do that before you try it, this resource is built exactly for that question.

The call

One route, one verb. Pass in the MediasiteId of whatever resource you want to check, a presentation, a folder, a channel, anything with permissions:

GET/api/v1/EffectivePermissions('resourceId')

The response tells you exactly what the currently authenticated user can do with that specific resource, no guesswork, no need to decode an access control list yourself.

What comes back

Property What it tells you
Read Can the user read this resource
Write Can the user modify this resource
Execute Can the user run or view it (named View for presentations, Monitor for Recorders)
Approve Can the user approve content
Moderate Can the user moderate content
Annotate Can the user add annotations

Each one comes back as true, false, or null. True or false means the permission bit genuinely applies to that resource type and you have your answer. Null means that particular bit simply doesn’t apply to this kind of resource at all, so don’t read it as a denial.

Why not just try the action and catch the error

You can, and Mediasite will stop you regardless. But checking first means your integration can make a smart decision in advance, hide a button the user can’t use, skip a batch update for resources they don’t have Write on, or surface a clear message before they waste time filling out a form. It is the difference between handling a permissions problem gracefully and just bubbling up a raw 401 or 403.

Worth knowing: this only tells you the requesting user’s own permissions. If you need to see or edit the full access control list for a resource, for example to manage who else has Write access, that is a different resource entirely: ResourcePermissions. EffectivePermissions answers “can I”, ResourcePermissions answers “who can”.

This is one of those, you don’t really need it until you need it when building out a custom workflow. If you get to that point, let us know below! We are always curious what our customers are up to.

2 Likes