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

create RequestBody struct, implement it using requests, add requestbody into Attribute for auditing #5124

Merged
merged 21 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b98c07b
Revert "CDNC-2088 (#5094) Add attempt-count to task processing logs"
bowenxia Feb 23, 2023
0a1b61f
experiment on adding audit info (has errorsgit status)
bowenxia Feb 24, 2023
1953ffe
Merge branch 'uber:master' into CDNC-2946-Add-Audit-Info
bowenxia Feb 24, 2023
acc3fed
move AuditInfo into Attr
bowenxia Feb 28, 2023
4a05932
implement requestBody Struct, implement it using requests, add it int…
bowenxia Mar 1, 2023
e3289ec
Merge branch 'master' into CDNC-2946-Add-Audit-Info
bowenxia Mar 1, 2023
f202aa1
change struct name to be ManualRequestBody to avoid conflict
bowenxia Mar 1, 2023
24c792b
change any to interface to solve a compiling error
bowenxia Mar 1, 2023
8939918
rerun make go-generate && make fmt && make lint && make copyright for…
bowenxia Mar 1, 2023
5a0894b
change the PII-filtered request to still be a requset instead of a map
bowenxia Mar 1, 2023
839db23
add a utility function to check if access is manual, add request body…
bowenxia Mar 2, 2023
80df291
Merge branch 'master' into CDNC-2946-Add-Audit-Info
bowenxia Mar 2, 2023
b7006fd
update with make go-generate && make fmt && make lint && make copyright
bowenxia Mar 2, 2023
e57f774
update comments and naming
bowenxia Mar 2, 2023
2e120ea
change Sprintf to marshal
bowenxia Mar 3, 2023
2e5d4d7
add error handling for json.marshal, pass it to the caller of Seriali…
bowenxia Mar 3, 2023
234e3c6
add a new log tag for actor email address
bowenxia Mar 3, 2023
fcc5429
update interface function error handling
bowenxia Mar 3, 2023
6428a9e
pass in a pointer for serialization instead of a struct
bowenxia Mar 6, 2023
f891ee7
Merge branch 'master' into CDNC-2946-Add-Audit-Info
bowenxia Mar 6, 2023
263d9b9
delete the isManual checks when creating Attributes
bowenxia Mar 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions common/authorization/authority_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions common/authorization/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type (
WorkflowType *types.WorkflowType
TaskList *types.TaskList
Permission Permission
RequestBody FilteredRequestBody // request object except for data inputs (PII)
}

// Result is result from authority.
Expand Down Expand Up @@ -97,3 +98,8 @@ func GetAuthProviderClient(privateKey string) (clientworker.AuthorizationProvide
}
return clientworker.NewAdminJwtAuthorizationProvider(pk), nil
}

// FilteredRequestBody request object except for data inputs (PII)
type FilteredRequestBody interface {
SerializeForLogging() (string, error)
}
10 changes: 10 additions & 0 deletions common/log/tag/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,21 @@ func ActorID(actorID string) Tag {
return newStringTag("actor-id", actorID)
}

// ActorEmail returns tag for the actor's email address
func ActorEmail(actorEmail string) Tag {
return newStringTag("actor-email", actorEmail)
}

// HandlerCall returns tag for the API name of a request
func HandlerCall(handlerCall string) Tag {
return newStringTag("handler-call", handlerCall)
}

// RequestBody returns the tag for the API request body
func RequestBody(requestBody string) Tag {
return newStringTag("request-body", requestBody)
}

// history engine shard

// ShardID returns tag for ShardID
Expand Down
36 changes: 36 additions & 0 deletions common/types/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ type AddSearchAttributeRequest struct {
SecurityToken string `json:"securityToken,omitempty"`
}

