-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update proto for internal ingest
- Loading branch information
Showing
12 changed files
with
1,279 additions
and
996 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package grpc | ||
|
||
import ( | ||
"context" | ||
envoyAuth "github.com/envoyproxy/go-control-plane/envoy/service/auth/v3" | ||
"github.com/gogo/googleapis/google/rpc" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/metadata" | ||
"google.golang.org/grpc/status" | ||
"net/http" | ||
) | ||
|
||
func CheckGRPCAuth(ctx context.Context, authClient envoyAuth.AuthorizationClient) error { | ||
md, ok := metadata.FromIncomingContext(ctx) | ||
if !ok { | ||
return status.Errorf(codes.Unauthenticated, "missing metadata") | ||
} | ||
|
||
mdHeaders := make(map[string]string) | ||
for k, v := range md { | ||
if len(v) > 0 { | ||
mdHeaders[k] = v[0] | ||
} | ||
} | ||
|
||
result, err := authClient.Check(ctx, &envoyAuth.CheckRequest{ | ||
Attributes: &envoyAuth.AttributeContext{ | ||
Request: &envoyAuth.AttributeContext_Request{ | ||
Http: &envoyAuth.AttributeContext_HttpRequest{ | ||
Headers: mdHeaders, | ||
}, | ||
}, | ||
}, | ||
}) | ||
if err != nil { | ||
return status.Errorf(codes.Unauthenticated, "authentication failed: %v", err) | ||
} | ||
|
||
if result.GetStatus() == nil || result.GetStatus().GetCode() != int32(rpc.OK) { | ||
return status.Errorf(codes.Unauthenticated, http.StatusText(http.StatusUnauthorized)) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
syntax = "proto3"; | ||
|
||
package kaytu.entity.v1; | ||
|
||
option go_package="github.com/kaytu-io/kaytu-util/proto/src/golang"; | ||
|
||
message DescribeJob { | ||
uint32 job_id = 1; | ||
uint32 schedule_job_id = 2; | ||
uint32 parent_job_id = 3; | ||
string resource_type = 4; | ||
string source_id = 5; | ||
string account_id = 6; | ||
int64 described_at = 7; | ||
string source_type = 8; | ||
string config_reg = 9; | ||
string trigger_type = 10; | ||
uint32 retry_counter = 11; | ||
} | ||
|
||
message ResponseOK { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
syntax = "proto3"; | ||
|
||
package kaytu.es_sink.v1; | ||
|
||
option go_package="github.com/kaytu-io/kaytu-util/proto/src/golang"; | ||
|
||
import "entity.proto"; | ||
|
||
message AWSResources { | ||
repeated AWSResource resources = 1; | ||
} | ||
|
||
message AWSResource { | ||
string arn = 1; | ||
string id = 2; | ||
string name = 3; | ||
string account = 4; | ||
string region = 5; | ||
string partition = 6; | ||
string type = 7; | ||
string description_json = 8; | ||
kaytu.entity.v1.DescribeJob job = 9; | ||
string unique_id = 10; | ||
map<string,string> metadata = 11; | ||
map<string,string> tags = 12; | ||
} | ||
|
||
message AzureResources { | ||
repeated AzureResource resources = 1; | ||
} | ||
message AzureResource { | ||
string id = 1; | ||
string name = 2; | ||
string type = 3; | ||
string resource_group = 4; | ||
string location = 5; | ||
string subscription_id = 6; | ||
string description_json = 7; | ||
kaytu.entity.v1.DescribeJob job = 8; | ||
string unique_id = 9; | ||
map<string,string> metadata = 10; | ||
map<string,string> tags = 11; | ||
} | ||
|
||
service DescribeService { | ||
rpc DeliverAWSResources(AWSResources) returns (kaytu.entity.v1.ResponseOK) {} | ||
rpc DeliverAzureResources(AzureResources) returns (kaytu.entity.v1.ResponseOK) {} | ||
} |
Oops, something went wrong.