feat: get current label and privacy policies (#3748)

This commit is contained in:
Livio Amstutz 2022-06-01 09:50:28 +02:00 committed by GitHub
parent b0436c995b
commit 21a0e4a972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 123 additions and 0 deletions

View File

@ -570,6 +570,30 @@ Limit should always be set, there is a default limit set by the service
POST: /memberships/me/_search
### GetMyLabelPolicy
> **rpc** GetMyLabelPolicy([GetMyLabelPolicyRequest](#getmylabelpolicyrequest))
[GetMyLabelPolicyResponse](#getmylabelpolicyresponse)
Returns the label policy of the current organisation
GET: /policies/label
### GetMyPrivacyPolicy
> **rpc** GetMyPrivacyPolicy([GetMyPrivacyPolicyRequest](#getmyprivacypolicyrequest))
[GetMyPrivacyPolicyResponse](#getmyprivacypolicyresponse)
Returns the privacy policy of the current organisation
GET: /policies/privacy
@ -726,6 +750,23 @@ This is an empty request
### GetMyLabelPolicyRequest
This is an empty request
### GetMyLabelPolicyResponse
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| policy | zitadel.policy.v1.LabelPolicy | - | |
### GetMyMetadataRequest
@ -783,6 +824,23 @@ This is an empty request
### GetMyPrivacyPolicyRequest
This is an empty request
### GetMyPrivacyPolicyResponse
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| policy | zitadel.policy.v1.PrivacyPolicy | - | |
### GetMyProfileRequest
This is an empty request

View File

@ -0,0 +1,29 @@
package auth
import (
"context"
"github.com/zitadel/zitadel/internal/api/authz"
policy_grpc "github.com/zitadel/zitadel/internal/api/grpc/policy"
auth_pb "github.com/zitadel/zitadel/pkg/grpc/auth"
)
func (s *Server) GetMyLabelPolicy(ctx context.Context, _ *auth_pb.GetMyLabelPolicyRequest) (*auth_pb.GetMyLabelPolicyResponse, error) {
policy, err := s.query.ActiveLabelPolicyByOrg(ctx, authz.GetCtxData(ctx).OrgID)
if err != nil {
return nil, err
}
return &auth_pb.GetMyLabelPolicyResponse{
Policy: policy_grpc.ModelLabelPolicyToPb(policy, s.assetsAPIDomain(ctx)),
}, nil
}
func (s *Server) GetMyPrivacyPolicy(ctx context.Context, _ *auth_pb.GetMyPrivacyPolicyRequest) (*auth_pb.GetMyPrivacyPolicyResponse, error) {
policy, err := s.query.PrivacyPolicyByOrg(ctx, authz.GetCtxData(ctx).OrgID)
if err != nil {
return nil, err
}
return &auth_pb.GetMyPrivacyPolicyResponse{
Policy: policy_grpc.ModelPrivacyPolicyToPb(policy),
}, nil
}

View File

@ -585,6 +585,28 @@ service AuthService {
permission: "authenticated"
};
}
// Returns the label policy of the current organisation
rpc GetMyLabelPolicy(GetMyLabelPolicyRequest) returns (GetMyLabelPolicyResponse) {
option (google.api.http) = {
get: "/policies/label"
};
option (zitadel.v1.auth_option) = {
permission: "authenticated"
};
}
// Returns the privacy policy of the current organisation
rpc GetMyPrivacyPolicy(GetMyPrivacyPolicyRequest) returns (GetMyPrivacyPolicyResponse) {
option (google.api.http) = {
get: "/policies/privacy"
};
option (zitadel.v1.auth_option) = {
permission: "authenticated"
};
}
}
//This is an empty request
@ -1017,3 +1039,17 @@ message ListMyMembershipsResponse {
zitadel.v1.ListDetails details = 1;
repeated zitadel.user.v1.Membership result = 2;
}
//This is an empty request
message GetMyLabelPolicyRequest {}
message GetMyLabelPolicyResponse {
zitadel.policy.v1.LabelPolicy policy = 1;
}
//This is an empty request
message GetMyPrivacyPolicyRequest {}
message GetMyPrivacyPolicyResponse {
zitadel.policy.v1.PrivacyPolicy policy = 1;
}