Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: assume role validation #453

Merged
merged 12 commits into from
Jun 12, 2023

Conversation

ftupas
Copy link
Contributor

@ftupas ftupas commented Jun 9, 2023

This pr does the following:

  • update authorization checking during role assumption (assume_role)
  • fallback check on the default resource-scoped role for when role is not set
  • assume_role uses dependencies to check which systems access to write components
  • add clear_role and checking if executed systems are part of the checking during role assumption
  • update admin role to sudo
  • resolves feat: Move validation check to assume_role #452

executor_dispatcher::write(IExecutorDispatcher {
contract_address: executor
});
executor_dispatcher::write(IExecutorDispatcher { contract_address: executor });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Formatting fix

Comment on lines 278 to 286
// Validate authorization if role is not set
// Otherwise, proceed with the write
if role.into() == 0 {
// Validate the calling system has permission to write to the component
assert(
is_authorized(context.caller_system, component, AuthRole { id: role }),
'system not authorized'
);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Authorization flow when role is not set, default resource-scoped role is checked

Copy link
Contributor

Choose a reason for hiding this comment

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

We should make this behavior more explicit in the refactor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, will add it to the refactor issue 👍

crates/dojo-core/src/world.cairo Outdated Show resolved Hide resolved
#[test]
#[available_gas(9000000)]
#[should_panic]
#[ignore] // TODO:: Remove once set_caller_address is working properly
Copy link
Contributor Author

Choose a reason for hiding this comment

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

starknet::testing::set_caller_address doesn't seem to work properly so I marked this as ignored for now

Copy link
Contributor

@tarrencev tarrencev left a comment

Choose a reason for hiding this comment

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

looks great! thank you!

Comment on lines 278 to 286
// Validate authorization if role is not set
// Otherwise, proceed with the write
if role.into() == 0 {
// Validate the calling system has permission to write to the component
assert(
is_authorized(context.caller_system, component, AuthRole { id: role }),
'system not authorized'
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

We should make this behavior more explicit in the refactor

crates/dojo-core/src/world.cairo Outdated Show resolved Hide resolved
Copy link
Contributor Author

@ftupas ftupas left a comment

Choose a reason for hiding this comment

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

Thanks for the feedback @tarrencev ! 🙏

Comment on lines 278 to 286
// Validate authorization if role is not set
// Otherwise, proceed with the write
if role.into() == 0 {
// Validate the calling system has permission to write to the component
assert(
is_authorized(context.caller_system, component, AuthRole { id: role }),
'system not authorized'
);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, will add it to the refactor issue 👍

crates/dojo-core/src/world.cairo Outdated Show resolved Hide resolved
crates/dojo-core/src/world.cairo Outdated Show resolved Hide resolved
@ftupas ftupas force-pushed the feat/assume-role-validation branch from e542453 to 5326332 Compare June 12, 2023 12:00
@ftupas ftupas force-pushed the feat/assume-role-validation branch from 5326332 to 750b708 Compare June 12, 2023 12:00
@tarrencev tarrencev merged commit 2b5f185 into dojoengine:main Jun 12, 2023
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.

feat: Move validation check to assume_role
2 participants