-
Notifications
You must be signed in to change notification settings - Fork 189
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
feat: assume role validation #453
Conversation
executor_dispatcher::write(IExecutorDispatcher { | ||
contract_address: executor | ||
}); | ||
executor_dispatcher::write(IExecutorDispatcher { contract_address: executor }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting fix
crates/dojo-core/src/world.cairo
Outdated
// 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' | ||
); | ||
}; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 👍
#[test] | ||
#[available_gas(9000000)] | ||
#[should_panic] | ||
#[ignore] // TODO:: Remove once set_caller_address is working properly |
There was a problem hiding this comment.
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
There was a problem hiding this 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!
crates/dojo-core/src/world.cairo
Outdated
// 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' | ||
); | ||
}; |
There was a problem hiding this comment.
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
There was a problem hiding this 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 ! 🙏
crates/dojo-core/src/world.cairo
Outdated
// 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' | ||
); | ||
}; |
There was a problem hiding this comment.
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 👍
e542453
to
5326332
Compare
5326332
to
750b708
Compare
This pr does the following:
assume_role
)assume_role
usesdependencies
to check which systems access to write componentsclear_role
and checking if executed systems are part of the checking during role assumptionsudo
assume_role
#452