Skip to content

[#6786] fix(authz): modify querying roles by user in ROLE_USER_REL relation for JcasbinAuthorizer#7376

Merged
xunliu merged 4 commits intoapache:branch-metadata-authzfrom
KyleLin0927:issue-6786
Jun 19, 2025
Merged

[#6786] fix(authz): modify querying roles by user in ROLE_USER_REL relation for JcasbinAuthorizer#7376
xunliu merged 4 commits intoapache:branch-metadata-authzfrom
KyleLin0927:issue-6786

Conversation

@KyleLin0927
Copy link
Contributor

What changes were proposed in this pull request?

Currently, the ROLE_USER_REL relation in JDBCBackend only supports querying users by role, but not querying roles by user. This causes issues in JcasbinAuthorizer when trying to load user privileges.

This PR adds support for querying roles by user in the ROLE_USER_REL relation by modifying the listEntitiesByRelation method in JDBCBackend.

Why are the changes needed?

Fixes #6786

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Ran ./gradlew clean build

@KyleLin0927
Copy link
Contributor Author

@hdygxsj plz help to confirm this, thanks.

Comment on lines +89 to +92
String metalake = NameIdentifierUtil.getMetalake(userIdent);
Long metalakeId = MetalakeMetaService.getInstance().getMetalakeIdByName(metalake);
Long userId =
UserMetaService.getInstance().getUserIdByMetalakeIdAndName(metalakeId, userIdent.name());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use UserMetaService.getInstance().getUserByIdentifier(nameIdentifier);.

Copy link
Contributor

@Abyss-lord Abyss-lord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@xunliu xunliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xunliu xunliu merged commit aca2a14 into apache:branch-metadata-authz Jun 19, 2025
28 of 30 checks passed
@roryqi
Copy link
Contributor

roryqi commented Jun 19, 2025

Actually, we don't need this. UserPO already has role names.

hdygxsj pushed a commit to hdygxsj/gravitino that referenced this pull request Jul 15, 2025
…REL relation for JcasbinAuthorizer (apache#7376)

### What changes were proposed in this pull request?

Currently, the `ROLE_USER_REL` relation in `JDBCBackend` only supports
querying users by role, but not querying roles by user. This causes
issues in `JcasbinAuthorizer` when trying to load user privileges.

This PR adds support for querying roles by user in the `ROLE_USER_REL`
relation by modifying the `listEntitiesByRelation` method in
`JDBCBackend`.

### Why are the changes needed?

Fixes apache#6786

### Does this PR introduce any user-facing change?

No.

### How was this patch tested?

Ran `./gradlew clean build`
hdygxsj pushed a commit to hdygxsj/gravitino that referenced this pull request Jul 15, 2025
…REL relation for JcasbinAuthorizer (apache#7376)

### What changes were proposed in this pull request?

Currently, the `ROLE_USER_REL` relation in `JDBCBackend` only supports
querying users by role, but not querying roles by user. This causes
issues in `JcasbinAuthorizer` when trying to load user privileges.

This PR adds support for querying roles by user in the `ROLE_USER_REL`
relation by modifying the `listEntitiesByRelation` method in
`JDBCBackend`.

### Why are the changes needed?

Fixes apache#6786

### Does this PR introduce any user-facing change?

No.

### How was this patch tested?

Ran `./gradlew clean build`
jerryshao pushed a commit that referenced this pull request Jul 15, 2025
…lation for JcasbinAuthorizer (#7376)

### What changes were proposed in this pull request?

Currently, the `ROLE_USER_REL` relation in `JDBCBackend` only supports
querying users by role, but not querying roles by user. This causes
issues in `JcasbinAuthorizer` when trying to load user privileges.

This PR adds support for querying roles by user in the `ROLE_USER_REL`
relation by modifying the `listEntitiesByRelation` method in
`JDBCBackend`.

### Why are the changes needed?

Fixes #6786

### Does this PR introduce any user-facing change?

No.

### How was this patch tested?

Ran `./gradlew clean build`
roryqi pushed a commit to qqqttt123/gravitino that referenced this pull request Jul 30, 2025
…REL relation for JcasbinAuthorizer (apache#7376)

### What changes were proposed in this pull request?

Currently, the `ROLE_USER_REL` relation in `JDBCBackend` only supports
querying users by role, but not querying roles by user. This causes
issues in `JcasbinAuthorizer` when trying to load user privileges.

This PR adds support for querying roles by user in the `ROLE_USER_REL`
relation by modifying the `listEntitiesByRelation` method in
`JDBCBackend`.

### Why are the changes needed?

Fixes apache#6786

### Does this PR introduce any user-facing change?

No.

### How was this patch tested?

Ran `./gradlew clean build`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants