-
Notifications
You must be signed in to change notification settings - Fork 363
Conversation
…-permissions-management # Conflicts: # src/routes/safe/components/Apps/components/AppFrame.tsx
CLA Assistant Lite All Contributors have signed the CLA. |
…-permissions-management
…-permissions-management
…-permissions-management
src/routes/safe/components/Apps/hooks/useSafeAppFromManifest.ts
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Apps/hooks/permissions/usePermissions.ts
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Apps/components/PermissionsPrompt.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Apps/components/PermissionsPrompt.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Settings/SafeAppsPermissions/index.tsx
Outdated
Show resolved
Hide resolved
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.
Good job senor 🎉 I suggest to also ask someone else for a review, it's a big PR and I could easily miss something
safeAppsUtils.canLoadAppImage = jest.fn().mockResolvedValue(true) | ||
// @ts-ignore | ||
axios.get.mockImplementation((url: string) => { | ||
console.log(url) |
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.
console.log sneaked in
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.
done!. Yep, i will wait to Dani's to review it
Hola! I wonder if we should do some magic for custom apps that are not added to the list and opened, for example, via the share app link. If I open this app directly I am always going to be asked for permissions (which makes sense as the app wouldn't work otherwise) but as the app is not added as a custom app, permissions will be created in the local storage but I will not be able to remove them. As a workaround I think we could add a remove option per app in this screen: What do you think? |
A button for remove the entry in the settings is fine for me |
I suppose that the typical bin icon could help there. @yagopv check the styling in case there is a long list of permissions there |
All bueno after the latest changes, thank you guys! |
What it solves
Resolves safe-global/safe-apps-sdk#318
How this PR fixes it
Designs
RFC
How to test it
For testing purposes we can use these 3 custom applications allowing you to test both Safe Permissions and Browser Permissions
This applications will ...
wallet_getPermissions
,wallet_requestPermissions
andrequestAddressBook
using the RPC tabThis Wallet Connect version test application:
... is a wallet-connect version asking for camera permissions because we added the
safe_apps_permissions
property inmanifest.json
🧑💻 Start testing with empty localStorage:
Safe Permissions
Test in this order:
Calling
wallet_getPermissions
should return an empty array as you don't have permissionsCalling
wallet_requestPermissions
entering an unknown method string (any different thanrequestAddressBook
), should raise a Permissions error in the consolewallet_requestPermissions
entering a known method string (requestAddressBook
) should show a popup asking for approve or reject the permissions.3.1) when approve the permission will be saved to localStorage under SAFE__BROWSER_PERMISSIONS
3.1) when reject the permission will be saved to localStorage under SAFE__BROWSER_PERMISSIONS but with a caveats array with the
userRestricted
type in place (true
value). This means the user explicitly decide to not allow the access to the permission and is important for not asking again when usingsdk.requestAddressBook()
method. An exception with Permissions rejected is raised in the consoleCalling
wallet_getPermissions
after accepting or rejecting should return an array with the new permission configuration for the corresponding originCalling
requestAddressBook
5.1) when you accepted then should return the addressBook
5.2) when you rejected then should return an empty array
🧑💻 Remove (only) SAFE__BROWSER_PERMISSIONS entry from localStorage
Calling
requestAddressBook
(This is what the safe apps developers are going to use as internally callwallet_getPermissions
andwallet_requestPermissions
) should show the prompt asking for permissions.6.1) when you accepted then should return the addressBook. Subsequents requests will return the address book without prompting again
6.2) when you rejected then and a exception is raised in the console. Subsequents will return an empty address book
Go to settings and select/unselect the options per domain. When you return to the app the selection should be reflected. The application is going to match the selection but not prompting again unless you call explicitly
wallet_requestPermission
. So calls torequestAddressBook
will return the address book or an empty arrayCalling
wallet_requestPermission
should always show the prompt and update the stored user decisionCalling
window.parent.postMessage
with the correct data9.1) when the user doesn't have permissions the application cannot get the addressBook
9.2) when the user has permissions then should return the address book
You can use the "Regular postMessage" button in the Test apps
Browser Permissions
When the app initially loads a new permissions slide in Security Feedback Modal should be added for selecting the browser features the user wants to allow. You can keep all selected or make a choice. When you end with the Modal the choice should be reflected in localStorage under SAFE__BROWSER_PERMISSIONS.
After the initial selection the features should be added to the allow iframe attribute
Once selected the modal shouldn't show again unless the permissions in the manifest change
When the user choose to unselect some of the features then an error is raised in the console when the application try to access them as some of the features will be missing in the allow attribute on the iframe
You can use the Wallet Connect test app included previously
You can allow or block. This is showed once per top level domain so if several apps are requesting for camera access only once should be showed
Go to the Settings management section and change features in each app. Next time you open the app it should reflect the selection
When the app change the permissions in the manifest then the initial modal should be showed again
When a custom app is removed the corresponding permissions should be removed
Screenshots
Safe Permissions prompt
Browser permissions slide in Security Feedback modal
Safe Permissions management in Settings