refactor: merge AuthMethod into AccessControl#2944
Conversation
bobbinth
left a comment
There was a problem hiding this comment.
Thank you! Not a review yet, but I left some comments inline. For now, more questions/thoughts than concrete suggestions.
| /// Rejects [`AuthMethod::Multisig`] / [`AuthMethod::Unknown`] for all variants (faucets do | ||
| /// not support Multisig today), and rejects [`AuthMethod::NoAuth`] specifically under | ||
| /// [`AccessControl::AuthControlled`] because it would leave authority-gated setters | ||
| /// permissionless. |
There was a problem hiding this comment.
There is no fundamental reason why faucets shouldn't support multisig-based auth. Let's create an issue for this - though, it'll probably be a fairly low priority.
| @@ -59,29 +86,51 @@ pub enum AccessControl { | |||
| Rbac { | |||
| owner: AccountId, | |||
| authority_role: Option<RoleSymbol>, | |||
| auth: AuthMethod, | |||
| }, | |||
There was a problem hiding this comment.
Adding AuthMethod to Ownable2Step and Rbac feels a bit off because currently the only "legal" value for these variants is AuthMethod::NetworkAccount. I think the fault mostly lies in the AuthMethod enum which is kind of in between an auth component and a pure enum.
It would be a bigger refactoring, but I think we should get rid of AuthMethod enum altogether and replace it with something like AccountAuthComponent struct which would be a wrapper over AccountComponent with some convenience constructors.
There was a problem hiding this comment.
Adding AuthMethod to Ownable2Step and Rbac feels a bit off
I agree on this. Additionally, adding andAuthMethodtoAccessControldoesn't sound well either.AuthControlledshould be an account component similar toOwnable2StepandRbacand having anAccountAuthComponentwould be a good variant instead of combiningAuthMethodwithAuthControlled.
For this refactoring, do we also need #2621 this to be merged? similar to below comment?
Other than that, if we decide to remove AuthMethod and replace it with AccountAuthComponent, I think separating this PR into two:
- The first one is as described above: Consider merging
AuthMethodintoAccessControl#2930 - The second on is resolving this issue: Bug:
AuthControlledfaucet leavesAuthoritysetters unauthenticated #2943
There was a problem hiding this comment.
Yes, let's tackle #2943 separately (which I see you've already done) - and then we can come back here and do a more comprehensive refactoring.
| /// | ||
| /// The faucet itself, including all token metadata, is provided in the `faucet` parameter (see | ||
| /// [`FungibleFaucet::builder`]). | ||
| pub fn create_fungible_faucet( |
There was a problem hiding this comment.
I wonder if we are trying to do too much with this single function. Maybe it is worth splitting it up with a couple functions - something like:
pub fn create_network_fungible_faucet(
init_seed: [u8; 32],
faucet: FungibleFaucet,
access_control: AccessControl, // this would contain only Ownable2Step and Rbac
token_policy_manager: TokenPolicyManager,
storage_mode: AccountStorageMode,
) -> Result<Account, FungibleFaucetError> {
...
}
pub fn create_user_fungible_faucet(
init_seed: [u8; 32],
faucet: FungibleFaucet,
auth_method: AuthMethod, // this would not contain NetworkAccount
token_policy_manager: TokenPolicyManager,
storage_mode: AccountStorageMode,
) -> Result<Account, FungibleFaucetError> {
...
}But again, this would be a bigger refactoring along the lines of #2621.
There was a problem hiding this comment.
This approach seems to me better in that way we can separate AccountAuthComponent and AccessControl. We might also want to rename the AccessControl enum to NetworkAccessControl and doesn't include AccountAuthComponent as a variant in the enum.
| /// Yields the [`AccountComponent`]s implementing this access control configuration, in the | ||
| /// order they must be installed on the account. The matching [`Authority`] component is | ||
| /// always included. |
There was a problem hiding this comment.
was this comment removed on purpose?
Closes: #2930
Fixes: #2943
Tasks:
build_auth_componentmethod added in Fix: AuthControlled faucet leaves Authority setters unauthenticated #2958create_fungible_faucetascreate_network_fungible_faucetandcreate_user_fungible_faucetspecified here: refactor: mergeAuthMethodintoAccessControl#2944 (comment)