From 2a851b4f33b481fe1eac6ad3c593330787fd990b Mon Sep 17 00:00:00 2001 From: Iain Macdonald Date: Mon, 9 Sep 2024 15:56:29 -0700 Subject: [PATCH] Add GetPublicKeys RPC to AuthService for retrieving RSA public key(s) that will be use to verify JWTs. --- enterprise/server/auth_service/auth_service.go | 4 ++++ enterprise/server/remoteauth/remoteauth_test.go | 4 ++++ proto/auth.proto | 11 +++++++++++ server/interfaces/interfaces.go | 1 + 4 files changed, 20 insertions(+) diff --git a/enterprise/server/auth_service/auth_service.go b/enterprise/server/auth_service/auth_service.go index 4031325f410..1cfbae04a84 100644 --- a/enterprise/server/auth_service/auth_service.go +++ b/enterprise/server/auth_service/auth_service.go @@ -31,3 +31,7 @@ func (a AuthService) Authenticate(ctx context.Context, req *authpb.AuthenticateR } return nil, status.UnauthenticatedError("Authentication failed") } + +func (a AuthService) GetPublicKeys(ctx context.Context, req *authpb.GetPublicKeysRequest) (*authpb.GetPublicKeysResponse, error) { + return &authpb.GetPublicKeysResponse{}, status.UnimplementedError("GetPublicKeys unimplemented") +} diff --git a/enterprise/server/remoteauth/remoteauth_test.go b/enterprise/server/remoteauth/remoteauth_test.go index b5ef71de834..0c04b755df6 100644 --- a/enterprise/server/remoteauth/remoteauth_test.go +++ b/enterprise/server/remoteauth/remoteauth_test.go @@ -58,6 +58,10 @@ func (a *fakeAuthService) Authenticate(ctx context.Context, req *authpb.Authenti return &authpb.AuthenticateResponse{Jwt: &jwt}, nil } +func (a *fakeAuthService) GetPublicKeys(ctx context.Context, req *authpb.GetPublicKeysRequest) (*authpb.GetPublicKeysResponse, error) { + return &authpb.GetPublicKeysResponse{}, status.UnimplementedError("GetPublicKeys unimplemented") +} + func setup(t *testing.T) (interfaces.Authenticator, *fakeAuthService) { fakeAuthService := fakeAuthService{} te := testenv.GetTestEnv(t) diff --git a/proto/auth.proto b/proto/auth.proto index 8677f1800a8..31cde203e8a 100644 --- a/proto/auth.proto +++ b/proto/auth.proto @@ -11,6 +11,17 @@ message AuthenticateResponse { optional string jwt = 1; } +message GetPublicKeysRequest {} + +message GetPublicKeysResponse { + repeated PublicKey public_keys = 1; +} + +message PublicKey { + optional string key = 1; +} + service AuthService { rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse); + rpc GetPublicKeys(GetPublicKeysRequest) returns (GetPublicKeysResponse); } diff --git a/server/interfaces/interfaces.go b/server/interfaces/interfaces.go index 1ee8e64ec74..757874c6342 100644 --- a/server/interfaces/interfaces.go +++ b/server/interfaces/interfaces.go @@ -1553,6 +1553,7 @@ type CodesearchService interface { type AuthService interface { Authenticate(ctx context.Context, req *authpb.AuthenticateRequest) (*authpb.AuthenticateResponse, error) + GetPublicKeys(ctx context.Context, req *authpb.GetPublicKeysRequest) (*authpb.GetPublicKeysResponse, error) } type RegistryService interface {