From dd8973dd9f233660765408bd9da9f6e2a83e8dd7 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 12 Oct 2020 18:03:15 -0400 Subject: [PATCH] Move authenticate service into auth method service (#635) This was always an RPC-only distinction and from that perspective it makes sense; however it causes the generated docs to treat it as an entirely separate service even though it's under the same collection path as auth methods and this is confusing. --- internal/gen/controller.swagger.json | 10 +- .../api/services/auth_method_service.pb.go | 565 +++++++++++++----- .../api/services/auth_method_service.pb.gw.go | 124 ++++ .../services/auth_method_service_grpc.pb.go | 38 ++ .../api/services/authenticate_service.pb.go | 370 ------------ .../services/authenticate_service.pb.gw.go | 210 ------- .../services/authenticate_service_grpc.pb.go | 88 --- .../api/services/v1/auth_method_service.proto | 34 ++ .../services/v1/authenticate_service.proto | 52 -- internal/servers/controller/handler.go | 10 +- .../authenticate/authenticate_service.go | 204 ------- .../authenticate/authenticate_service_test.go | 234 -------- .../authmethods/authmethod_service.go | 160 ++++- .../authmethods/authmethod_service_test.go | 269 ++++++++- 14 files changed, 1019 insertions(+), 1349 deletions(-) delete mode 100644 internal/gen/controller/api/services/authenticate_service.pb.go delete mode 100644 internal/gen/controller/api/services/authenticate_service.pb.gw.go delete mode 100644 internal/gen/controller/api/services/authenticate_service_grpc.pb.go delete mode 100644 internal/proto/local/controller/api/services/v1/authenticate_service.proto delete mode 100644 internal/servers/controller/handlers/authenticate/authenticate_service.go delete mode 100644 internal/servers/controller/handlers/authenticate/authenticate_service_test.go diff --git a/internal/gen/controller.swagger.json b/internal/gen/controller.swagger.json index b00c05663..96cae9c8b 100644 --- a/internal/gen/controller.swagger.json +++ b/internal/gen/controller.swagger.json @@ -1,13 +1,9 @@ { "swagger": "2.0", "info": { - "title": "Controller API", + "title": "controller/api/services/v1/account_service.proto", "version": "version not set" }, - "schemes": [ - "https", - "http" - ], "consumes": [ "application/json" ], @@ -273,7 +269,7 @@ "/v1/auth-methods/{auth_method_id}:authenticate": { "post": { "summary": "Authenticate a user to an scope and retrieve an authentication token.", - "operationId": "AuthenticationService_Authenticate", + "operationId": "AuthMethodService_Authenticate", "responses": { "200": { "description": "", @@ -300,7 +296,7 @@ } ], "tags": [ - "controller.api.services.v1.AuthenticationService" + "controller.api.services.v1.AuthMethodService" ] } }, diff --git a/internal/gen/controller/api/services/auth_method_service.pb.go b/internal/gen/controller/api/services/auth_method_service.pb.go index d08bcfc94..d5445ed40 100644 --- a/internal/gen/controller/api/services/auth_method_service.pb.go +++ b/internal/gen/controller/api/services/auth_method_service.pb.go @@ -8,8 +8,10 @@ package services import ( proto "github.com/golang/protobuf/proto" + _struct "github.com/golang/protobuf/ptypes/struct" _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" authmethods "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods" + authtokens "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authtokens" _ "google.golang.org/genproto/googleapis/api/annotations" field_mask "google.golang.org/genproto/protobuf/field_mask" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -514,6 +516,183 @@ func (*DeleteAuthMethodResponse) Descriptor() ([]byte, []int) { return file_controller_api_services_v1_auth_method_service_proto_rawDescGZIP(), []int{9} } +// The layout of the struct for "credentials" field in AuthenticateRequest. This message isn't directly referenced anywhere but is used here to define the expected field names and types. +type PasswordCredentials struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LoginName string `protobuf:"bytes,1,opt,name=login_name,proto3" json:"login_name,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *PasswordCredentials) Reset() { + *x = PasswordCredentials{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_auth_method_service_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PasswordCredentials) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PasswordCredentials) ProtoMessage() {} + +func (x *PasswordCredentials) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_auth_method_service_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PasswordCredentials.ProtoReflect.Descriptor instead. +func (*PasswordCredentials) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_auth_method_service_proto_rawDescGZIP(), []int{10} +} + +func (x *PasswordCredentials) GetLoginName() string { + if x != nil { + return x.LoginName + } + return "" +} + +func (x *PasswordCredentials) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type AuthenticateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The ID of the Auth Method in the system that should be used for authentication. + AuthMethodId string `protobuf:"bytes,1,opt,name=auth_method_id,proto3" json:"auth_method_id,omitempty"` + // This can be "cookie" or "token". If not provided, "token" will be used. "cookie" activates a split-cookie method where the token is split partially between http-only and regular cookies in order to keep it safe from rogue JS in the browser. + TokenType string `protobuf:"bytes,2,opt,name=token_type,proto3" json:"token_type,omitempty"` + // Credentials are passed to the Auth Method; the valid keys and values depend on the type of Auth Method. + Credentials *_struct.Struct `protobuf:"bytes,3,opt,name=credentials,proto3" json:"credentials,omitempty"` +} + +func (x *AuthenticateRequest) Reset() { + *x = AuthenticateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_auth_method_service_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AuthenticateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthenticateRequest) ProtoMessage() {} + +func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_auth_method_service_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AuthenticateRequest.ProtoReflect.Descriptor instead. +func (*AuthenticateRequest) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_auth_method_service_proto_rawDescGZIP(), []int{11} +} + +func (x *AuthenticateRequest) GetAuthMethodId() string { + if x != nil { + return x.AuthMethodId + } + return "" +} + +func (x *AuthenticateRequest) GetTokenType() string { + if x != nil { + return x.TokenType + } + return "" +} + +func (x *AuthenticateRequest) GetCredentials() *_struct.Struct { + if x != nil { + return x.Credentials + } + return nil +} + +type AuthenticateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Item *authtokens.AuthToken `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` + TokenType string `protobuf:"bytes,2,opt,name=token_type,proto3" json:"token_type,omitempty"` +} + +func (x *AuthenticateResponse) Reset() { + *x = AuthenticateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_auth_method_service_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AuthenticateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthenticateResponse) ProtoMessage() {} + +func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_auth_method_service_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AuthenticateResponse.ProtoReflect.Descriptor instead. +func (*AuthenticateResponse) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_auth_method_service_proto_rawDescGZIP(), []int{12} +} + +func (x *AuthenticateResponse) GetItem() *authtokens.AuthToken { + if x != nil { + return x.Item + } + return nil +} + +func (x *AuthenticateResponse) GetTokenType() string { + if x != nil { + return x.TokenType + } + return "" +} + var File_controller_api_services_v1_auth_method_service_proto protoreflect.FileDescriptor var file_controller_api_services_v1_auth_method_service_proto_rawDesc = []byte{ @@ -529,130 +708,175 @@ var file_controller_api_services_v1_auth_method_service_proto_rawDesc = []byte{ 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x39, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x61, 0x75, 0x74, - 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, - 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x26, 0x0a, - 0x14, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x60, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, - 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, - 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x34, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x41, - 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x22, 0x64, 0x0a, - 0x17, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2e, 0x76, - 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x05, 0x69, 0x74, - 0x65, 0x6d, 0x73, 0x22, 0x62, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, - 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x47, - 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x75, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x47, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, - 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, - 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0xb0, - 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x04, 0x69, 0x74, - 0x65, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x04, 0x69, - 0x74, 0x65, 0x6d, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, - 0x73, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, - 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, - 0x6b, 0x22, 0x63, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, - 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x29, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x22, 0x1a, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xc9, 0x07, - 0x0a, 0x11, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0xb8, 0x01, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x42, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x1d, 0x12, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, - 0x41, 0x1c, 0x12, 0x1a, 0x47, 0x65, 0x74, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c, - 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, 0x20, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, 0x12, 0xb0, - 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x73, 0x12, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x34, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x73, 0x92, 0x41, 0x19, 0x12, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x73, 0x20, - 0x61, 0x6c, 0x6c, 0x20, 0x41, 0x75, 0x74, 0x68, 0x20, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, - 0x2e, 0x12, 0xc5, 0x01, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, - 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, - 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x46, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x22, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x61, - 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x3a, 0x04, 0x69, 0x74, 0x65, - 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x1f, 0x12, 0x1d, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x41, 0x75, 0x74, - 0x68, 0x20, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, 0x12, 0xc4, 0x01, 0x0a, 0x10, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x33, + 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x39, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x36, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, + 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x26, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x60, 0x0a, 0x15, 0x47, + 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, + 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, + 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x34, 0x0a, + 0x16, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, + 0x5f, 0x69, 0x64, 0x22, 0x64, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, + 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x62, 0x0a, 0x17, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x47, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, + 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, + 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x75, 0x0a, + 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x47, 0x0a, 0x04, 0x69, + 0x74, 0x65, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, + 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x04, + 0x69, 0x74, 0x65, 0x6d, 0x22, 0xb0, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, + 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x47, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, - 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x45, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x23, 0x32, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, - 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x19, 0x12, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, - 0x20, 0x61, 0x6e, 0x20, 0x41, 0x75, 0x74, 0x68, 0x20, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, - 0x12, 0xb6, 0x01, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x63, 0x6f, 0x6e, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x22, 0x63, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, + 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, + 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x29, 0x0a, 0x17, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x1a, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x51, 0x0a, 0x13, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x43, + 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x6c, 0x6f, + 0x67, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x98, 0x01, 0x0a, 0x13, 0x41, 0x75, 0x74, 0x68, 0x65, + 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, + 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, + 0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, + 0x73, 0x22, 0x7d, 0x0a, 0x14, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x04, 0x69, 0x74, 0x65, + 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x41, 0x75, 0x74, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, + 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x32, 0xc9, 0x09, 0x0a, 0x11, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xb8, 0x01, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x41, 0x75, + 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x75, - 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x2a, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, - 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x92, - 0x41, 0x17, 0x12, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x41, - 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, - 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x42, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x12, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, + 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x62, 0x04, 0x69, 0x74, + 0x65, 0x6d, 0x92, 0x41, 0x1c, 0x12, 0x1a, 0x47, 0x65, 0x74, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, + 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x41, 0x75, 0x74, 0x68, 0x20, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x2e, 0x12, 0xb0, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x73, 0x12, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x4d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x34, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, + 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x92, 0x41, 0x19, 0x12, 0x17, 0x4c, 0x69, 0x73, + 0x74, 0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x41, 0x75, 0x74, 0x68, 0x20, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x73, 0x2e, 0x12, 0xc5, 0x01, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, + 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, + 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, + 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x46, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x22, 0x10, 0x2f, 0x76, + 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x3a, 0x04, + 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x1f, 0x12, 0x1d, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, + 0x41, 0x75, 0x74, 0x68, 0x20, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, 0x12, 0xc4, 0x01, 0x0a, + 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x12, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, + 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x45, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x23, 0x32, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x04, 0x69, 0x74, 0x65, + 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x19, 0x12, 0x17, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x41, 0x75, 0x74, 0x68, 0x20, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x2e, 0x12, 0xb6, 0x01, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x75, + 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x33, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, + 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x2a, 0x15, 0x2f, 0x76, 0x31, + 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x69, + 0x64, 0x7d, 0x92, 0x41, 0x17, 0x12, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x73, 0x20, 0x61, + 0x6e, 0x20, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0xfd, 0x01, 0x0a, + 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x2f, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x65, + 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, + 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, + 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x89, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x39, 0x22, 0x2e, 0x2f, 0x76, 0x31, 0x2f, 0x61, + 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x61, 0x75, 0x74, + 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x3a, 0x61, 0x75, 0x74, + 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, + 0x65, 0x6d, 0x92, 0x41, 0x47, 0x12, 0x45, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, + 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x6e, + 0x20, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, + 0x65, 0x76, 0x65, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x42, 0x4d, 0x5a, 0x4b, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, + 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -667,7 +891,7 @@ func file_controller_api_services_v1_auth_method_service_proto_rawDescGZIP() []b return file_controller_api_services_v1_auth_method_service_proto_rawDescData } -var file_controller_api_services_v1_auth_method_service_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_controller_api_services_v1_auth_method_service_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_controller_api_services_v1_auth_method_service_proto_goTypes = []interface{}{ (*GetAuthMethodRequest)(nil), // 0: controller.api.services.v1.GetAuthMethodRequest (*GetAuthMethodResponse)(nil), // 1: controller.api.services.v1.GetAuthMethodResponse @@ -679,32 +903,41 @@ var file_controller_api_services_v1_auth_method_service_proto_goTypes = []interf (*UpdateAuthMethodResponse)(nil), // 7: controller.api.services.v1.UpdateAuthMethodResponse (*DeleteAuthMethodRequest)(nil), // 8: controller.api.services.v1.DeleteAuthMethodRequest (*DeleteAuthMethodResponse)(nil), // 9: controller.api.services.v1.DeleteAuthMethodResponse - (*authmethods.AuthMethod)(nil), // 10: controller.api.resources.authmethods.v1.AuthMethod - (*field_mask.FieldMask)(nil), // 11: google.protobuf.FieldMask + (*PasswordCredentials)(nil), // 10: controller.api.services.v1.PasswordCredentials + (*AuthenticateRequest)(nil), // 11: controller.api.services.v1.AuthenticateRequest + (*AuthenticateResponse)(nil), // 12: controller.api.services.v1.AuthenticateResponse + (*authmethods.AuthMethod)(nil), // 13: controller.api.resources.authmethods.v1.AuthMethod + (*field_mask.FieldMask)(nil), // 14: google.protobuf.FieldMask + (*_struct.Struct)(nil), // 15: google.protobuf.Struct + (*authtokens.AuthToken)(nil), // 16: controller.api.resources.authtokens.v1.AuthToken } var file_controller_api_services_v1_auth_method_service_proto_depIdxs = []int32{ - 10, // 0: controller.api.services.v1.GetAuthMethodResponse.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod - 10, // 1: controller.api.services.v1.ListAuthMethodsResponse.items:type_name -> controller.api.resources.authmethods.v1.AuthMethod - 10, // 2: controller.api.services.v1.CreateAuthMethodRequest.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod - 10, // 3: controller.api.services.v1.CreateAuthMethodResponse.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod - 10, // 4: controller.api.services.v1.UpdateAuthMethodRequest.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod - 11, // 5: controller.api.services.v1.UpdateAuthMethodRequest.update_mask:type_name -> google.protobuf.FieldMask - 10, // 6: controller.api.services.v1.UpdateAuthMethodResponse.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod - 0, // 7: controller.api.services.v1.AuthMethodService.GetAuthMethod:input_type -> controller.api.services.v1.GetAuthMethodRequest - 2, // 8: controller.api.services.v1.AuthMethodService.ListAuthMethods:input_type -> controller.api.services.v1.ListAuthMethodsRequest - 4, // 9: controller.api.services.v1.AuthMethodService.CreateAuthMethod:input_type -> controller.api.services.v1.CreateAuthMethodRequest - 6, // 10: controller.api.services.v1.AuthMethodService.UpdateAuthMethod:input_type -> controller.api.services.v1.UpdateAuthMethodRequest - 8, // 11: controller.api.services.v1.AuthMethodService.DeleteAuthMethod:input_type -> controller.api.services.v1.DeleteAuthMethodRequest - 1, // 12: controller.api.services.v1.AuthMethodService.GetAuthMethod:output_type -> controller.api.services.v1.GetAuthMethodResponse - 3, // 13: controller.api.services.v1.AuthMethodService.ListAuthMethods:output_type -> controller.api.services.v1.ListAuthMethodsResponse - 5, // 14: controller.api.services.v1.AuthMethodService.CreateAuthMethod:output_type -> controller.api.services.v1.CreateAuthMethodResponse - 7, // 15: controller.api.services.v1.AuthMethodService.UpdateAuthMethod:output_type -> controller.api.services.v1.UpdateAuthMethodResponse - 9, // 16: controller.api.services.v1.AuthMethodService.DeleteAuthMethod:output_type -> controller.api.services.v1.DeleteAuthMethodResponse - 12, // [12:17] is the sub-list for method output_type - 7, // [7:12] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 13, // 0: controller.api.services.v1.GetAuthMethodResponse.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod + 13, // 1: controller.api.services.v1.ListAuthMethodsResponse.items:type_name -> controller.api.resources.authmethods.v1.AuthMethod + 13, // 2: controller.api.services.v1.CreateAuthMethodRequest.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod + 13, // 3: controller.api.services.v1.CreateAuthMethodResponse.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod + 13, // 4: controller.api.services.v1.UpdateAuthMethodRequest.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod + 14, // 5: controller.api.services.v1.UpdateAuthMethodRequest.update_mask:type_name -> google.protobuf.FieldMask + 13, // 6: controller.api.services.v1.UpdateAuthMethodResponse.item:type_name -> controller.api.resources.authmethods.v1.AuthMethod + 15, // 7: controller.api.services.v1.AuthenticateRequest.credentials:type_name -> google.protobuf.Struct + 16, // 8: controller.api.services.v1.AuthenticateResponse.item:type_name -> controller.api.resources.authtokens.v1.AuthToken + 0, // 9: controller.api.services.v1.AuthMethodService.GetAuthMethod:input_type -> controller.api.services.v1.GetAuthMethodRequest + 2, // 10: controller.api.services.v1.AuthMethodService.ListAuthMethods:input_type -> controller.api.services.v1.ListAuthMethodsRequest + 4, // 11: controller.api.services.v1.AuthMethodService.CreateAuthMethod:input_type -> controller.api.services.v1.CreateAuthMethodRequest + 6, // 12: controller.api.services.v1.AuthMethodService.UpdateAuthMethod:input_type -> controller.api.services.v1.UpdateAuthMethodRequest + 8, // 13: controller.api.services.v1.AuthMethodService.DeleteAuthMethod:input_type -> controller.api.services.v1.DeleteAuthMethodRequest + 11, // 14: controller.api.services.v1.AuthMethodService.Authenticate:input_type -> controller.api.services.v1.AuthenticateRequest + 1, // 15: controller.api.services.v1.AuthMethodService.GetAuthMethod:output_type -> controller.api.services.v1.GetAuthMethodResponse + 3, // 16: controller.api.services.v1.AuthMethodService.ListAuthMethods:output_type -> controller.api.services.v1.ListAuthMethodsResponse + 5, // 17: controller.api.services.v1.AuthMethodService.CreateAuthMethod:output_type -> controller.api.services.v1.CreateAuthMethodResponse + 7, // 18: controller.api.services.v1.AuthMethodService.UpdateAuthMethod:output_type -> controller.api.services.v1.UpdateAuthMethodResponse + 9, // 19: controller.api.services.v1.AuthMethodService.DeleteAuthMethod:output_type -> controller.api.services.v1.DeleteAuthMethodResponse + 12, // 20: controller.api.services.v1.AuthMethodService.Authenticate:output_type -> controller.api.services.v1.AuthenticateResponse + 15, // [15:21] is the sub-list for method output_type + 9, // [9:15] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_controller_api_services_v1_auth_method_service_proto_init() } @@ -833,6 +1066,42 @@ func file_controller_api_services_v1_auth_method_service_proto_init() { return nil } } + file_controller_api_services_v1_auth_method_service_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PasswordCredentials); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_auth_method_service_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AuthenticateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_auth_method_service_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AuthenticateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -840,7 +1109,7 @@ func file_controller_api_services_v1_auth_method_service_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_controller_api_services_v1_auth_method_service_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 13, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/gen/controller/api/services/auth_method_service.pb.gw.go b/internal/gen/controller/api/services/auth_method_service.pb.gw.go index d277a8740..7a541376c 100644 --- a/internal/gen/controller/api/services/auth_method_service.pb.gw.go +++ b/internal/gen/controller/api/services/auth_method_service.pb.gw.go @@ -305,6 +305,74 @@ func local_request_AuthMethodService_DeleteAuthMethod_0(ctx context.Context, mar } +func request_AuthMethodService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, client AuthMethodServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq AuthenticateRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["auth_method_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auth_method_id") + } + + protoReq.AuthMethodId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) + } + + msg, err := client.Authenticate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_AuthMethodService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, server AuthMethodServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq AuthenticateRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["auth_method_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auth_method_id") + } + + protoReq.AuthMethodId, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) + } + + msg, err := server.Authenticate(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterAuthMethodServiceHandlerServer registers the http handlers for service AuthMethodService to "mux". // UnaryRPC :call AuthMethodServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -426,6 +494,29 @@ func RegisterAuthMethodServiceHandlerServer(ctx context.Context, mux *runtime.Se }) + mux.Handle("POST", pattern_AuthMethodService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.AuthMethodService/Authenticate") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_AuthMethodService_Authenticate_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_AuthMethodService_Authenticate_0(ctx, mux, outboundMarshaler, w, req, response_AuthMethodService_Authenticate_0{resp}, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -567,6 +658,26 @@ func RegisterAuthMethodServiceHandlerClient(ctx context.Context, mux *runtime.Se }) + mux.Handle("POST", pattern_AuthMethodService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.AuthMethodService/Authenticate") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_AuthMethodService_Authenticate_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_AuthMethodService_Authenticate_0(ctx, mux, outboundMarshaler, w, req, response_AuthMethodService_Authenticate_0{resp}, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -597,6 +708,15 @@ func (m response_AuthMethodService_UpdateAuthMethod_0) XXX_ResponseBody() interf return response.Item } +type response_AuthMethodService_Authenticate_0 struct { + proto.Message +} + +func (m response_AuthMethodService_Authenticate_0) XXX_ResponseBody() interface{} { + response := m.Message.(*AuthenticateResponse) + return response.Item +} + var ( pattern_AuthMethodService_GetAuthMethod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "auth-methods", "id"}, "")) @@ -607,6 +727,8 @@ var ( pattern_AuthMethodService_UpdateAuthMethod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "auth-methods", "id"}, "")) pattern_AuthMethodService_DeleteAuthMethod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "auth-methods", "id"}, "")) + + pattern_AuthMethodService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "auth-methods", "auth_method_id"}, "authenticate")) ) var ( @@ -619,4 +741,6 @@ var ( forward_AuthMethodService_UpdateAuthMethod_0 = runtime.ForwardResponseMessage forward_AuthMethodService_DeleteAuthMethod_0 = runtime.ForwardResponseMessage + + forward_AuthMethodService_Authenticate_0 = runtime.ForwardResponseMessage ) diff --git a/internal/gen/controller/api/services/auth_method_service_grpc.pb.go b/internal/gen/controller/api/services/auth_method_service_grpc.pb.go index f9b298f61..5bfcfc678 100644 --- a/internal/gen/controller/api/services/auth_method_service_grpc.pb.go +++ b/internal/gen/controller/api/services/auth_method_service_grpc.pb.go @@ -43,6 +43,8 @@ type AuthMethodServiceClient interface { // DeleteAuthMethod removes an Auth Method from Boundary. If the Auth Method id // is malformed or not provided an error is returned. DeleteAuthMethod(ctx context.Context, in *DeleteAuthMethodRequest, opts ...grpc.CallOption) (*DeleteAuthMethodResponse, error) + // Authenticate validates credentials provided and returns an Auth Token. + Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) } type authMethodServiceClient struct { @@ -98,6 +100,15 @@ func (c *authMethodServiceClient) DeleteAuthMethod(ctx context.Context, in *Dele return out, nil } +func (c *authMethodServiceClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) { + out := new(AuthenticateResponse) + err := c.cc.Invoke(ctx, "/controller.api.services.v1.AuthMethodService/Authenticate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // AuthMethodServiceServer is the server API for AuthMethodService service. type AuthMethodServiceServer interface { // GetAuthMethod returns a stored Auth Method if present. The provided request @@ -126,6 +137,8 @@ type AuthMethodServiceServer interface { // DeleteAuthMethod removes an Auth Method from Boundary. If the Auth Method id // is malformed or not provided an error is returned. DeleteAuthMethod(context.Context, *DeleteAuthMethodRequest) (*DeleteAuthMethodResponse, error) + // Authenticate validates credentials provided and returns an Auth Token. + Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) } // UnimplementedAuthMethodServiceServer can be embedded to have forward compatible implementations. @@ -147,6 +160,9 @@ func (*UnimplementedAuthMethodServiceServer) UpdateAuthMethod(context.Context, * func (*UnimplementedAuthMethodServiceServer) DeleteAuthMethod(context.Context, *DeleteAuthMethodRequest) (*DeleteAuthMethodResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteAuthMethod not implemented") } +func (*UnimplementedAuthMethodServiceServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") +} func RegisterAuthMethodServiceServer(s *grpc.Server, srv AuthMethodServiceServer) { s.RegisterService(&_AuthMethodService_serviceDesc, srv) @@ -242,6 +258,24 @@ func _AuthMethodService_DeleteAuthMethod_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } +func _AuthMethodService_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AuthenticateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthMethodServiceServer).Authenticate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/controller.api.services.v1.AuthMethodService/Authenticate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthMethodServiceServer).Authenticate(ctx, req.(*AuthenticateRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _AuthMethodService_serviceDesc = grpc.ServiceDesc{ ServiceName: "controller.api.services.v1.AuthMethodService", HandlerType: (*AuthMethodServiceServer)(nil), @@ -266,6 +300,10 @@ var _AuthMethodService_serviceDesc = grpc.ServiceDesc{ MethodName: "DeleteAuthMethod", Handler: _AuthMethodService_DeleteAuthMethod_Handler, }, + { + MethodName: "Authenticate", + Handler: _AuthMethodService_Authenticate_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "controller/api/services/v1/auth_method_service.proto", diff --git a/internal/gen/controller/api/services/authenticate_service.pb.go b/internal/gen/controller/api/services/authenticate_service.pb.go deleted file mode 100644 index 41202cb58..000000000 --- a/internal/gen/controller/api/services/authenticate_service.pb.go +++ /dev/null @@ -1,370 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.12.4 -// source: controller/api/services/v1/authenticate_service.proto - -package services - -import ( - proto "github.com/golang/protobuf/proto" - _struct "github.com/golang/protobuf/ptypes/struct" - _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" - authtokens "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authtokens" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -// The layout of the struct for "credentials" field in AuthenticateRequest. This message isn't directly referenced anywhere but is used here to define the expected field names and types. -type PasswordCredentials struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - LoginName string `protobuf:"bytes,1,opt,name=login_name,proto3" json:"login_name,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` -} - -func (x *PasswordCredentials) Reset() { - *x = PasswordCredentials{} - if protoimpl.UnsafeEnabled { - mi := &file_controller_api_services_v1_authenticate_service_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PasswordCredentials) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PasswordCredentials) ProtoMessage() {} - -func (x *PasswordCredentials) ProtoReflect() protoreflect.Message { - mi := &file_controller_api_services_v1_authenticate_service_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PasswordCredentials.ProtoReflect.Descriptor instead. -func (*PasswordCredentials) Descriptor() ([]byte, []int) { - return file_controller_api_services_v1_authenticate_service_proto_rawDescGZIP(), []int{0} -} - -func (x *PasswordCredentials) GetLoginName() string { - if x != nil { - return x.LoginName - } - return "" -} - -func (x *PasswordCredentials) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -type AuthenticateRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ID of the Auth Method in the system that should be used for authentication. - AuthMethodId string `protobuf:"bytes,1,opt,name=auth_method_id,proto3" json:"auth_method_id,omitempty"` - // This can be "cookie" or "token". If not provided, "token" will be used. "cookie" activates a split-cookie method where the token is split partially between http-only and regular cookies in order to keep it safe from rogue JS in the browser. - TokenType string `protobuf:"bytes,2,opt,name=token_type,proto3" json:"token_type,omitempty"` - // Credentials are passed to the Auth Method; the valid keys and values depend on the type of Auth Method. - Credentials *_struct.Struct `protobuf:"bytes,3,opt,name=credentials,proto3" json:"credentials,omitempty"` -} - -func (x *AuthenticateRequest) Reset() { - *x = AuthenticateRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_controller_api_services_v1_authenticate_service_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AuthenticateRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthenticateRequest) ProtoMessage() {} - -func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { - mi := &file_controller_api_services_v1_authenticate_service_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AuthenticateRequest.ProtoReflect.Descriptor instead. -func (*AuthenticateRequest) Descriptor() ([]byte, []int) { - return file_controller_api_services_v1_authenticate_service_proto_rawDescGZIP(), []int{1} -} - -func (x *AuthenticateRequest) GetAuthMethodId() string { - if x != nil { - return x.AuthMethodId - } - return "" -} - -func (x *AuthenticateRequest) GetTokenType() string { - if x != nil { - return x.TokenType - } - return "" -} - -func (x *AuthenticateRequest) GetCredentials() *_struct.Struct { - if x != nil { - return x.Credentials - } - return nil -} - -type AuthenticateResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Item *authtokens.AuthToken `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` - TokenType string `protobuf:"bytes,2,opt,name=token_type,proto3" json:"token_type,omitempty"` -} - -func (x *AuthenticateResponse) Reset() { - *x = AuthenticateResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_controller_api_services_v1_authenticate_service_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AuthenticateResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthenticateResponse) ProtoMessage() {} - -func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { - mi := &file_controller_api_services_v1_authenticate_service_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AuthenticateResponse.ProtoReflect.Descriptor instead. -func (*AuthenticateResponse) Descriptor() ([]byte, []int) { - return file_controller_api_services_v1_authenticate_service_proto_rawDescGZIP(), []int{2} -} - -func (x *AuthenticateResponse) GetItem() *authtokens.AuthToken { - if x != nil { - return x.Item - } - return nil -} - -func (x *AuthenticateResponse) GetTokenType() string { - if x != nil { - return x.TokenType - } - return "" -} - -var File_controller_api_services_v1_authenticate_service_proto protoreflect.FileDescriptor - -var file_controller_api_services_v1_authenticate_service_proto_rawDesc = []byte{ - 0x0a, 0x35, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, - 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x76, 0x31, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, - 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x36, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x51, 0x0a, 0x13, 0x50, 0x61, 0x73, 0x73, 0x77, - 0x6f, 0x72, 0x64, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x1e, - 0x0a, 0x0a, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x98, 0x01, 0x0a, 0x13, 0x41, - 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, 0x75, 0x74, 0x68, - 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x63, 0x72, - 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x61, 0x6c, 0x73, 0x22, 0x7d, 0x0a, 0x14, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, - 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, - 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x04, - 0x69, 0x74, 0x65, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, - 0x74, 0x79, 0x70, 0x65, 0x32, 0x97, 0x02, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xfd, - 0x01, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, - 0x2f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, - 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, - 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x89, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x39, 0x22, 0x2e, 0x2f, 0x76, 0x31, - 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x61, - 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x3a, 0x61, - 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x3a, 0x01, 0x2a, 0x62, 0x04, - 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x47, 0x12, 0x45, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, - 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, - 0x61, 0x6e, 0x20, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x65, 0x74, - 0x72, 0x69, 0x65, 0x76, 0x65, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x42, 0x66, - 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, - 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x92, 0x41, 0x16, - 0x12, 0x10, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x20, 0x41, - 0x50, 0x49, 0x2a, 0x02, 0x02, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_controller_api_services_v1_authenticate_service_proto_rawDescOnce sync.Once - file_controller_api_services_v1_authenticate_service_proto_rawDescData = file_controller_api_services_v1_authenticate_service_proto_rawDesc -) - -func file_controller_api_services_v1_authenticate_service_proto_rawDescGZIP() []byte { - file_controller_api_services_v1_authenticate_service_proto_rawDescOnce.Do(func() { - file_controller_api_services_v1_authenticate_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_api_services_v1_authenticate_service_proto_rawDescData) - }) - return file_controller_api_services_v1_authenticate_service_proto_rawDescData -} - -var file_controller_api_services_v1_authenticate_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_controller_api_services_v1_authenticate_service_proto_goTypes = []interface{}{ - (*PasswordCredentials)(nil), // 0: controller.api.services.v1.PasswordCredentials - (*AuthenticateRequest)(nil), // 1: controller.api.services.v1.AuthenticateRequest - (*AuthenticateResponse)(nil), // 2: controller.api.services.v1.AuthenticateResponse - (*_struct.Struct)(nil), // 3: google.protobuf.Struct - (*authtokens.AuthToken)(nil), // 4: controller.api.resources.authtokens.v1.AuthToken -} -var file_controller_api_services_v1_authenticate_service_proto_depIdxs = []int32{ - 3, // 0: controller.api.services.v1.AuthenticateRequest.credentials:type_name -> google.protobuf.Struct - 4, // 1: controller.api.services.v1.AuthenticateResponse.item:type_name -> controller.api.resources.authtokens.v1.AuthToken - 1, // 2: controller.api.services.v1.AuthenticationService.Authenticate:input_type -> controller.api.services.v1.AuthenticateRequest - 2, // 3: controller.api.services.v1.AuthenticationService.Authenticate:output_type -> controller.api.services.v1.AuthenticateResponse - 3, // [3:4] is the sub-list for method output_type - 2, // [2:3] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_controller_api_services_v1_authenticate_service_proto_init() } -func file_controller_api_services_v1_authenticate_service_proto_init() { - if File_controller_api_services_v1_authenticate_service_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_controller_api_services_v1_authenticate_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PasswordCredentials); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_controller_api_services_v1_authenticate_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthenticateRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_controller_api_services_v1_authenticate_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthenticateResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_controller_api_services_v1_authenticate_service_proto_rawDesc, - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_controller_api_services_v1_authenticate_service_proto_goTypes, - DependencyIndexes: file_controller_api_services_v1_authenticate_service_proto_depIdxs, - MessageInfos: file_controller_api_services_v1_authenticate_service_proto_msgTypes, - }.Build() - File_controller_api_services_v1_authenticate_service_proto = out.File - file_controller_api_services_v1_authenticate_service_proto_rawDesc = nil - file_controller_api_services_v1_authenticate_service_proto_goTypes = nil - file_controller_api_services_v1_authenticate_service_proto_depIdxs = nil -} diff --git a/internal/gen/controller/api/services/authenticate_service.pb.gw.go b/internal/gen/controller/api/services/authenticate_service.pb.gw.go deleted file mode 100644 index 43ea2c780..000000000 --- a/internal/gen/controller/api/services/authenticate_service.pb.gw.go +++ /dev/null @@ -1,210 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: controller/api/services/v1/authenticate_service.proto - -/* -Package services is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package services - -import ( - "context" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = metadata.Join - -func request_AuthenticationService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, client AuthenticationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq AuthenticateRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["auth_method_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auth_method_id") - } - - protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) - } - - msg, err := client.Authenticate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_AuthenticationService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, server AuthenticationServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq AuthenticateRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["auth_method_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auth_method_id") - } - - protoReq.AuthMethodId, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err) - } - - msg, err := server.Authenticate(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterAuthenticationServiceHandlerServer registers the http handlers for service AuthenticationService to "mux". -// UnaryRPC :call AuthenticationServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthenticationServiceHandlerFromEndpoint instead. -func RegisterAuthenticationServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthenticationServiceServer) error { - - mux.Handle("POST", pattern_AuthenticationService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.AuthenticationService/Authenticate") - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_AuthenticationService_Authenticate_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_AuthenticationService_Authenticate_0(ctx, mux, outboundMarshaler, w, req, response_AuthenticationService_Authenticate_0{resp}, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterAuthenticationServiceHandlerFromEndpoint is same as RegisterAuthenticationServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterAuthenticationServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterAuthenticationServiceHandler(ctx, mux, conn) -} - -// RegisterAuthenticationServiceHandler registers the http handlers for service AuthenticationService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterAuthenticationServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterAuthenticationServiceHandlerClient(ctx, mux, NewAuthenticationServiceClient(conn)) -} - -// RegisterAuthenticationServiceHandlerClient registers the http handlers for service AuthenticationService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AuthenticationServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AuthenticationServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "AuthenticationServiceClient" to call the correct interceptors. -func RegisterAuthenticationServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthenticationServiceClient) error { - - mux.Handle("POST", pattern_AuthenticationService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.AuthenticationService/Authenticate") - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_AuthenticationService_Authenticate_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_AuthenticationService_Authenticate_0(ctx, mux, outboundMarshaler, w, req, response_AuthenticationService_Authenticate_0{resp}, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -type response_AuthenticationService_Authenticate_0 struct { - proto.Message -} - -func (m response_AuthenticationService_Authenticate_0) XXX_ResponseBody() interface{} { - response := m.Message.(*AuthenticateResponse) - return response.Item -} - -var ( - pattern_AuthenticationService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "auth-methods", "auth_method_id"}, "authenticate")) -) - -var ( - forward_AuthenticationService_Authenticate_0 = runtime.ForwardResponseMessage -) diff --git a/internal/gen/controller/api/services/authenticate_service_grpc.pb.go b/internal/gen/controller/api/services/authenticate_service_grpc.pb.go deleted file mode 100644 index eab373f55..000000000 --- a/internal/gen/controller/api/services/authenticate_service_grpc.pb.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. - -package services - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// AuthenticationServiceClient is the client API for AuthenticationService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type AuthenticationServiceClient interface { - // Authenticate validates credentials provided and returns an Auth Token. - Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) -} - -type authenticationServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewAuthenticationServiceClient(cc grpc.ClientConnInterface) AuthenticationServiceClient { - return &authenticationServiceClient{cc} -} - -func (c *authenticationServiceClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) { - out := new(AuthenticateResponse) - err := c.cc.Invoke(ctx, "/controller.api.services.v1.AuthenticationService/Authenticate", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// AuthenticationServiceServer is the server API for AuthenticationService service. -type AuthenticationServiceServer interface { - // Authenticate validates credentials provided and returns an Auth Token. - Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) -} - -// UnimplementedAuthenticationServiceServer can be embedded to have forward compatible implementations. -type UnimplementedAuthenticationServiceServer struct { -} - -func (*UnimplementedAuthenticationServiceServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") -} - -func RegisterAuthenticationServiceServer(s *grpc.Server, srv AuthenticationServiceServer) { - s.RegisterService(&_AuthenticationService_serviceDesc, srv) -} - -func _AuthenticationService_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AuthenticateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthenticationServiceServer).Authenticate(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/controller.api.services.v1.AuthenticationService/Authenticate", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthenticationServiceServer).Authenticate(ctx, req.(*AuthenticateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _AuthenticationService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "controller.api.services.v1.AuthenticationService", - HandlerType: (*AuthenticationServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Authenticate", - Handler: _AuthenticationService_Authenticate_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "controller/api/services/v1/authenticate_service.proto", -} diff --git a/internal/proto/local/controller/api/services/v1/auth_method_service.proto b/internal/proto/local/controller/api/services/v1/auth_method_service.proto index 98ff014db..87a532ff9 100644 --- a/internal/proto/local/controller/api/services/v1/auth_method_service.proto +++ b/internal/proto/local/controller/api/services/v1/auth_method_service.proto @@ -7,7 +7,9 @@ option go_package = "github.com/hashicorp/boundary/internal/gen/controller/api/s import "protoc-gen-openapiv2/options/annotations.proto"; import "google/api/annotations.proto"; import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; import "controller/api/resources/authmethods/v1/auth_method.proto"; +import "controller/api/resources/authtokens/v1/authtoken.proto"; service AuthMethodService { // GetAuthMethod returns a stored Auth Method if present. The provided request @@ -80,6 +82,18 @@ service AuthMethodService { summary: "Deletes an AuthMethod" }; } + + // Authenticate validates credentials provided and returns an Auth Token. + rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) { + option (google.api.http) = { + post: "/v1/auth-methods/{auth_method_id}:authenticate" + body: "*" + response_body: "item" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Authenticate a user to an scope and retrieve an authentication token." + }; + } } message GetAuthMethodRequest { @@ -122,3 +136,23 @@ message DeleteAuthMethodRequest { } message DeleteAuthMethodResponse {} + +// The layout of the struct for "credentials" field in AuthenticateRequest. This message isn't directly referenced anywhere but is used here to define the expected field names and types. +message PasswordCredentials { + string login_name = 1 [json_name="login_name"]; + string password = 2; +} + +message AuthenticateRequest { + // The ID of the Auth Method in the system that should be used for authentication. + string auth_method_id = 1 [json_name="auth_method_id"]; + // This can be "cookie" or "token". If not provided, "token" will be used. "cookie" activates a split-cookie method where the token is split partially between http-only and regular cookies in order to keep it safe from rogue JS in the browser. + string token_type = 2 [json_name="token_type"]; + // Credentials are passed to the Auth Method; the valid keys and values depend on the type of Auth Method. + google.protobuf.Struct credentials = 3; +} + +message AuthenticateResponse { + resources.authtokens.v1.AuthToken item = 1; + string token_type = 2 [json_name="token_type"]; +} \ No newline at end of file diff --git a/internal/proto/local/controller/api/services/v1/authenticate_service.proto b/internal/proto/local/controller/api/services/v1/authenticate_service.proto deleted file mode 100644 index 0b2fbeb15..000000000 --- a/internal/proto/local/controller/api/services/v1/authenticate_service.proto +++ /dev/null @@ -1,52 +0,0 @@ -syntax = "proto3"; - -package controller.api.services.v1; - -option go_package = "github.com/hashicorp/boundary/internal/gen/controller/api/services;services"; - -import "protoc-gen-openapiv2/options/annotations.proto"; -import "google/api/annotations.proto"; -import "google/protobuf/struct.proto"; -import "controller/api/resources/authtokens/v1/authtoken.proto"; - -option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { - info: { - title: "Controller API" - } - schemes: HTTPS - schemes: HTTP -}; - -service AuthenticationService { - // Authenticate validates credentials provided and returns an Auth Token. - rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) { - option (google.api.http) = { - post: "/v1/auth-methods/{auth_method_id}:authenticate" - body: "*" - response_body: "item" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - summary: "Authenticate a user to an scope and retrieve an authentication token." - }; - } -} - -// The layout of the struct for "credentials" field in AuthenticateRequest. This message isn't directly referenced anywhere but is used here to define the expected field names and types. -message PasswordCredentials { - string login_name = 1 [json_name="login_name"]; - string password = 2; -} - -message AuthenticateRequest { - // The ID of the Auth Method in the system that should be used for authentication. - string auth_method_id = 1 [json_name="auth_method_id"]; - // This can be "cookie" or "token". If not provided, "token" will be used. "cookie" activates a split-cookie method where the token is split partially between http-only and regular cookies in order to keep it safe from rogue JS in the browser. - string token_type = 2 [json_name="token_type"]; - // Credentials are passed to the Auth Method; the valid keys and values depend on the type of Auth Method. - google.protobuf.Struct credentials = 3; -} - -message AuthenticateResponse { - resources.authtokens.v1.AuthToken item = 1; - string token_type = 2 [json_name="token_type"]; -} \ No newline at end of file diff --git a/internal/servers/controller/handler.go b/internal/servers/controller/handler.go index 17b832562..1e2f444d6 100644 --- a/internal/servers/controller/handler.go +++ b/internal/servers/controller/handler.go @@ -23,7 +23,6 @@ import ( "github.com/hashicorp/shared-secure-libs/configutil" "github.com/hashicorp/boundary/internal/servers/controller/handlers" - "github.com/hashicorp/boundary/internal/servers/controller/handlers/authenticate" "github.com/hashicorp/boundary/internal/servers/controller/handlers/authtokens" "github.com/hashicorp/boundary/internal/servers/controller/handlers/groups" "github.com/hashicorp/boundary/internal/servers/controller/handlers/host_catalogs" @@ -108,14 +107,7 @@ func handleGrpcGateway(c *Controller, props HandlerProperties) (http.Handler, er if err := services.RegisterAccountServiceHandlerServer(ctx, mux, accts); err != nil { return nil, fmt.Errorf("failed to register account service handler: %w", err) } - auths, err := authenticate.NewService(c.kms, c.PasswordAuthRepoFn, c.IamRepoFn, c.AuthTokenRepoFn) - if err != nil { - return nil, fmt.Errorf("failed to create authentication handler service: %w", err) - } - if err := services.RegisterAuthenticationServiceHandlerServer(ctx, mux, auths); err != nil { - return nil, fmt.Errorf("failed to register authenticate service handler: %w", err) - } - authMethods, err := authmethods.NewService(c.PasswordAuthRepoFn, c.IamRepoFn) + authMethods, err := authmethods.NewService(c.kms, c.PasswordAuthRepoFn, c.IamRepoFn, c.AuthTokenRepoFn) if err != nil { return nil, fmt.Errorf("failed to create auth method handler service: %w", err) } diff --git a/internal/servers/controller/handlers/authenticate/authenticate_service.go b/internal/servers/controller/handlers/authenticate/authenticate_service.go deleted file mode 100644 index 8a2a8d67f..000000000 --- a/internal/servers/controller/handlers/authenticate/authenticate_service.go +++ /dev/null @@ -1,204 +0,0 @@ -package authenticate - -import ( - "context" - "errors" - "regexp" - "strings" - - "github.com/hashicorp/boundary/internal/auth" - "github.com/hashicorp/boundary/internal/auth/password" - "github.com/hashicorp/boundary/internal/authtoken" - pba "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authtokens" - "github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes" - pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services" - "github.com/hashicorp/boundary/internal/iam" - "github.com/hashicorp/boundary/internal/kms" - "github.com/hashicorp/boundary/internal/servers/controller/common" - "github.com/hashicorp/boundary/internal/servers/controller/handlers" - "github.com/hashicorp/boundary/internal/types/action" - "github.com/hashicorp/boundary/internal/types/resource" - "google.golang.org/grpc/codes" -) - -const ( - loginNameKey = "login_name" - pwKey = "password" -) - -var ( - reInvalidID = regexp.MustCompile("[^A-Za-z0-9]") -) - -// Service handles request as described by the pbs.OrgServiceServer interface. -type Service struct { - kms *kms.Kms - pwRepo common.PasswordAuthRepoFactory - iamRepo common.IamRepoFactory - authTokenRepo common.AuthTokenRepoFactory -} - -// NewService returns an org service which handles org related requests to boundary. -func NewService(kms *kms.Kms, pwRepo common.PasswordAuthRepoFactory, iamRepo common.IamRepoFactory, atRepo common.AuthTokenRepoFactory) (Service, error) { - if kms == nil { - return Service{}, errors.New("nil kms provided") - } - if iamRepo == nil { - return Service{}, errors.New("nil iam repository provided") - } - if atRepo == nil { - return Service{}, errors.New("nil auth token repository provided") - } - if pwRepo == nil { - return Service{}, errors.New("nil password repository provided") - } - - return Service{kms: kms, pwRepo: pwRepo, iamRepo: iamRepo, authTokenRepo: atRepo}, nil -} - -var _ pbs.AuthenticationServiceServer = Service{} - -// Authenticate implements the interface pbs.AuthenticationServiceServer. -func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest) (*pbs.AuthenticateResponse, error) { - if err := validateAuthenticateRequest(req); err != nil { - return nil, err - } - authResults := s.authResult(ctx, req.GetAuthMethodId(), action.Authenticate) - if authResults.Error != nil { - return nil, authResults.Error - } - creds := req.GetCredentials().GetFields() - tok, err := s.authenticateWithRepo(ctx, authResults.Scope.GetId(), req.GetAuthMethodId(), creds[loginNameKey].GetStringValue(), creds[pwKey].GetStringValue()) - if err != nil { - return nil, err - } - return &pbs.AuthenticateResponse{Item: tok, TokenType: req.GetTokenType()}, nil -} - -func (s Service) authenticateWithRepo(ctx context.Context, scopeId, authMethodId, loginName, pw string) (*pba.AuthToken, error) { - iamRepo, err := s.iamRepo() - if err != nil { - return nil, err - } - atRepo, err := s.authTokenRepo() - if err != nil { - return nil, err - } - pwRepo, err := s.pwRepo() - if err != nil { - return nil, err - } - - acct, err := pwRepo.Authenticate(ctx, scopeId, authMethodId, loginName, pw) - if err != nil { - return nil, err - } - if acct == nil { - return nil, handlers.ApiErrorWithCodeAndMessage(codes.Unauthenticated, "Unable to authenticate.") - } - - u, err := iamRepo.LookupUserWithLogin(ctx, acct.GetPublicId(), iam.WithAutoVivify(true)) - if err != nil { - return nil, err - } - tok, err := atRepo.CreateAuthToken(ctx, u, acct.GetPublicId()) - if err != nil { - return nil, err - } - - token, err := authtoken.EncryptToken(ctx, s.kms, scopeId, tok.GetPublicId(), tok.GetToken()) - if err != nil { - return nil, err - } - - tok.Token = tok.GetPublicId() + "_" + token - prot := toProto(tok) - - scp, err := iamRepo.LookupScope(ctx, u.GetScopeId()) - if err != nil { - return nil, err - } - if scp == nil { - return nil, err - } - prot.Scope = &scopes.ScopeInfo{ - Id: scp.GetPublicId(), - Type: scp.GetType(), - ParentScopeId: scp.GetParentId(), - } - - return prot, nil -} - -func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.VerifyResults { - res := auth.VerifyResults{} - - repo, err := s.pwRepo() - if err != nil { - res.Error = err - return res - } - authMeth, err := repo.LookupAuthMethod(ctx, id) - if err != nil { - res.Error = err - return res - } - if authMeth == nil { - res.Error = handlers.NotFoundError() - return res - } - - authResults := auth.Verify(ctx, - auth.WithAction(a), - auth.WithType(resource.AuthMethod), - auth.WithScopeId(authMeth.GetScopeId()), - auth.WithId(id)) - return authResults -} - -func toProto(t *authtoken.AuthToken) *pba.AuthToken { - return &pba.AuthToken{ - Id: t.GetPublicId(), - Token: t.GetToken(), - UserId: t.GetIamUserId(), - AuthMethodId: t.GetAuthMethodId(), - AccountId: t.GetAuthAccountId(), - CreatedTime: t.GetCreateTime().GetTimestamp(), - UpdatedTime: t.GetUpdateTime().GetTimestamp(), - ApproximateLastUsedTime: t.GetApproximateLastAccessTime().GetTimestamp(), - ExpirationTime: t.GetExpirationTime().GetTimestamp(), - } -} - -// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce -// requirements on the structure of the request. They verify that: -// * The path passed in is correctly formatted -// * All required parameters are set -// * There are no conflicting parameters provided -func validateAuthenticateRequest(req *pbs.AuthenticateRequest) error { - badFields := make(map[string]string) - if strings.TrimSpace(req.GetAuthMethodId()) == "" { - badFields["auth_method_id"] = "This is a required field." - } else if !handlers.ValidId(password.AuthMethodPrefix, req.GetAuthMethodId()) { - badFields["auth_method_id"] = "Invalid formatted identifier." - } - // TODO: Update this when we enable different auth method types. - if req.GetCredentials() == nil { - badFields["credentials"] = "This is a required field." - } - creds := req.GetCredentials().GetFields() - if _, ok := creds[loginNameKey]; !ok { - badFields["credentials.login_name"] = "This is a required field." - } - if _, ok := creds[pwKey]; !ok { - badFields["credentials.password"] = "This is a required field." - } - tType := strings.ToLower(strings.TrimSpace(req.GetTokenType())) - if tType != "" && tType != "token" && tType != "cookie" { - badFields["token_type"] = `The only accepted types are "token" and "cookie".` - } - if len(badFields) > 0 { - return handlers.InvalidArgumentErrorf("Invalid fields provided in request.", badFields) - } - return nil -} diff --git a/internal/servers/controller/handlers/authenticate/authenticate_service_test.go b/internal/servers/controller/handlers/authenticate/authenticate_service_test.go deleted file mode 100644 index 7b90aa752..000000000 --- a/internal/servers/controller/handlers/authenticate/authenticate_service_test.go +++ /dev/null @@ -1,234 +0,0 @@ -package authenticate - -import ( - "context" - "errors" - "strings" - "testing" - - structpb "github.com/golang/protobuf/ptypes/struct" - "github.com/hashicorp/boundary/internal/auth" - "github.com/hashicorp/boundary/internal/auth/password" - "github.com/hashicorp/boundary/internal/authtoken" - "github.com/hashicorp/boundary/internal/db" - pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services" - "github.com/hashicorp/boundary/internal/iam" - "github.com/hashicorp/boundary/internal/kms" - "github.com/hashicorp/boundary/internal/servers/controller/handlers" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" -) - -const ( - testPassword = "thetestpassword" - testLoginName = "default" -) - -func TestAuthenticate(t *testing.T) { - conn, _ := db.TestSetup(t, "postgres") - rw := db.New(conn) - wrapper := db.TestWrapper(t) - kms := kms.TestKms(t, conn, wrapper) - o, _ := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) - - authTokenRepoFn := func() (*authtoken.Repository, error) { return authtoken.NewRepository(rw, rw, kms) } - iamRepoFn := func() (*iam.Repository, error) { return iam.NewRepository(rw, rw, kms) } - passwordRepoFn := func() (*password.Repository, error) { return password.NewRepository(rw, rw, kms) } - am := password.TestAuthMethods(t, conn, o.GetPublicId(), 1)[0] - - acct, err := password.NewAccount(am.GetPublicId(), password.WithLoginName(testLoginName)) - require.NoError(t, err) - - pwRepo, err := passwordRepoFn() - require.NoError(t, err) - acct, err = pwRepo.CreateAccount(context.Background(), o.GetPublicId(), acct, password.WithPassword(testPassword)) - require.NoError(t, err) - require.NotNil(t, acct) - - cases := []struct { - name string - request *pbs.AuthenticateRequest - wantType string - wantErr error - }{ - { - name: "basic", - request: &pbs.AuthenticateRequest{ - AuthMethodId: am.GetPublicId(), - TokenType: "token", - Credentials: func() *structpb.Struct { - creds := map[string]*structpb.Value{ - "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, - "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, - } - return &structpb.Struct{Fields: creds} - }(), - }, - wantType: "token", - }, - { - name: "cookie-type", - request: &pbs.AuthenticateRequest{ - AuthMethodId: am.GetPublicId(), - TokenType: "cookie", - Credentials: func() *structpb.Struct { - creds := map[string]*structpb.Value{ - "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, - "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, - } - return &structpb.Struct{Fields: creds} - }(), - }, - wantType: "cookie", - }, - { - name: "no-token-type", - request: &pbs.AuthenticateRequest{ - AuthMethodId: am.GetPublicId(), - Credentials: func() *structpb.Struct { - creds := map[string]*structpb.Value{ - "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, - "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, - } - return &structpb.Struct{Fields: creds} - }(), - }, - }, - { - name: "bad-token-type", - request: &pbs.AuthenticateRequest{ - AuthMethodId: am.GetPublicId(), - TokenType: "email", - Credentials: func() *structpb.Struct { - creds := map[string]*structpb.Value{ - "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, - "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, - } - return &structpb.Struct{Fields: creds} - }(), - }, - wantErr: handlers.ApiErrorWithCode(codes.InvalidArgument), - }, - { - name: "no-authmethod", - request: &pbs.AuthenticateRequest{ - Credentials: func() *structpb.Struct { - creds := map[string]*structpb.Value{ - "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, - "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, - } - return &structpb.Struct{Fields: creds} - }(), - }, - wantErr: handlers.ApiErrorWithCode(codes.InvalidArgument), - }, - { - name: "wrong-password", - request: &pbs.AuthenticateRequest{ - AuthMethodId: am.GetPublicId(), - TokenType: "token", - Credentials: func() *structpb.Struct { - creds := map[string]*structpb.Value{ - "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, - "password": {Kind: &structpb.Value_StringValue{StringValue: "wrong"}}, - } - return &structpb.Struct{Fields: creds} - }(), - }, - wantErr: handlers.ApiErrorWithCode(codes.Unauthenticated), - }, - { - name: "wrong-login-name", - request: &pbs.AuthenticateRequest{ - AuthMethodId: am.GetPublicId(), - TokenType: "token", - Credentials: func() *structpb.Struct { - creds := map[string]*structpb.Value{ - "login_name": {Kind: &structpb.Value_StringValue{StringValue: "wrong"}}, - "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, - } - return &structpb.Struct{Fields: creds} - }(), - }, - wantErr: handlers.ApiErrorWithCode(codes.Unauthenticated), - }, - } - - for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { - assert, require := assert.New(t), require.New(t) - s, err := NewService(kms, passwordRepoFn, iamRepoFn, authTokenRepoFn) - require.NoError(err) - - resp, err := s.Authenticate(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), tc.request) - if tc.wantErr != nil { - assert.Error(err) - assert.Truef(errors.Is(err, tc.wantErr), "Got %#v, wanted %#v", err, tc.wantErr) - return - } - require.NoError(err) - aToken := resp.GetItem() - assert.NotEmpty(aToken.GetId()) - assert.NotEmpty(aToken.GetToken()) - assert.True(strings.HasPrefix(aToken.GetToken(), aToken.GetId())) - assert.Equal(am.GetPublicId(), aToken.GetAuthMethodId()) - assert.Equal(aToken.GetCreatedTime(), aToken.GetUpdatedTime()) - assert.Equal(aToken.GetCreatedTime(), aToken.GetApproximateLastUsedTime()) - assert.Equal(acct.GetPublicId(), aToken.GetAccountId()) - assert.Equal(am.GetPublicId(), aToken.GetAuthMethodId()) - assert.Equal(tc.wantType, resp.GetTokenType()) - }) - } -} - -func TestAuthenticate_AuthAccountConnectedToIamUser(t *testing.T) { - assert, require := assert.New(t), require.New(t) - conn, _ := db.TestSetup(t, "postgres") - rw := db.New(conn) - wrapper := db.TestWrapper(t) - kms := kms.TestKms(t, conn, wrapper) - o, _ := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) - - passwordRepoFn := func() (*password.Repository, error) { return password.NewRepository(rw, rw, kms) } - authTokenRepoFn := func() (*authtoken.Repository, error) { return authtoken.NewRepository(rw, rw, kms) } - iamRepoFn := func() (*iam.Repository, error) { return iam.NewRepository(rw, rw, kms) } - - am := password.TestAuthMethods(t, conn, o.GetPublicId(), 1)[0] - acct, err := password.NewAccount(am.GetPublicId(), password.WithLoginName(testLoginName)) - require.NoError(err) - - pwRepo, err := passwordRepoFn() - require.NoError(err) - acct, err = pwRepo.CreateAccount(context.Background(), o.GetPublicId(), acct, password.WithPassword(testPassword)) - require.NoError(err) - - // connected to an account. - iamRepo, err := iamRepoFn() - require.NoError(err) - iamUser, err := iamRepo.LookupUserWithLogin(context.Background(), acct.GetPublicId(), iam.WithAutoVivify(true)) - require.NoError(err) - - s, err := NewService(kms, passwordRepoFn, iamRepoFn, authTokenRepoFn) - require.NoError(err) - resp, err := s.Authenticate(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), &pbs.AuthenticateRequest{ - AuthMethodId: am.GetPublicId(), - Credentials: func() *structpb.Struct { - creds := map[string]*structpb.Value{ - "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, - "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, - } - return &structpb.Struct{Fields: creds} - }(), - }) - require.NoError(err) - - aToken := resp.GetItem() - assert.Equal(iamUser.GetPublicId(), aToken.GetUserId()) - assert.Equal(am.GetPublicId(), aToken.GetAuthMethodId()) - assert.Equal(acct.GetPublicId(), aToken.GetAccountId()) - - assert.NotEmpty(aToken.GetId()) - assert.NotEmpty(aToken.GetToken()) - assert.True(strings.HasPrefix(aToken.GetToken(), aToken.GetId())) -} diff --git a/internal/servers/controller/handlers/authmethods/authmethod_service.go b/internal/servers/controller/handlers/authmethods/authmethod_service.go index 3848790e3..54e63180b 100644 --- a/internal/servers/controller/handlers/authmethods/authmethod_service.go +++ b/internal/servers/controller/handlers/authmethods/authmethod_service.go @@ -4,13 +4,19 @@ import ( "context" "errors" "fmt" + "strings" "github.com/hashicorp/boundary/internal/auth" "github.com/hashicorp/boundary/internal/auth/password" "github.com/hashicorp/boundary/internal/auth/password/store" + "github.com/hashicorp/boundary/internal/authtoken" "github.com/hashicorp/boundary/internal/db" pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods" + pba "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authtokens" + "github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes" pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services" + "github.com/hashicorp/boundary/internal/iam" + "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/servers/controller/common" "github.com/hashicorp/boundary/internal/servers/controller/handlers" "github.com/hashicorp/boundary/internal/types/action" @@ -20,6 +26,11 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" ) +const ( + loginNameKey = "login_name" + pwKey = "password" +) + var ( maskManager handlers.MaskManager ) @@ -33,19 +44,24 @@ func init() { // Service handles request as described by the pbs.AuthMethodServiceServer interface. type Service struct { - repoFn common.PasswordAuthRepoFactory + kms *kms.Kms + pwRepoFn common.PasswordAuthRepoFactory iamRepoFn common.IamRepoFactory + atRepoFn common.AuthTokenRepoFactory } // NewService returns a auth method service which handles auth method related requests to boundary. -func NewService(repo common.PasswordAuthRepoFactory, iamRepoFn common.IamRepoFactory) (Service, error) { - if repo == nil { +func NewService(kms *kms.Kms, pwRepoFn common.PasswordAuthRepoFactory, iamRepoFn common.IamRepoFactory, atRepoFn common.AuthTokenRepoFactory) (Service, error) { + if kms == nil { + return Service{}, errors.New("nil kms provided") + } + if pwRepoFn == nil { return Service{}, fmt.Errorf("nil password repository provided") } if iamRepoFn == nil { return Service{}, fmt.Errorf("nil iam repository provided") } - return Service{repoFn: repo, iamRepoFn: iamRepoFn}, nil + return Service{kms: kms, pwRepoFn: pwRepoFn, iamRepoFn: iamRepoFn, atRepoFn: atRepoFn}, nil } var _ pbs.AuthMethodServiceServer = Service{} @@ -136,8 +152,25 @@ func (s Service) DeleteAuthMethod(ctx context.Context, req *pbs.DeleteAuthMethod return &pbs.DeleteAuthMethodResponse{}, nil } +// Authenticate implements the interface pbs.AuthenticationServiceServer. +func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest) (*pbs.AuthenticateResponse, error) { + if err := validateAuthenticateRequest(req); err != nil { + return nil, err + } + authResults := s.authResult(ctx, req.GetAuthMethodId(), action.Authenticate) + if authResults.Error != nil { + return nil, authResults.Error + } + creds := req.GetCredentials().GetFields() + tok, err := s.authenticateWithRepo(ctx, authResults.Scope.GetId(), req.GetAuthMethodId(), creds[loginNameKey].GetStringValue(), creds[pwKey].GetStringValue()) + if err != nil { + return nil, err + } + return &pbs.AuthenticateResponse{Item: tok, TokenType: req.GetTokenType()}, nil +} + func (s Service) getFromRepo(ctx context.Context, id string) (*pb.AuthMethod, error) { - repo, err := s.repoFn() + repo, err := s.pwRepoFn() if err != nil { return nil, err } @@ -151,11 +184,11 @@ func (s Service) getFromRepo(ctx context.Context, id string) (*pb.AuthMethod, er if u == nil { return nil, handlers.NotFoundErrorf("AuthMethod %q doesn't exist.", id) } - return toProto(u) + return toAuthMethodProto(u) } func (s Service) listFromRepo(ctx context.Context, scopeId string) ([]*pb.AuthMethod, error) { - repo, err := s.repoFn() + repo, err := s.pwRepoFn() if err != nil { return nil, err } @@ -165,7 +198,7 @@ func (s Service) listFromRepo(ctx context.Context, scopeId string) ([]*pb.AuthMe } var outUl []*pb.AuthMethod for _, u := range ul { - ou, err := toProto(u) + ou, err := toAuthMethodProto(u) if err != nil { return nil, err } @@ -186,7 +219,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth if err != nil { return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to build auth method for creation: %v.", err) } - repo, err := s.repoFn() + repo, err := s.pwRepoFn() if err != nil { return nil, err } @@ -197,7 +230,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth if out == nil { return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create auth method but no error returned from repository.") } - return toProto(out) + return toAuthMethodProto(out) } func (s Service) updateInRepo(ctx context.Context, scopeId, id string, mask []string, item *pb.AuthMethod) (*pb.AuthMethod, error) { @@ -231,7 +264,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, id string, mask []st if len(dbMask) == 0 { return nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."}) } - repo, err := s.repoFn() + repo, err := s.pwRepoFn() if err != nil { return nil, err } @@ -242,11 +275,11 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, id string, mask []st if rowsUpdated == 0 { return nil, handlers.NotFoundErrorf("AuthMethod %q doesn't exist or incorrect version provided.", id) } - return toProto(out) + return toAuthMethodProto(out) } func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool, error) { - repo, err := s.repoFn() + repo, err := s.pwRepoFn() if err != nil { return false, err } @@ -260,6 +293,61 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool, return rows > 0, nil } +func (s Service) authenticateWithRepo(ctx context.Context, scopeId, authMethodId, loginName, pw string) (*pba.AuthToken, error) { + iamRepo, err := s.iamRepoFn() + if err != nil { + return nil, err + } + atRepo, err := s.atRepoFn() + if err != nil { + return nil, err + } + pwRepo, err := s.pwRepoFn() + if err != nil { + return nil, err + } + + acct, err := pwRepo.Authenticate(ctx, scopeId, authMethodId, loginName, pw) + if err != nil { + return nil, err + } + if acct == nil { + return nil, handlers.ApiErrorWithCodeAndMessage(codes.Unauthenticated, "Unable to authenticate.") + } + + u, err := iamRepo.LookupUserWithLogin(ctx, acct.GetPublicId(), iam.WithAutoVivify(true)) + if err != nil { + return nil, err + } + tok, err := atRepo.CreateAuthToken(ctx, u, acct.GetPublicId()) + if err != nil { + return nil, err + } + + token, err := authtoken.EncryptToken(ctx, s.kms, scopeId, tok.GetPublicId(), tok.GetToken()) + if err != nil { + return nil, err + } + + tok.Token = tok.GetPublicId() + "_" + token + prot := toAuthTokenProto(tok) + + scp, err := iamRepo.LookupScope(ctx, u.GetScopeId()) + if err != nil { + return nil, err + } + if scp == nil { + return nil, err + } + prot.Scope = &scopes.ScopeInfo{ + Id: scp.GetPublicId(), + Type: scp.GetType(), + ParentScopeId: scp.GetParentId(), + } + + return prot, nil +} + func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.VerifyResults { res := auth.VerifyResults{} @@ -283,7 +371,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth. return res } default: - repo, err := s.repoFn() + repo, err := s.pwRepoFn() if err != nil { res.Error = err return res @@ -304,7 +392,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth. return auth.Verify(ctx, opts...) } -func toProto(in *password.AuthMethod) (*pb.AuthMethod, error) { +func toAuthMethodProto(in *password.AuthMethod) (*pb.AuthMethod, error) { out := pb.AuthMethod{ Id: in.GetPublicId(), ScopeId: in.GetScopeId(), @@ -330,6 +418,20 @@ func toProto(in *password.AuthMethod) (*pb.AuthMethod, error) { return &out, nil } +func toAuthTokenProto(t *authtoken.AuthToken) *pba.AuthToken { + return &pba.AuthToken{ + Id: t.GetPublicId(), + Token: t.GetToken(), + UserId: t.GetIamUserId(), + AuthMethodId: t.GetAuthMethodId(), + AccountId: t.GetAuthAccountId(), + CreatedTime: t.GetCreateTime().GetTimestamp(), + UpdatedTime: t.GetUpdateTime().GetTimestamp(), + ApproximateLastUsedTime: t.GetApproximateLastAccessTime().GetTimestamp(), + ExpirationTime: t.GetExpirationTime().GetTimestamp(), + } +} + // A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce // requirements on the structure of the request. They verify that: // * The path passed in is correctly formatted @@ -393,3 +495,31 @@ func validateListRequest(req *pbs.ListAuthMethodsRequest) error { } return nil } + +func validateAuthenticateRequest(req *pbs.AuthenticateRequest) error { + badFields := make(map[string]string) + if strings.TrimSpace(req.GetAuthMethodId()) == "" { + badFields["auth_method_id"] = "This is a required field." + } else if !handlers.ValidId(password.AuthMethodPrefix, req.GetAuthMethodId()) { + badFields["auth_method_id"] = "Invalid formatted identifier." + } + // TODO: Update this when we enable different auth method types. + if req.GetCredentials() == nil { + badFields["credentials"] = "This is a required field." + } + creds := req.GetCredentials().GetFields() + if _, ok := creds[loginNameKey]; !ok { + badFields["credentials.login_name"] = "This is a required field." + } + if _, ok := creds[pwKey]; !ok { + badFields["credentials.password"] = "This is a required field." + } + tType := strings.ToLower(strings.TrimSpace(req.GetTokenType())) + if tType != "" && tType != "token" && tType != "cookie" { + badFields["token_type"] = `The only accepted types are "token" and "cookie".` + } + if len(badFields) > 0 { + return handlers.InvalidArgumentErrorf("Invalid fields provided in request.", badFields) + } + return nil +} diff --git a/internal/servers/controller/handlers/authmethods/authmethod_service_test.go b/internal/servers/controller/handlers/authmethods/authmethod_service_test.go index a70b8b419..ce046858c 100644 --- a/internal/servers/controller/handlers/authmethods/authmethod_service_test.go +++ b/internal/servers/controller/handlers/authmethods/authmethod_service_test.go @@ -1,6 +1,7 @@ package authmethods_test import ( + "context" "errors" "fmt" "strings" @@ -10,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/boundary/internal/auth" "github.com/hashicorp/boundary/internal/auth/password" + "github.com/hashicorp/boundary/internal/authtoken" "github.com/hashicorp/boundary/internal/db" pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods" scopepb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes" @@ -29,6 +31,11 @@ import ( "github.com/stretchr/testify/require" ) +const ( + testPassword = "thetestpassword" + testLoginName = "default" +) + func TestGet(t *testing.T) { conn, _ := db.TestSetup(t, "postgres") rw := db.New(conn) @@ -37,9 +44,12 @@ func TestGet(t *testing.T) { iamRepoFn := func() (*iam.Repository, error) { return iam.TestRepo(t, conn, wrapper), nil } - repoFn := func() (*password.Repository, error) { + pwRepoFn := func() (*password.Repository, error) { return password.NewRepository(rw, rw, kms) } + atRepoFn := func() (*authtoken.Repository, error) { + return authtoken.NewRepository(rw, rw, kms) + } iamRepo := iam.TestRepo(t, conn, wrapper) o, _ := iam.TestScopes(t, iamRepo) @@ -101,7 +111,7 @@ func TestGet(t *testing.T) { t.Run(tc.name, func(t *testing.T) { assert, require := assert.New(t), require.New(t) - s, err := authmethods.NewService(repoFn, iamRepoFn) + s, err := authmethods.NewService(kms, pwRepoFn, iamRepoFn, atRepoFn) require.NoError(err, "Couldn't create new auth_method service.") got, gErr := s.GetAuthMethod(auth.DisabledAuthTestContext(auth.WithScopeId(tc.scopeId)), tc.req) @@ -122,9 +132,12 @@ func TestList(t *testing.T) { iamRepoFn := func() (*iam.Repository, error) { return iam.TestRepo(t, conn, wrapper), nil } - repoFn := func() (*password.Repository, error) { + pwRepoFn := func() (*password.Repository, error) { return password.NewRepository(rw, rw, kms) } + atRepoFn := func() (*authtoken.Repository, error) { + return authtoken.NewRepository(rw, rw, kms) + } iamRepo := iam.TestRepo(t, conn, wrapper) oNoAuthMethods, _ := iam.TestScopes(t, iamRepo) @@ -195,7 +208,7 @@ func TestList(t *testing.T) { for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { assert, require := assert.New(t), require.New(t) - s, err := authmethods.NewService(repoFn, iamRepoFn) + s, err := authmethods.NewService(kms, pwRepoFn, iamRepoFn, atRepoFn) require.NoError(err, "Couldn't create new auth_method service.") got, gErr := s.ListAuthMethods(auth.DisabledAuthTestContext(auth.WithScopeId(tc.scopeId)), &pbs.ListAuthMethodsRequest{ScopeId: tc.scopeId}) @@ -216,15 +229,18 @@ func TestDelete(t *testing.T) { iamRepoFn := func() (*iam.Repository, error) { return iam.TestRepo(t, conn, wrapper), nil } - repoFn := func() (*password.Repository, error) { + pwRepoFn := func() (*password.Repository, error) { return password.NewRepository(rw, rw, kms) } + atRepoFn := func() (*authtoken.Repository, error) { + return authtoken.NewRepository(rw, rw, kms) + } iamRepo := iam.TestRepo(t, conn, wrapper) o, _ := iam.TestScopes(t, iamRepo) am := password.TestAuthMethods(t, conn, o.GetPublicId(), 1)[0] - s, err := authmethods.NewService(repoFn, iamRepoFn) + s, err := authmethods.NewService(kms, pwRepoFn, iamRepoFn, atRepoFn) require.NoError(t, err, "Error when getting new auth_method service.") cases := []struct { @@ -277,15 +293,18 @@ func TestDelete_twice(t *testing.T) { iamRepoFn := func() (*iam.Repository, error) { return iam.TestRepo(t, conn, wrapper), nil } - repoFn := func() (*password.Repository, error) { + pwRepoFn := func() (*password.Repository, error) { return password.NewRepository(rw, rw, kms) } + atRepoFn := func() (*authtoken.Repository, error) { + return authtoken.NewRepository(rw, rw, kms) + } iamRepo := iam.TestRepo(t, conn, wrapper) o, _ := iam.TestScopes(t, iamRepo) am := password.TestAuthMethods(t, conn, o.GetPublicId(), 1)[0] - s, err := authmethods.NewService(repoFn, iamRepoFn) + s, err := authmethods.NewService(kms, pwRepoFn, iamRepoFn, atRepoFn) require.NoError(err, "Error when getting new auth_method service.") req := &pbs.DeleteAuthMethodRequest{ @@ -306,9 +325,12 @@ func TestCreate(t *testing.T) { iamRepoFn := func() (*iam.Repository, error) { return iam.TestRepo(t, conn, wrapper), nil } - repoFn := func() (*password.Repository, error) { + pwRepoFn := func() (*password.Repository, error) { return password.NewRepository(rw, rw, kms) } + atRepoFn := func() (*authtoken.Repository, error) { + return authtoken.NewRepository(rw, rw, kms) + } iamRepo := iam.TestRepo(t, conn, wrapper) o, _ := iam.TestScopes(t, iamRepo) @@ -445,7 +467,7 @@ func TestCreate(t *testing.T) { t.Run(tc.name, func(t *testing.T) { assert, require := assert.New(t), require.New(t) - s, err := authmethods.NewService(repoFn, iamRepoFn) + s, err := authmethods.NewService(kms, pwRepoFn, iamRepoFn, atRepoFn) require.NoError(err, "Error when getting new auth_method service.") got, gErr := s.CreateAuthMethod(auth.DisabledAuthTestContext(auth.WithScopeId(tc.req.GetItem().GetScopeId())), tc.req) @@ -485,13 +507,16 @@ func TestUpdate(t *testing.T) { iamRepoFn := func() (*iam.Repository, error) { return iam.TestRepo(t, conn, wrapper), nil } - repoFn := func() (*password.Repository, error) { + pwRepoFn := func() (*password.Repository, error) { return password.NewRepository(rw, rw, kms) } + atRepoFn := func() (*authtoken.Repository, error) { + return authtoken.NewRepository(rw, rw, kms) + } iamRepo := iam.TestRepo(t, conn, wrapper) o, _ := iam.TestScopes(t, iamRepo) - tested, err := authmethods.NewService(repoFn, iamRepoFn) + tested, err := authmethods.NewService(kms, pwRepoFn, iamRepoFn, atRepoFn) require.NoError(t, err, "Error when getting new auth_method service.") defaultScopeInfo := &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: o.GetType()} @@ -863,3 +888,223 @@ func TestUpdate(t *testing.T) { }) } } + +func TestAuthenticate(t *testing.T) { + conn, _ := db.TestSetup(t, "postgres") + rw := db.New(conn) + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + o, _ := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + pwRepoFn := func() (*password.Repository, error) { + return password.NewRepository(rw, rw, kms) + } + atRepoFn := func() (*authtoken.Repository, error) { + return authtoken.NewRepository(rw, rw, kms) + } + am := password.TestAuthMethods(t, conn, o.GetPublicId(), 1)[0] + + acct, err := password.NewAccount(am.GetPublicId(), password.WithLoginName(testLoginName)) + require.NoError(t, err) + + pwRepo, err := pwRepoFn() + require.NoError(t, err) + acct, err = pwRepo.CreateAccount(context.Background(), o.GetPublicId(), acct, password.WithPassword(testPassword)) + require.NoError(t, err) + require.NotNil(t, acct) + + cases := []struct { + name string + request *pbs.AuthenticateRequest + wantType string + wantErr error + }{ + { + name: "basic", + request: &pbs.AuthenticateRequest{ + AuthMethodId: am.GetPublicId(), + TokenType: "token", + Credentials: func() *structpb.Struct { + creds := map[string]*structpb.Value{ + "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, + "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, + } + return &structpb.Struct{Fields: creds} + }(), + }, + wantType: "token", + }, + { + name: "cookie-type", + request: &pbs.AuthenticateRequest{ + AuthMethodId: am.GetPublicId(), + TokenType: "cookie", + Credentials: func() *structpb.Struct { + creds := map[string]*structpb.Value{ + "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, + "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, + } + return &structpb.Struct{Fields: creds} + }(), + }, + wantType: "cookie", + }, + { + name: "no-token-type", + request: &pbs.AuthenticateRequest{ + AuthMethodId: am.GetPublicId(), + Credentials: func() *structpb.Struct { + creds := map[string]*structpb.Value{ + "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, + "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, + } + return &structpb.Struct{Fields: creds} + }(), + }, + }, + { + name: "bad-token-type", + request: &pbs.AuthenticateRequest{ + AuthMethodId: am.GetPublicId(), + TokenType: "email", + Credentials: func() *structpb.Struct { + creds := map[string]*structpb.Value{ + "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, + "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, + } + return &structpb.Struct{Fields: creds} + }(), + }, + wantErr: handlers.ApiErrorWithCode(codes.InvalidArgument), + }, + { + name: "no-authmethod", + request: &pbs.AuthenticateRequest{ + Credentials: func() *structpb.Struct { + creds := map[string]*structpb.Value{ + "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, + "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, + } + return &structpb.Struct{Fields: creds} + }(), + }, + wantErr: handlers.ApiErrorWithCode(codes.InvalidArgument), + }, + { + name: "wrong-password", + request: &pbs.AuthenticateRequest{ + AuthMethodId: am.GetPublicId(), + TokenType: "token", + Credentials: func() *structpb.Struct { + creds := map[string]*structpb.Value{ + "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, + "password": {Kind: &structpb.Value_StringValue{StringValue: "wrong"}}, + } + return &structpb.Struct{Fields: creds} + }(), + }, + wantErr: handlers.ApiErrorWithCode(codes.Unauthenticated), + }, + { + name: "wrong-login-name", + request: &pbs.AuthenticateRequest{ + AuthMethodId: am.GetPublicId(), + TokenType: "token", + Credentials: func() *structpb.Struct { + creds := map[string]*structpb.Value{ + "login_name": {Kind: &structpb.Value_StringValue{StringValue: "wrong"}}, + "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, + } + return &structpb.Struct{Fields: creds} + }(), + }, + wantErr: handlers.ApiErrorWithCode(codes.Unauthenticated), + }, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + assert, require := assert.New(t), require.New(t) + s, err := authmethods.NewService(kms, pwRepoFn, iamRepoFn, atRepoFn) + require.NoError(err) + + resp, err := s.Authenticate(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), tc.request) + if tc.wantErr != nil { + assert.Error(err) + assert.Truef(errors.Is(err, tc.wantErr), "Got %#v, wanted %#v", err, tc.wantErr) + return + } + require.NoError(err) + aToken := resp.GetItem() + assert.NotEmpty(aToken.GetId()) + assert.NotEmpty(aToken.GetToken()) + assert.True(strings.HasPrefix(aToken.GetToken(), aToken.GetId())) + assert.Equal(am.GetPublicId(), aToken.GetAuthMethodId()) + assert.Equal(aToken.GetCreatedTime(), aToken.GetUpdatedTime()) + assert.Equal(aToken.GetCreatedTime(), aToken.GetApproximateLastUsedTime()) + assert.Equal(acct.GetPublicId(), aToken.GetAccountId()) + assert.Equal(am.GetPublicId(), aToken.GetAuthMethodId()) + assert.Equal(tc.wantType, resp.GetTokenType()) + }) + } +} + +func TestAuthenticate_AuthAccountConnectedToIamUser(t *testing.T) { + assert, require := assert.New(t), require.New(t) + conn, _ := db.TestSetup(t, "postgres") + rw := db.New(conn) + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + o, _ := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + pwRepoFn := func() (*password.Repository, error) { + return password.NewRepository(rw, rw, kms) + } + atRepoFn := func() (*authtoken.Repository, error) { + return authtoken.NewRepository(rw, rw, kms) + } + + am := password.TestAuthMethods(t, conn, o.GetPublicId(), 1)[0] + acct, err := password.NewAccount(am.GetPublicId(), password.WithLoginName(testLoginName)) + require.NoError(err) + + pwRepo, err := pwRepoFn() + require.NoError(err) + acct, err = pwRepo.CreateAccount(context.Background(), o.GetPublicId(), acct, password.WithPassword(testPassword)) + require.NoError(err) + + // connected to an account. + iamRepo, err := iamRepoFn() + require.NoError(err) + iamUser, err := iamRepo.LookupUserWithLogin(context.Background(), acct.GetPublicId(), iam.WithAutoVivify(true)) + require.NoError(err) + + s, err := authmethods.NewService(kms, pwRepoFn, iamRepoFn, atRepoFn) + require.NoError(err) + resp, err := s.Authenticate(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), &pbs.AuthenticateRequest{ + AuthMethodId: am.GetPublicId(), + Credentials: func() *structpb.Struct { + creds := map[string]*structpb.Value{ + "login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}}, + "password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}}, + } + return &structpb.Struct{Fields: creds} + }(), + }) + require.NoError(err) + + aToken := resp.GetItem() + assert.Equal(iamUser.GetPublicId(), aToken.GetUserId()) + assert.Equal(am.GetPublicId(), aToken.GetAuthMethodId()) + assert.Equal(acct.GetPublicId(), aToken.GetAccountId()) + + assert.NotEmpty(aToken.GetId()) + assert.NotEmpty(aToken.GetToken()) + assert.True(strings.HasPrefix(aToken.GetToken(), aToken.GetId())) +}