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

Dynamic Permissions #111

Merged
merged 8 commits into from
Dec 6, 2023
Merged

Dynamic Permissions #111

merged 8 commits into from
Dec 6, 2023

Conversation

FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Oct 19, 2023

Adds a SIP that specifies how snaps can utilize dynamic permissions.

Closes MetaMask/snaps#1820

SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Show resolved Hide resolved
SIPS/sip-14.md Show resolved Hide resolved
SIPS/sip-14.md Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated

## Motivation

Snaps currently have to request all permissions that they plan to use at install-time. This becomes a problem when a Snap wants to use many permissions as the installation experience suffers and the user has to either accept all permissions requested or deny the installation. This proposal provides an improvement to the experience by letting Snaps request permissions at run-time as long as those permissions are statically defined in the manifest at build-time.
Copy link
Contributor

Choose a reason for hiding this comment

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

With the exception of eth_accounts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that is true. But eth_accounts is kind of an edge-case right now. We should probably require it being put into dynamicPermissions

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be a new permission? Right now we just require that they request endowment:ethereum-provider, so it's like a dynamic permission on top of a static one.

Copy link
Member Author

Choose a reason for hiding this comment

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

eth_accounts is an edge-case because it is technically a permission that is granted when using certain RPC methods with endowment:ethereum-provider. It is not inherently granted just by having the endowment.

We could choose to enforce that you need to have it as part of dynamicPermissions to grant it via endowment:ethereum-provider. We could also choose to keep it as the edge-case that it is.

Copy link
Contributor

@Montoya Montoya Oct 27, 2023

Choose a reason for hiding this comment

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

I do wonder if we have created a strange design pattern with the current approach. What if a Snap just wants eth_accounts and is requesting endowment:ethereum-provider just for that, and not using anything else that the endowment offers? Maybe it should be a separate endowment that must be defined in dynamicPermissions and is never in initialPermissions. Assuming this change would be in manifest version 0.2 and would not be backwards compatible.

To be clear I am comfortable punting on this topic, leaving eth_accounts as a special edge case and solving this in a separate effort.

SIPS/sip-14.md Show resolved Hide resolved
Montoya
Montoya previously approved these changes Dec 4, 2023
Copy link
Contributor

@Montoya Montoya left a comment

Choose a reason for hiding this comment

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

LGTM

@FrederikBolding FrederikBolding marked this pull request as ready for review December 4, 2023 15:13
@FrederikBolding FrederikBolding requested review from ziad-saab and a team as code owners December 4, 2023 15:13
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Show resolved Hide resolved
}
```

The caveat information passed SHOULD be ignored in the initial implementation of this. Instead of processing the caveats, the implementation SHOULD revoke the entire permission key. We will revisit this at a later time to make it more granular.
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to specify the caveats if it's ignored? Or is it for future compatibility?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea was that it would be future proof this way. We can make it more granular as we see fit

Copy link
Member

Choose a reason for hiding this comment

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

I would probably just remove the caveat part. It just makes it more complicated for Snaps developers to use this method, doesn't it? In the future when we revisit this, Snaps developers can just change it to only revoke certain caveats, and we revoke everything if the object is empty or something.

SIPS/sip-14.md Outdated Show resolved Hide resolved
SIPS/sip-14.md Outdated Show resolved Hide resolved
Co-authored-by: Maarten Zuidhoorn <[email protected]>
Copy link
Contributor

@Montoya Montoya left a comment

Choose a reason for hiding this comment

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

LGTM

@FrederikBolding FrederikBolding merged commit fd17d23 into main Dec 6, 2023
3 checks passed
@FrederikBolding FrederikBolding deleted the fb/dynamic-permissions branch December 6, 2023 14:42
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.

Dynamic Permissions SIP
3 participants