Skip to content

refactor: merge AuthMethod into AccessControl#2944

Open
onurinanc wants to merge 5 commits into
nextfrom
fix-auth-controlled
Open

refactor: merge AuthMethod into AccessControl#2944
onurinanc wants to merge 5 commits into
nextfrom
fix-auth-controlled

Conversation

@onurinanc
Copy link
Copy Markdown
Collaborator

@onurinanc onurinanc commented May 18, 2026

Closes: #2930
Fixes: #2943

Tasks:

Copy link
Copy Markdown
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Thank you! Not a review yet, but I left some comments inline. For now, more questions/thoughts than concrete suggestions.

Comment on lines +640 to +643
/// 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines 73 to 90
@@ -59,29 +86,51 @@ pub enum AccessControl {
Rbac {
owner: AccountId,
authority_role: Option<RoleSymbol>,
auth: AuthMethod,
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adding AuthMethod to Ownable2Step and Rbac feels a bit off
I agree on this. Additionally, adding and AuthMethod to AccessControl doesn't sound well either. AuthControlled should be an account component similar to Ownable2Step and Rbac and having an AccountAuthComponent would be a good variant instead of combining AuthMethod with AuthControlled.

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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator

@mmagician mmagician left a comment

Choose a reason for hiding this comment

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

It looks like this PR contains most of the changes from #2958

Comment on lines -69 to -71
/// 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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

was this comment removed on purpose?

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.

Consider merging AuthMethod into AccessControl Bug: AuthControlled faucet leaves Authority setters unauthenticated

3 participants