Skip to content

Conversation

@lionelschiepers
Copy link

Why make this change?

This pull request is related to issue 2115 (#2115) that reports that it's not
possible to filter entities anonymously accessible when the caller is using a custom role.

What is this change?

When filtering is disallowed for a custom role because the role is not defined for that entity, it is then checked for the authenticated role the custom role inherits from. Please note that when no authenticated role is defined for an entity, it is automatically defined using the definition of the anonymous role.

How was this tested?

I've tested in our live environment.

@seantleonard
Copy link
Contributor

Thank you for your contribution, I will take a look soon. But in the meantime, please add tests that exercise this scenario that you are fixing.

@JerryNixon
Copy link
Contributor

@Aniruddh25 we should review this this semester.

@JerryNixon
Copy link
Contributor

+1

@JerryNixon JerryNixon added this to the Backlog milestone Oct 7, 2025
@JerryNixon
Copy link
Contributor

This behavior described is by design, not a bug.

Here’s the key:

Data API builder does not perform role inheritance. Each role must be explicitly defined per entity in the configuration.

So when you set X-MS-API-ROLE = role-a, DAB looks for an explicit role-a permission block on that entity. If it doesn’t find one, it does not automatically inherit permissions from authenticated or anonymous. That’s why the filter authorization check fails.

The apparent inconsistency—being able to read fields but not filter—comes from how GraphQL and REST differ in execution paths. In the read operation, the engine evaluates “access to entity” (which passes through because of anonymous read permissions), but filtering checks column-level permission for the active role, which is undefined for role-a. Since DAB sees role-a but can’t find corresponding metadata, it correctly blocks the filter for security reasons.

@Aniruddh25
Copy link
Collaborator

Please note that when no authenticated role is defined for an entity, it is automatically defined using the definition of the anonymous role.

While this is true, the same rule does not apply to custom roles this authenticated and anonymous are special roles.

@Aniruddh25 Aniruddh25 closed this Nov 10, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in Data API builder Nov 10, 2025
@Aniruddh25
Copy link
Collaborator

Aniruddh25 commented Nov 10, 2025

As discussed in the issue here: #2115
this behavior is by design hence closing this PR.

But really appreciate and thank you for your deep investigation and contributions, @lionelschiepers!

Refer to this section of doc to add multiple permissions to the same entity, example:
dab add Book --source dbo.Books --permissions "anonymous:read" --permissions "authenticated:create,read,update,delete"
https://learn.microsoft.com/en-us/azure/data-api-builder/command-line/dab-add#--permissions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants