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

chore: 🤖 review permissions #1413

Draft
wants to merge 1 commit into
base: alpha
Choose a base branch
from
Draft

chore: 🤖 review permissions #1413

wants to merge 1 commit into from

Conversation

sansan
Copy link
Contributor

@sansan sansan commented Dec 13, 2024

Description

  • for discussion
  • adds comments comparing permissions used on chain vs those that we check for with getAuthorization for procedures

on chain there are multiple ways how we check permissions, the main ones are

  • Identity::check_perms -> cheks if the identity can execute module/extrinsic on chain
  • External Agents:check_perms -> checks if the external agent has ownership ower asset, can execute the tx (module/extrinsic)
  • Checks for portfolio ownership

Additional checks are done via specific methods in the extrinsic - e.g. if the signer is multiSig admin, if it is multiSig

JIRA Link

https://polymesh.atlassian.net/browse/DA-1411

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
23 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@@ -55,6 +55,7 @@ export async function prepareRemoveSecondaryAccounts(
export const removeSecondaryAccounts = (): Procedure<RemoveSecondaryAccountsParams> =>
new Procedure(prepareRemoveSecondaryAccounts, {
permissions: {
// TODO: might not need this -> chain checks if called by primary key, checks if secondary key exists and can be unlinked, then unlinks
Copy link
Collaborator

Choose a reason for hiding this comment

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

chain checks if called by primary key,

I don't get this. Technically we don't need to check any permissions since the chain always checks them, but we do this to avoid having the chain catch obvious errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same here -> so as I understood from the chain logic -> there are no specific extra checks for the Tx method -> if it is ok with those two conditions then the extrinsic will run

@@ -81,6 +81,7 @@ export async function getAuthorization(

return {
permissions: {
// TODO: on chain just checks if is signed by primary key -> so we should check in prepareAddSecondaryKeysWithAuth if signer is the target primary key
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there is a few methods like this. Would we need to add an extra field to permissions for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean we don't need to check for the TxTags -> as the chain does not do it anyways

@@ -80,6 +80,7 @@ export async function getAuthorization(

return {
permissions: {
// TODO: might not need these as prepareUnlinkChildIdentity checks if signer is primary key of either the child or parent which the same as done on chain
transactions: [TxTags.identity.UnlinkChildIdentity],
Copy link
Collaborator

Choose a reason for hiding this comment

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

All the TxTags are given in the case where as secondary key is performing the given action, and if that key has the permission for that tx or not. Maybe in a few cases it may not be needed but my guess most of them will be required

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.

3 participants