Documentation
¶
Overview ¶
Package handler is a generated GoMock package.
Package handler is a generated GoMock package.
Package handler is a generated GoMock package.
Index ¶
- Constants
- func NewAuthHandler(provider, region string) http.Handler
- func StartServer(provider, region string, port int)
- type AWSAuthHandler
- type AWSAuthHandlerBuilder
- type AWSTokenGenerator
- type AuthHandlerdeprecated
- type DefaultAWSTokenGenerator
- type DefaultGoogleServiceImpl
- type GCPAuthHandler
- type GCPAuthHandlerBuilder
- type GoogleService
- type MockAWSTokenGenerator
- type MockAWSTokenGeneratorMockRecorder
- type MockGoogleService
- type MockGoogleServiceMockRecorder
- type MockTokenSource
- type MockTokenSourceMockRecorder
Constants ¶
const ( ProviderGCP = "gcp" ProviderAWS = "aws" )
Provider constants for supported cloud providers.
Variables ¶
This section is empty.
Functions ¶
func NewAuthHandler ¶
NewAuthHandler creates the appropriate auth handler based on provider. For GCP: uses Google Application Default Credentials. For AWS: uses IAM Roles for Service Accounts (IRSA) with the specified region. If provider is empty or unknown, defaults to GCP for backwards compatibility.
func StartServer ¶
StartServer starts the HTTP server with provider-based authentication. provider: "gcp" or "aws" (defaults to "gcp" if empty). region: AWS region for MSK IAM authentication (required for AWS, ignored for GCP). port: The port to listen on.
Types ¶
type AWSAuthHandler ¶
type AWSAuthHandler struct {
TokenGenerator AWSTokenGenerator
Region string
}
AWSAuthHandler handles AWS MSK IAM token requests for Kafka authentication.
func (*AWSAuthHandler) ServeHTTP ¶
func (h *AWSAuthHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request)
ServeHTTP handles the HTTP request for AWS MSK IAM tokens.
type AWSAuthHandlerBuilder ¶
type AWSAuthHandlerBuilder struct {
// contains filtered or unexported fields
}
AWSAuthHandlerBuilder builds AWSAuthHandler instances.
func NewAWSAuthHandlerBuilder ¶
func NewAWSAuthHandlerBuilder() *AWSAuthHandlerBuilder
NewAWSAuthHandlerBuilder creates a new AWSAuthHandlerBuilder.
func (*AWSAuthHandlerBuilder) Build ¶
func (b *AWSAuthHandlerBuilder) Build() *AWSAuthHandler
Build creates the AWSAuthHandler.
func (*AWSAuthHandlerBuilder) WithRegion ¶
func (b *AWSAuthHandlerBuilder) WithRegion(region string) *AWSAuthHandlerBuilder
WithRegion sets the AWS region for token generation.
func (*AWSAuthHandlerBuilder) WithTokenGenerator ¶
func (b *AWSAuthHandlerBuilder) WithTokenGenerator(generator AWSTokenGenerator) *AWSAuthHandlerBuilder
WithTokenGenerator sets the token generator for testing.
type AWSTokenGenerator ¶
type AWSTokenGenerator interface {
GenerateAuthToken(ctx context.Context, region string) (string, int64, error)
}
AWSTokenGenerator provides AWS MSK IAM token generation.
type AuthHandler
deprecated
type AuthHandler = GCPAuthHandler
AuthHandler is an alias for GCPAuthHandler.
Deprecated: Use GCPAuthHandler and NewGCPAuthHandlerBuilder instead.
type DefaultAWSTokenGenerator ¶
type DefaultAWSTokenGenerator struct{}
DefaultAWSTokenGenerator uses the aws-msk-iam-sasl-signer-go library.
func (*DefaultAWSTokenGenerator) GenerateAuthToken ¶
func (g *DefaultAWSTokenGenerator) GenerateAuthToken(ctx context.Context, region string) (string, int64, error)
GenerateAuthToken generates an AWS MSK IAM authentication token.
type DefaultGoogleServiceImpl ¶
type DefaultGoogleServiceImpl struct {
GoogleService
}
DefaultGoogleServiceImpl is the default implementation using Google's OAuth2 library.
func (*DefaultGoogleServiceImpl) FindDefaultCredentials ¶
func (s *DefaultGoogleServiceImpl) FindDefaultCredentials(ctx context.Context, scopes ...string) (*google.Credentials, error)
FindDefaultCredentials retrieves Google Application Default Credentials.
type GCPAuthHandler ¶
type GCPAuthHandler struct {
GoogleService GoogleService
}
GCPAuthHandler handles GCP OAuth token requests for Kafka authentication.
func (*GCPAuthHandler) ServeHTTP ¶
func (h *GCPAuthHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request)
ServeHTTP handles the HTTP request for GCP OAuth tokens.
type GCPAuthHandlerBuilder ¶
type GCPAuthHandlerBuilder struct {
// contains filtered or unexported fields
}
GCPAuthHandlerBuilder builds GCPAuthHandler instances.
func NewAuthHandlerBuilder
deprecated
func NewAuthHandlerBuilder() *GCPAuthHandlerBuilder
NewAuthHandlerBuilder creates a new GCPAuthHandlerBuilder.
Deprecated: Use NewGCPAuthHandlerBuilder instead.
func NewGCPAuthHandlerBuilder ¶
func NewGCPAuthHandlerBuilder() *GCPAuthHandlerBuilder
NewGCPAuthHandlerBuilder creates a new GCPAuthHandlerBuilder.
func (*GCPAuthHandlerBuilder) Build ¶
func (b *GCPAuthHandlerBuilder) Build() *GCPAuthHandler
Build creates the GCPAuthHandler.
func (*GCPAuthHandlerBuilder) WithGoogleService ¶
func (b *GCPAuthHandlerBuilder) WithGoogleService(googleService GoogleService) *GCPAuthHandlerBuilder
WithGoogleService sets the GoogleService for testing.
type GoogleService ¶
type GoogleService interface {
FindDefaultCredentials(ctx context.Context, scopes ...string) (*google.Credentials, error)
}
GoogleService provides Google credential operations.
type MockAWSTokenGenerator ¶
type MockAWSTokenGenerator struct {
// contains filtered or unexported fields
}
MockAWSTokenGenerator is a mock of AWSTokenGenerator interface.
func NewMockAWSTokenGenerator ¶
func NewMockAWSTokenGenerator(ctrl *gomock.Controller) *MockAWSTokenGenerator
NewMockAWSTokenGenerator creates a new mock instance.
func (*MockAWSTokenGenerator) EXPECT ¶
func (m *MockAWSTokenGenerator) EXPECT() *MockAWSTokenGeneratorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockAWSTokenGenerator) GenerateAuthToken ¶
func (m *MockAWSTokenGenerator) GenerateAuthToken(ctx context.Context, region string) (string, int64, error)
GenerateAuthToken mocks base method.
type MockAWSTokenGeneratorMockRecorder ¶
type MockAWSTokenGeneratorMockRecorder struct {
// contains filtered or unexported fields
}
MockAWSTokenGeneratorMockRecorder is the mock recorder for MockAWSTokenGenerator.
func (*MockAWSTokenGeneratorMockRecorder) GenerateAuthToken ¶
func (mr *MockAWSTokenGeneratorMockRecorder) GenerateAuthToken(ctx, region any) *gomock.Call
GenerateAuthToken indicates an expected call of GenerateAuthToken.
type MockGoogleService ¶
type MockGoogleService struct {
// contains filtered or unexported fields
}
MockGoogleService is a mock of GoogleService interface.
func NewMockGoogleService ¶
func NewMockGoogleService(ctrl *gomock.Controller) *MockGoogleService
NewMockGoogleService creates a new mock instance.
func (*MockGoogleService) EXPECT ¶
func (m *MockGoogleService) EXPECT() *MockGoogleServiceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockGoogleService) FindDefaultCredentials ¶
func (m *MockGoogleService) FindDefaultCredentials(ctx context.Context, scopes ...string) (*google.Credentials, error)
FindDefaultCredentials mocks base method.
type MockGoogleServiceMockRecorder ¶
type MockGoogleServiceMockRecorder struct {
// contains filtered or unexported fields
}
MockGoogleServiceMockRecorder is the mock recorder for MockGoogleService.
func (*MockGoogleServiceMockRecorder) FindDefaultCredentials ¶
func (mr *MockGoogleServiceMockRecorder) FindDefaultCredentials(ctx any, scopes ...any) *gomock.Call
FindDefaultCredentials indicates an expected call of FindDefaultCredentials.
type MockTokenSource ¶
type MockTokenSource struct {
// contains filtered or unexported fields
}
MockTokenSource is a mock of TokenSource interface.
func NewMockTokenSource ¶
func NewMockTokenSource(ctrl *gomock.Controller) *MockTokenSource
NewMockTokenSource creates a new mock instance.
func (*MockTokenSource) EXPECT ¶
func (m *MockTokenSource) EXPECT() *MockTokenSourceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockTokenSourceMockRecorder ¶
type MockTokenSourceMockRecorder struct {
// contains filtered or unexported fields
}
MockTokenSourceMockRecorder is the mock recorder for MockTokenSource.
func (*MockTokenSourceMockRecorder) Token ¶
func (mr *MockTokenSourceMockRecorder) Token() *gomock.Call
Token indicates an expected call of Token.