func (v *AddSearchAttributeRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetSearchAttribute is an internal getter (TBD...)
func (v *AddSearchAttributeRequest) GetSearchAttribute() (o map[string]IndexedValueType) {
if v != nil && v.SearchAttribute != nil {
Expand All @@ -47,6 +51,10 @@ type AdminDescribeWorkflowExecutionRequest struct {
Execution *WorkflowExecution `json:"execution,omitempty"`
}

func (v *AdminDescribeWorkflowExecutionRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetDomain is an internal getter (TBD...)
func (v *AdminDescribeWorkflowExecutionRequest) GetDomain() (o string) {
if v != nil {
Expand Down Expand Up @@ -91,6 +99,10 @@ type GetWorkflowExecutionRawHistoryV2Request struct {
NextPageToken []byte `json:"nextPageToken,omitempty"`
}

func (v *GetWorkflowExecutionRawHistoryV2Request) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetDomain is an internal getter (TBD...)
func (v *GetWorkflowExecutionRawHistoryV2Request) GetDomain() (o string) {
if v != nil {
Expand Down Expand Up @@ -206,6 +218,10 @@ type ResendReplicationTasksRequest struct {
EndVersion *int64 `json:"endVersion,omitempty"`
}

func (v *ResendReplicationTasksRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetWorkflowID is an internal getter (TBD...)
func (v *ResendReplicationTasksRequest) GetWorkflowID() (o string) {
if v != nil {
Expand Down Expand Up @@ -242,6 +258,10 @@ type GetDynamicConfigRequest struct {
Filters []*DynamicConfigFilter `json:"filters,omitempty"`
}

func (v *GetDynamicConfigRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

type GetDynamicConfigResponse struct {
Value *DataBlob `json:"value,omitempty"`
}
Expand All @@ -251,18 +271,30 @@ type UpdateDynamicConfigRequest struct {
ConfigValues []*DynamicConfigValue `json:"configValues,omitempty"`
}

func (v *UpdateDynamicConfigRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

type RestoreDynamicConfigRequest struct {
ConfigName string `json:"configName,omitempty"`
Filters []*DynamicConfigFilter `json:"filters,omitempty"`
}

func (v *RestoreDynamicConfigRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// AdminDeleteWorkflowRequest is an internal type (TBD...)
type AdminDeleteWorkflowRequest struct {
Domain string `json:"domain,omitempty"`
Execution *WorkflowExecution `json:"execution,omitempty"`
SkipErrors bool `json:"skipErrors,omitempty"`
}

func (v *AdminDeleteWorkflowRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

func (v *AdminDeleteWorkflowRequest) GetDomain() (o string) {
if v != nil {
return v.Domain
Expand Down Expand Up @@ -298,6 +330,10 @@ type ListDynamicConfigRequest struct {
ConfigName string `json:"configName,omitempty"`
}

func (v *ListDynamicConfigRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

type ListDynamicConfigResponse struct {
Entries []*DynamicConfigEntry `json:"entries,omitempty"`
}
24 changes: 24 additions & 0 deletions common/types/replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ type GetDLQReplicationMessagesRequest struct {
TaskInfos []*ReplicationTaskInfo `json:"taskInfos,omitempty"`
}

func (v *GetDLQReplicationMessagesRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetTaskInfos is an internal getter (TBD...)
func (v *GetDLQReplicationMessagesRequest) GetTaskInfos() (o []*ReplicationTaskInfo) {
if v != nil && v.TaskInfos != nil {
Expand All @@ -249,6 +253,10 @@ type GetDomainReplicationMessagesRequest struct {
ClusterName string `json:"clusterName,omitempty"`
}

func (v *GetDomainReplicationMessagesRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetLastRetrievedMessageID is an internal getter (TBD...)
func (v *GetDomainReplicationMessagesRequest) GetLastRetrievedMessageID() (o int64) {
if v != nil && v.LastRetrievedMessageID != nil {
Expand Down Expand Up @@ -284,6 +292,10 @@ type GetReplicationMessagesRequest struct {
ClusterName string `json:"clusterName,omitempty"`
}

func (v *GetReplicationMessagesRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetClusterName is an internal getter (TBD...)
func (v *GetReplicationMessagesRequest) GetClusterName() (o string) {
if v != nil {
Expand Down Expand Up @@ -393,6 +405,10 @@ type MergeDLQMessagesRequest struct {
NextPageToken []byte `json:"nextPageToken,omitempty"`
}

func (v *MergeDLQMessagesRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetType is an internal getter (TBD...)
func (v *MergeDLQMessagesRequest) GetType() (o DLQType) {
if v != nil && v.Type != nil {
Expand Down Expand Up @@ -454,6 +470,10 @@ type PurgeDLQMessagesRequest struct {
InclusiveEndMessageID *int64 `json:"inclusiveEndMessageID,omitempty"`
}

func (v *PurgeDLQMessagesRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetType is an internal getter (TBD...)
func (v *PurgeDLQMessagesRequest) GetType() (o DLQType) {
if v != nil && v.Type != nil {
Expand Down Expand Up @@ -496,6 +516,10 @@ type ReadDLQMessagesRequest struct {
NextPageToken []byte `json:"nextPageToken,omitempty"`
}

func (v *ReadDLQMessagesRequest) SerializeForLogging() (string, error) {
return SerializeRequest(v)
}

// GetType is an internal getter (TBD...)
func (v *ReadDLQMessagesRequest) GetType() (o DLQType) {
if v != nil && v.Type != nil {
Expand Down
Loading