@@ -84,6 +84,18 @@ var IAMSelfManageInvitationPolicy = policy.NewPolicy(
|
||||
).
|
||||
WithDescription("Allows users to view and accept invitations sent to them")
|
||||
|
||||
// IAMSelfManageProfilePolicy allows users to view their own profiles.
|
||||
var IAMSelfManageProfilePolicy = policy.NewPolicy(
|
||||
"iam:self-manage-profile",
|
||||
"Self-Manage Profiles",
|
||||
|
||||
// Users can view their own profiles
|
||||
policy.Allow(ActionMembershipProfileGet).
|
||||
WithSID("view-own-profiles").
|
||||
When(policy.Equals("principal.id", "resource.identity_id")),
|
||||
).
|
||||
WithDescription("Allows users to view their organization profiles")
|
||||
|
||||
// IAMSelfManageMembershipPolicy allows users to view their own memberships.
|
||||
var IAMSelfManageMembershipPolicy = policy.NewPolicy(
|
||||
"iam:self-manage-membership",
|
||||
|
||||
@@ -504,9 +504,9 @@ func (s *OrganizationService) CreateOrganization(
|
||||
ctx context.Context,
|
||||
identityID gid.GID,
|
||||
req *CreateOrganizationRequest,
|
||||
) (*coredata.Organization, error) {
|
||||
) (*coredata.Organization, *coredata.Membership, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, fmt.Errorf("invalid request: %w", err)
|
||||
return nil, nil, fmt.Errorf("invalid request: %w", err)
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -584,7 +584,7 @@ func (s *OrganizationService) CreateOrganization(
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot upload logo file: %w", err)
|
||||
return nil, nil, fmt.Errorf("cannot upload logo file: %w", err)
|
||||
}
|
||||
|
||||
logoFile.FileSize = fileSize
|
||||
@@ -621,7 +621,7 @@ func (s *OrganizationService) CreateOrganization(
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot upload logo file: %w", err)
|
||||
return nil, nil, fmt.Errorf("cannot upload logo file: %w", err)
|
||||
}
|
||||
|
||||
horizontalLogoFile.FileSize = fileSize
|
||||
@@ -713,10 +713,10 @@ func (s *OrganizationService) CreateOrganization(
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot insert organization: %w", err)
|
||||
return nil, nil, fmt.Errorf("cannot insert organization: %w", err)
|
||||
}
|
||||
|
||||
return organization, nil
|
||||
return organization, membership, nil
|
||||
}
|
||||
|
||||
func (s *OrganizationService) UpdateOrganization(ctx context.Context, organizationID gid.GID, req *UpdateOrganizationRequest) (*coredata.Organization, error) {
|
||||
|
||||
@@ -66,6 +66,7 @@ func IAMPolicySet() *PolicySet {
|
||||
IAMSelfManageIdentityPolicy,
|
||||
IAMSelfManageSessionPolicy,
|
||||
IAMSelfManageInvitationPolicy,
|
||||
IAMSelfManageProfilePolicy,
|
||||
IAMSelfManageMembershipPolicy,
|
||||
IAMSelfManagePersonalAPIKeyPolicy,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user