refactor (controller): Use a grpc server for the grpc-gateway (#1576)
* refactor (controller): Use a grpc server for the grpc-gateway This starts a grpc server for the grpc-gateway. The new gateway server uses an in-memory listener which also supports "dialing", so the http proxy can connect to the in-memory listener. This change allows us to use all grpc server features and was in part motivated by a need for an interceptor of inbound requests. With that said, having a "proper" grpc server for the gateway will provide a lot more flexibility and capabilities moving forward. The request context will still be verified via middleware in the http proxy (see wrapHandlerWithCommonFuncs). This verified context will be serialized into a protobuf and sent along to the grpc-gateway via metadata where an interceptor will add the verified request info to the request's context (see requestCtxInterceptor). The interceptor will verify the serialized request info via a shared ticket with it's companion in-memory http proxy. FYI: the ticket is simply random base62 string (see db.NewPrivateId). This change also necessitated a minor change to services. We need to return an empty response instead of nil, nil when there are no errors and the response is empty. * refactor (handlers): Rename gRPC Gateway filter Originally, this was called an OutgoingInterceptor, which is an unfortunate name since it's not an interceptor. Now that we're refactoring the gateway stuff and have proper interceptors, renaming this should remove ambiguity * refactor: Rework how 204 with empty msg is handled Recent changes to grpc gateway has necessitated a change to how 204s are handled by the gateway * tests (bats): Check status codes for delete operations
This commit is contained in:
50 files changed
+2625
-370
No files matched your search
@@ -0,0 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.api.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/gen/controller/api;api";
|
||||
|
||||
// EmptyResponse represents an empty response
|
||||
message EmptyResponse {}
|
||||
@@ -0,0 +1,42 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.auth.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/gen/controller/auth;auth";
|
||||
|
||||
// RequestInfo contains request parameters necessary for checking authn/authz
|
||||
message RequestInfo {
|
||||
// path of the request
|
||||
string path = 10;
|
||||
|
||||
// method (http verb) of the request
|
||||
string method = 20;
|
||||
|
||||
// public_id for the request
|
||||
string public_id = 30;
|
||||
|
||||
// encrypted_token from the request
|
||||
string encrypted_token = 40;
|
||||
|
||||
// token from the request
|
||||
string token = 50;
|
||||
|
||||
// token_format of the request's token
|
||||
uint32 token_format = 60;
|
||||
|
||||
// scope_id_override for the request (helpful for tests)
|
||||
string scope_id_override = 70;
|
||||
|
||||
// user_id_override for the request (helpful for tests)
|
||||
string user_id_override = 80;
|
||||
|
||||
// disable_authz_failures for the request (helpful for tests)
|
||||
bool disable_authz_failures = 90;
|
||||
|
||||
// disable_auth_entirely for the request (helpful for tests)
|
||||
bool disable_auth_entirely = 100;
|
||||
|
||||
// ticket is a unique id that allows the grpc-gateway to verify that the info
|
||||
// came from its companion http proxy
|
||||
string ticket = 110;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package errors.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/gen/errors;errors";
|
||||
|
||||
import "controller/api/v1/error.proto";
|
||||
|
||||
// Err is a protobuf representation of a domain error
|
||||
message Err {
|
||||
// code is the error's code, which can be used to get the error's
|
||||
// errorCodeInfo, which contains the error's Kind and Message
|
||||
uint32 code = 10;
|
||||
|
||||
// msg for the error
|
||||
string msg = 20;
|
||||
|
||||
// op represents the operation raising/propagating an error and is optional.
|
||||
string op = 30;
|
||||
|
||||
// wrapped represents an optionally wrapped error
|
||||
oneof wrapped {
|
||||
// err is a wrapped Err (aka a domain error)
|
||||
Err err = 40;
|
||||
|
||||
// std_error is a wrapped std error
|
||||
string std_error = 50;
|
||||
|
||||
// no error or err is wrapped
|
||||
bool none = 60;
|
||||
}
|
||||
}
|
||||
|
||||
// ApiError is a protobuf representation of a controller ApiError
|
||||
message ApiError {
|
||||
// api_error is the controller ApiError
|
||||
controller.api.v1.Error api_error = 10;
|
||||
|
||||
// status is the status code assocatiated with the api error
|
||||
int32 status = 20;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package testing.interceptor.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/gen/testing/interceptor;interceptor";
|
||||
|
||||
// The greeting service definition. This is just a dead simple service that can
|
||||
// be used to test interceptors. (See controller.startTestGreeterService)
|
||||
service GreeterService {
|
||||
// Sends a greeting
|
||||
rpc SayHello(SayHelloRequest) returns (SayHelloResponse) {}
|
||||
}
|
||||
|
||||
// The request message containing the user's name.
|
||||
message SayHelloRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
// The response message containing the greetings
|
||||
message SayHelloResponse {
|
||||
string message = 1;
|
||||
}
|
||||
Reference in new issue
Block a user