Skip to content

Conversation

@konac-hamza
Copy link
Collaborator

No description provided.

| AssignmentType::GroupProject
| AssignmentType::UserDomain
| AssignmentType::UserProject => {
db_assignment::Entity::delete_many()
Copy link
Collaborator

Choose a reason for hiding this comment

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

all those fields are part of the composed PK. It is better to access it this way. Reason is that when some of the filter parameters here are wrong we may end up deleting what we should not

Copy link
Collaborator

Choose a reason for hiding this comment

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

please use the delete_by_id here

#[derive(Builder, Clone, Debug, Deserialize, PartialEq, Serialize, Validate)]
#[builder(build_fn(error = "BuilderError"))]
#[builder(setter(strip_option, into))]
pub struct AssignmentRevoke {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please implement the From for AssignmentRevoke. I think this is going to be more comfortable to use it this way (check the assignment and pass it down to the revoke), but honestly I doubt whether we need AssignmentRevoke at all (it's same except few optional fields) and we should just use the Assignment directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

During implementation, I also had doubts about the necessity of AssignmentRevoke.
Then I realized that the AssignmentCreate struct is almost the same as Assignment.
So I kept the same approach for AssignmentRevoke but use Assignment directly look more clear. I will update PR accordingly

Copy link
Collaborator

Choose a reason for hiding this comment

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

create/update is a slightly different usecase. Usually they look very similar, but have differences (i.e. some attributes are not updatable)


policy
.enforce(
"identity/project/user/role/check",
Copy link
Collaborator

Choose a reason for hiding this comment

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

that is definitely wrong - check policy is pretty permissive while role assignment/revokation is intended to be used by admin/domain_manager only (similar to the grant policy). I would need to implement this policy first

@konac-hamza konac-hamza force-pushed the feature/grant-deletion branch 2 times, most recently from 5f9d1f0 to 0f30fea Compare January 21, 2026 22:56
Copy link
Collaborator

@gtema gtema left a comment

Choose a reason for hiding this comment

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

after analysis of the python keystone I see few things that need to be addressed somehow (maybe consciously not implemented):

),
security(
("X-Auth-Token" = [])),
tag="Role Assignment"
Copy link
Collaborator

Choose a reason for hiding this comment

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

the openapi tag should match the one in the create assignment, it influences how endpoints are grouped

@konac-hamza konac-hamza force-pushed the feature/grant-deletion branch from 0f30fea to ac579ad Compare January 23, 2026 00:19
| AssignmentType::GroupProject
| AssignmentType::UserDomain
| AssignmentType::UserProject => {
db_assignment::Entity::delete_many()
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use the delete_by_id here

}

#[tokio::test]
async fn test_delete_inherited_not_found_returns_error() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

since the implementation does not really differentiate upon the inherited field this test makes no sense - mocks are the same

//
// SPDX-License-Identifier: Apache-2.0

//! Project user role: delete
Copy link
Collaborator

Choose a reason for hiding this comment

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

the new linter check will start complaining here. Please ensure docstrings have proper ending punctuation.

fn from(source: AssignmentDatabaseError) -> Self {
match source {
AssignmentDatabaseError::AssignmentNotFound(msg) => {
AssignmentProviderError::AssignmentNotFound(msg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this new error should be also handled in the stc/api/error - we do not want to return 500 to the user

@konac-hamza konac-hamza force-pushed the feature/grant-deletion branch from ac579ad to 5f480d9 Compare January 26, 2026 21:26
Copy link
Collaborator

@gtema gtema left a comment

Choose a reason for hiding this comment

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

is coming close. Can you please also add an integration test (https://github.com/openstack-experimental/keystone/blob/main/tests/integration/assignment/grant.rs) to verify that the grant has been revoked and the assignment check after revoke confirms it is not there. In the separate change you could add more tests (revoking a grant that was not present, revoking inherited grant, etc)

tag="role_assignments"
)]
#[tracing::instrument(
name = "api::v3:project_user_role_revoke",
Copy link
Collaborator

Choose a reason for hiding this comment

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

one ":" is missing

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.

2 participants