Skip to content

Commit

Permalink
feat: store mutable permissions in its own GroupMutablePermissionsV1 …
Browse files Browse the repository at this point in the history
…message
  • Loading branch information
cameronvoell committed Apr 26, 2024
1 parent 1b21fb0 commit 823187f
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 62 deletions.
2 changes: 1 addition & 1 deletion proto/mls/message_contents/group_metadata.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Group metadata
// Group immutable metadata
syntax = "proto3";

package xmtp.mls.message_contents;
Expand Down
69 changes: 8 additions & 61 deletions proto/mls/message_contents/group_mutable_metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,71 +6,18 @@ package xmtp.mls.message_contents;
option go_package = "github.com/xmtp/proto/v3/go/mls/message_contents";
option java_package = "org.xmtp.proto.mls.message.contents";


// Message for group mutable metadata
message GroupMutableMetadataV1 {
// Map to store various metadata attributes (Group name, etc.)
map<string, string> attributes = 1;
PolicySet policies = 2;
}

// The set of policies that govern the group
message PolicySet {
MembershipPolicy add_member_policy = 1;
MembershipPolicy remove_member_policy = 2;
map<string, MetadataPolicy> update_metadata_policy = 3;
}

// A policy that governs adding/removing members or installations
message MembershipPolicy {
// Base policy
enum BasePolicy {
BASE_POLICY_UNSPECIFIED = 0;
BASE_POLICY_ALLOW = 1;
BASE_POLICY_DENY = 2;
BASE_POLICY_ALLOW_IF_ACTOR_CREATOR = 3;
}

// Combine multiple policies. All must evaluate to true
message AndCondition {
repeated MembershipPolicy policies = 1;
}

// Combine multiple policies. Any must evaluate to true
message AnyCondition {
repeated MembershipPolicy policies = 1;
}

oneof kind {
BasePolicy base = 1;
AndCondition and_condition = 2;
AnyCondition any_condition = 3;
}
AccountAddresses admin_list = 2;
// Creator starts as only super_admin
// Only super_admin can add/remove other super_admin
AccountAddresses super_admin_list = 3;
}

// A policy that governs updating metadata
message MetadataPolicy {
// Base policy
enum MetadataBasePolicy {
METADATA_BASE_POLICY_UNSPECIFIED = 0;
METADATA_BASE_POLICY_ALLOW = 1;
METADATA_BASE_POLICY_DENY = 2;
METADATA_BASE_POLICY_ALLOW_IF_ACTOR_CREATOR = 3;
}

// Combine multiple policies. All must evaluate to true
message AndCondition {
repeated MetadataPolicy policies = 1;
}

// Combine multiple policies. Any must evaluate to true
message AnyCondition {
repeated MetadataPolicy policies = 1;
}

oneof kind {
MetadataBasePolicy base = 1;
AndCondition and_condition = 2;
AnyCondition any_condition = 3;
}
// Wrapper around a list af repeated EVM Account Addresses
message AccountAddresses {
repeated string account_addresses = 1;
}

106 changes: 106 additions & 0 deletions proto/mls/message_contents/group_permissions.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Group mutable permissions metadata
syntax = "proto3";

package xmtp.mls.message_contents;

option go_package = "github.com/xmtp/proto/v3/go/mls/message_contents";
option java_package = "org.xmtp.proto.mls.message.contents";

// Message for group mutable metadata
message GroupMutablePermissionsV1 {\
PolicySet policies = 1;
}

// The set of policies that govern the group
message PolicySet {
MembershipPolicy add_member_policy = 1;
MembershipPolicy remove_member_policy = 2;
map<string, MetadataPolicy> update_metadata_policy = 3;
MetadataPolicy add_admin_policy = 4;
MetadataPolicy remove_admin_policy = 5;
PermissionsUpdatePolicy update_permissions_policy = 6;
}

// A policy that governs adding/removing members or installations
message MembershipPolicy {
// Base policy
enum BasePolicy {
BASE_POLICY_UNSPECIFIED = 0;
BASE_POLICY_ALLOW = 1;
BASE_POLICY_DENY = 2;
BASE_POLICY_ALLOW_IF_ADMIN_OR_SUPER_ADMIN = 3;
BASE_POLICY_ALLOW_IF_SUPER_ADMIN = 4;
}

// Combine multiple policies. All must evaluate to true
message AndCondition {
repeated MembershipPolicy policies = 1;
}

// Combine multiple policies. Any must evaluate to true
message AnyCondition {
repeated MembershipPolicy policies = 1;
}

oneof kind {
BasePolicy base = 1;
AndCondition and_condition = 2;
AnyCondition any_condition = 3;
}
}

// A policy that governs updating metadata
message MetadataPolicy {
// Base policy
enum MetadataBasePolicy {
METADATA_BASE_POLICY_UNSPECIFIED = 0;
METADATA_BASE_POLICY_ALLOW = 1;
METADATA_BASE_POLICY_DENY = 2;
METADATA_BASE_POLICY_ALLOW_IF_ADMIN = 3;
METADATA_BASE_POLICY_ALLOW_IF_SUPER_ADMIN = 4;
}

// Combine multiple policies. All must evaluate to true
message AndCondition {
repeated MetadataPolicy policies = 1;
}

// Combine multiple policies. Any must evaluate to true
message AnyCondition {
repeated MetadataPolicy policies = 1;
}

oneof kind {
MetadataBasePolicy base = 1;
AndCondition and_condition = 2;
AnyCondition any_condition = 3;
}
}

// A policy that governs updating permissions
message PermissionsUpdatePolicy {
// Base policy
enum PermissionsBasePolicy {
PERMISSIONS_BASE_POLICY_UNSPECIFIED = 0;
PERMISSIONS_BASE_POLICY_ALLOW = 1;
PERMISSIONS_BASE_POLICY_DENY = 2;
PERMISSIONS_BASE_POLICY_ALLOW_IF_ADMIN = 3;
PERMISSIONS_BASE_POLICY_ALLOW_IF_SUPER_ADMIN = 4;
}

// Combine multiple policies. All must evaluate to true
message AndCondition {
repeated PermissionsUpdatePolicy policies = 1;
}

// Combine multiple policies. Any must evaluate to true
message AnyCondition {
repeated PermissionsUpdatePolicy policies = 1;
}

oneof kind {
PermissionsBasePolicy base = 1;
AndCondition and_condition = 2;
AnyCondition any_condition = 3;
}
}

0 comments on commit 823187f

Please sign in to comment.