common

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package common is a generated GoMock package.

Index

Constants

View Source
const (
	AuthHeader string = "Authorization"
)

Variables

This section is empty.

Functions

func ExtractBearerToken added in v0.6.0

func ExtractBearerToken(r *http.Request) (string, error)

func IsPublicAuthEndpoint added in v1.0.0

func IsPublicAuthEndpoint(path string) bool

IsPublicAuthEndpoint checks if the given path is a public auth endpoint that doesn't require authentication or org validation. Only includes endpoints served by the main API server. OIDC/OAuth2 endpoints (authorize, token, jwks, etc.) are served by the PAM issuer on a separate server and are not included here.

func ShouldValidateOrg added in v1.0.0

func ShouldValidateOrg(method, path string) bool

ShouldValidateOrg checks if org validation should be performed for the given method and path. Returns false if org validation should be skipped, true otherwise.

Types

type AuthNMiddleware added in v1.0.0

type AuthNMiddleware interface {
	GetAuthToken(r *http.Request) (string, error)
	ValidateToken(ctx context.Context, token string) error
	GetIdentity(ctx context.Context, token string) (Identity, error)
	GetAuthConfig() *v1beta1.AuthConfig
	IsEnabled() bool
}

type AuthOrganizationsConfig added in v0.10.0

type AuthOrganizationsConfig struct {
	// OrganizationAssignment defines how users are assigned to organizations
	OrganizationAssignment *v1beta1.AuthOrganizationAssignment
}

type BaseIdentity added in v0.10.0

type BaseIdentity struct {
	// contains filtered or unexported fields
}

func NewBaseIdentity added in v0.10.0

func NewBaseIdentity(username string, uID string, organizations []ReportedOrganization) *BaseIdentity

func NewBaseIdentityWithIssuer added in v1.0.0

func NewBaseIdentityWithIssuer(username string, uID string, organizations []ReportedOrganization, issuer *identity.Issuer) *BaseIdentity

func (*BaseIdentity) GetIssuer added in v1.0.0

func (i *BaseIdentity) GetIssuer() *identity.Issuer

func (*BaseIdentity) GetOrganizations added in v1.0.0

func (i *BaseIdentity) GetOrganizations() []ReportedOrganization

func (*BaseIdentity) GetUID added in v0.10.0

func (i *BaseIdentity) GetUID() string

func (*BaseIdentity) GetUsername added in v0.10.0

func (i *BaseIdentity) GetUsername() string

func (*BaseIdentity) IsSuperAdmin added in v1.0.0

func (i *BaseIdentity) IsSuperAdmin() bool

func (*BaseIdentity) SetIssuer added in v1.0.0

func (i *BaseIdentity) SetIssuer(issuer *identity.Issuer)

func (*BaseIdentity) SetOrganizations added in v1.0.0

func (i *BaseIdentity) SetOrganizations(organizations []ReportedOrganization)

func (*BaseIdentity) SetSuperAdmin added in v1.0.0

func (i *BaseIdentity) SetSuperAdmin(superAdmin bool)

func (*BaseIdentity) SetUID added in v0.10.0

func (i *BaseIdentity) SetUID(uID string)

func (*BaseIdentity) SetUsername added in v0.10.0

func (i *BaseIdentity) SetUsername(username string)

type ContextKey added in v1.0.0

type ContextKey string

ContextKey is a custom type for context keys to avoid collisions

type Identity added in v0.4.0

type Identity interface {
	GetUsername() string
	GetUID() string
	GetOrganizations() []ReportedOrganization
	GetIssuer() *identity.Issuer
	IsSuperAdmin() bool
	SetSuperAdmin(bool)
}

func GetIdentity added in v0.4.0

func GetIdentity(ctx context.Context) (Identity, error)

type K8sIdentity added in v1.0.0

type K8sIdentity struct {
	*BaseIdentity
	// contains filtered or unexported fields
}

K8sIdentity extends BaseIdentity with K8s control plane URL and RBAC namespace

func NewK8sIdentity added in v1.0.0

func NewK8sIdentity(username string, uID string, organizations []ReportedOrganization, issuer *identity.Issuer, controlPlaneUrl string, rbacNs string) *K8sIdentity

func (*K8sIdentity) GetControlPlaneUrl added in v1.0.0

func (i *K8sIdentity) GetControlPlaneUrl() string

func (*K8sIdentity) GetRbacNs added in v1.0.0

func (i *K8sIdentity) GetRbacNs() string

type K8sIdentityProvider added in v1.0.0

type K8sIdentityProvider interface {
	Identity
	GetControlPlaneUrl() string
}

K8sIdentityProvider extends Identity with control plane URL for K8s-based auth

type MockAuthNMiddleware added in v1.0.0

type MockAuthNMiddleware struct {
	// contains filtered or unexported fields
}

MockAuthNMiddleware is a mock of AuthNMiddleware interface.

func NewMockAuthNMiddleware added in v1.0.0

func NewMockAuthNMiddleware(ctrl *gomock.Controller) *MockAuthNMiddleware

NewMockAuthNMiddleware creates a new mock instance.

func (*MockAuthNMiddleware) EXPECT added in v1.0.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAuthNMiddleware) GetAuthConfig added in v1.0.0

func (m *MockAuthNMiddleware) GetAuthConfig() *v1beta1.AuthConfig

GetAuthConfig mocks base method.

func (*MockAuthNMiddleware) GetAuthToken added in v1.0.0

func (m *MockAuthNMiddleware) GetAuthToken(r *http.Request) (string, error)

GetAuthToken mocks base method.

func (*MockAuthNMiddleware) GetIdentity added in v1.0.0

func (m *MockAuthNMiddleware) GetIdentity(ctx context.Context, token string) (Identity, error)

GetIdentity mocks base method.

func (*MockAuthNMiddleware) IsEnabled added in v1.0.0

func (m *MockAuthNMiddleware) IsEnabled() bool

IsEnabled mocks base method.

func (*MockAuthNMiddleware) ValidateToken added in v1.0.0

func (m *MockAuthNMiddleware) ValidateToken(ctx context.Context, token string) error

ValidateToken mocks base method.

type MockAuthNMiddlewareMockRecorder added in v1.0.0

type MockAuthNMiddlewareMockRecorder struct {
	// contains filtered or unexported fields
}

MockAuthNMiddlewareMockRecorder is the mock recorder for MockAuthNMiddleware.

func (*MockAuthNMiddlewareMockRecorder) GetAuthConfig added in v1.0.0

func (mr *MockAuthNMiddlewareMockRecorder) GetAuthConfig() *gomock.Call

GetAuthConfig indicates an expected call of GetAuthConfig.

func (*MockAuthNMiddlewareMockRecorder) GetAuthToken added in v1.0.0

func (mr *MockAuthNMiddlewareMockRecorder) GetAuthToken(r any) *gomock.Call

GetAuthToken indicates an expected call of GetAuthToken.

func (*MockAuthNMiddlewareMockRecorder) GetIdentity added in v1.0.0

func (mr *MockAuthNMiddlewareMockRecorder) GetIdentity(ctx, token any) *gomock.Call

GetIdentity indicates an expected call of GetIdentity.

func (*MockAuthNMiddlewareMockRecorder) IsEnabled added in v1.0.0

func (mr *MockAuthNMiddlewareMockRecorder) IsEnabled() *gomock.Call

IsEnabled indicates an expected call of IsEnabled.

func (*MockAuthNMiddlewareMockRecorder) ValidateToken added in v1.0.0

func (mr *MockAuthNMiddlewareMockRecorder) ValidateToken(ctx, token any) *gomock.Call

ValidateToken indicates an expected call of ValidateToken.

type MockIdentity added in v1.0.0

type MockIdentity struct {
	// contains filtered or unexported fields
}

MockIdentity is a mock of Identity interface.

func NewMockIdentity added in v1.0.0

func NewMockIdentity(ctrl *gomock.Controller) *MockIdentity

NewMockIdentity creates a new mock instance.

func (*MockIdentity) EXPECT added in v1.0.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIdentity) GetIssuer added in v1.0.0

func (m *MockIdentity) GetIssuer() *identity.Issuer

GetIssuer mocks base method.

func (*MockIdentity) GetOrganizations added in v1.0.0

func (m *MockIdentity) GetOrganizations() []ReportedOrganization

GetOrganizations mocks base method.

func (*MockIdentity) GetUID added in v1.0.0

func (m *MockIdentity) GetUID() string

GetUID mocks base method.

func (*MockIdentity) GetUsername added in v1.0.0

func (m *MockIdentity) GetUsername() string

GetUsername mocks base method.

func (*MockIdentity) IsSuperAdmin added in v1.0.0

func (m *MockIdentity) IsSuperAdmin() bool

IsSuperAdmin mocks base method.

func (*MockIdentity) SetSuperAdmin added in v1.0.0

func (m *MockIdentity) SetSuperAdmin(arg0 bool)

SetSuperAdmin mocks base method.

type MockIdentityMockRecorder added in v1.0.0

type MockIdentityMockRecorder struct {
	// contains filtered or unexported fields
}

MockIdentityMockRecorder is the mock recorder for MockIdentity.

func (*MockIdentityMockRecorder) GetIssuer added in v1.0.0

func (mr *MockIdentityMockRecorder) GetIssuer() *gomock.Call

GetIssuer indicates an expected call of GetIssuer.

func (*MockIdentityMockRecorder) GetOrganizations added in v1.0.0

func (mr *MockIdentityMockRecorder) GetOrganizations() *gomock.Call

GetOrganizations indicates an expected call of GetOrganizations.

func (*MockIdentityMockRecorder) GetUID added in v1.0.0

func (mr *MockIdentityMockRecorder) GetUID() *gomock.Call

GetUID indicates an expected call of GetUID.

func (*MockIdentityMockRecorder) GetUsername added in v1.0.0

func (mr *MockIdentityMockRecorder) GetUsername() *gomock.Call

GetUsername indicates an expected call of GetUsername.

func (*MockIdentityMockRecorder) IsSuperAdmin added in v1.0.0

func (mr *MockIdentityMockRecorder) IsSuperAdmin() *gomock.Call

IsSuperAdmin indicates an expected call of IsSuperAdmin.

func (*MockIdentityMockRecorder) SetSuperAdmin added in v1.0.0

func (mr *MockIdentityMockRecorder) SetSuperAdmin(arg0 any) *gomock.Call

SetSuperAdmin indicates an expected call of SetSuperAdmin.

type MockK8sIdentityProvider added in v1.0.0

type MockK8sIdentityProvider struct {
	// contains filtered or unexported fields
}

MockK8sIdentityProvider is a mock of K8sIdentityProvider interface.

func NewMockK8sIdentityProvider added in v1.0.0

func NewMockK8sIdentityProvider(ctrl *gomock.Controller) *MockK8sIdentityProvider

NewMockK8sIdentityProvider creates a new mock instance.

func (*MockK8sIdentityProvider) EXPECT added in v1.0.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockK8sIdentityProvider) GetControlPlaneUrl added in v1.0.0

func (m *MockK8sIdentityProvider) GetControlPlaneUrl() string

GetControlPlaneUrl mocks base method.

func (*MockK8sIdentityProvider) GetIssuer added in v1.0.0

func (m *MockK8sIdentityProvider) GetIssuer() *identity.Issuer

GetIssuer mocks base method.

func (*MockK8sIdentityProvider) GetOrganizations added in v1.0.0

func (m *MockK8sIdentityProvider) GetOrganizations() []ReportedOrganization

GetOrganizations mocks base method.

func (*MockK8sIdentityProvider) GetUID added in v1.0.0

func (m *MockK8sIdentityProvider) GetUID() string

GetUID mocks base method.

func (*MockK8sIdentityProvider) GetUsername added in v1.0.0

func (m *MockK8sIdentityProvider) GetUsername() string

GetUsername mocks base method.

func (*MockK8sIdentityProvider) IsSuperAdmin added in v1.0.0

func (m *MockK8sIdentityProvider) IsSuperAdmin() bool

IsSuperAdmin mocks base method.

func (*MockK8sIdentityProvider) SetSuperAdmin added in v1.0.0

func (m *MockK8sIdentityProvider) SetSuperAdmin(arg0 bool)

SetSuperAdmin mocks base method.

type MockK8sIdentityProviderMockRecorder added in v1.0.0

type MockK8sIdentityProviderMockRecorder struct {
	// contains filtered or unexported fields
}

MockK8sIdentityProviderMockRecorder is the mock recorder for MockK8sIdentityProvider.

func (*MockK8sIdentityProviderMockRecorder) GetControlPlaneUrl added in v1.0.0

func (mr *MockK8sIdentityProviderMockRecorder) GetControlPlaneUrl() *gomock.Call

GetControlPlaneUrl indicates an expected call of GetControlPlaneUrl.

func (*MockK8sIdentityProviderMockRecorder) GetIssuer added in v1.0.0

GetIssuer indicates an expected call of GetIssuer.

func (*MockK8sIdentityProviderMockRecorder) GetOrganizations added in v1.0.0

func (mr *MockK8sIdentityProviderMockRecorder) GetOrganizations() *gomock.Call

GetOrganizations indicates an expected call of GetOrganizations.

func (*MockK8sIdentityProviderMockRecorder) GetUID added in v1.0.0

GetUID indicates an expected call of GetUID.

func (*MockK8sIdentityProviderMockRecorder) GetUsername added in v1.0.0

func (mr *MockK8sIdentityProviderMockRecorder) GetUsername() *gomock.Call

GetUsername indicates an expected call of GetUsername.

func (*MockK8sIdentityProviderMockRecorder) IsSuperAdmin added in v1.0.0

func (mr *MockK8sIdentityProviderMockRecorder) IsSuperAdmin() *gomock.Call

IsSuperAdmin indicates an expected call of IsSuperAdmin.

func (*MockK8sIdentityProviderMockRecorder) SetSuperAdmin added in v1.0.0

func (mr *MockK8sIdentityProviderMockRecorder) SetSuperAdmin(arg0 any) *gomock.Call

SetSuperAdmin indicates an expected call of SetSuperAdmin.

type MockMultiAuthNMiddleware added in v1.0.0

type MockMultiAuthNMiddleware struct {
	// contains filtered or unexported fields
}

MockMultiAuthNMiddleware is a mock of MultiAuthNMiddleware interface.

func NewMockMultiAuthNMiddleware added in v1.0.0

func NewMockMultiAuthNMiddleware(ctrl *gomock.Controller) *MockMultiAuthNMiddleware

NewMockMultiAuthNMiddleware creates a new mock instance.

func (*MockMultiAuthNMiddleware) EXPECT added in v1.0.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMultiAuthNMiddleware) GetAuthConfig added in v1.0.0

func (m *MockMultiAuthNMiddleware) GetAuthConfig() *v1beta1.AuthConfig

GetAuthConfig mocks base method.

func (*MockMultiAuthNMiddleware) GetAuthToken added in v1.0.0

func (m *MockMultiAuthNMiddleware) GetAuthToken(r *http.Request) (string, error)

GetAuthToken mocks base method.

func (*MockMultiAuthNMiddleware) GetIdentity added in v1.0.0

func (m *MockMultiAuthNMiddleware) GetIdentity(ctx context.Context, token string) (Identity, error)

GetIdentity mocks base method.

func (*MockMultiAuthNMiddleware) IsEnabled added in v1.0.0

func (m *MockMultiAuthNMiddleware) IsEnabled() bool

IsEnabled mocks base method.

func (*MockMultiAuthNMiddleware) ValidateToken added in v1.0.0

func (m *MockMultiAuthNMiddleware) ValidateToken(ctx context.Context, token string) error

ValidateToken mocks base method.

func (*MockMultiAuthNMiddleware) ValidateTokenAndGetProvider added in v1.0.0

func (m *MockMultiAuthNMiddleware) ValidateTokenAndGetProvider(ctx context.Context, token string) (AuthNMiddleware, error)

ValidateTokenAndGetProvider mocks base method.

type MockMultiAuthNMiddlewareMockRecorder added in v1.0.0

type MockMultiAuthNMiddlewareMockRecorder struct {
	// contains filtered or unexported fields
}

MockMultiAuthNMiddlewareMockRecorder is the mock recorder for MockMultiAuthNMiddleware.

func (*MockMultiAuthNMiddlewareMockRecorder) GetAuthConfig added in v1.0.0

func (mr *MockMultiAuthNMiddlewareMockRecorder) GetAuthConfig() *gomock.Call

GetAuthConfig indicates an expected call of GetAuthConfig.

func (*MockMultiAuthNMiddlewareMockRecorder) GetAuthToken added in v1.0.0

func (mr *MockMultiAuthNMiddlewareMockRecorder) GetAuthToken(r any) *gomock.Call

GetAuthToken indicates an expected call of GetAuthToken.

func (*MockMultiAuthNMiddlewareMockRecorder) GetIdentity added in v1.0.0

func (mr *MockMultiAuthNMiddlewareMockRecorder) GetIdentity(ctx, token any) *gomock.Call

GetIdentity indicates an expected call of GetIdentity.

func (*MockMultiAuthNMiddlewareMockRecorder) IsEnabled added in v1.0.0

IsEnabled indicates an expected call of IsEnabled.

func (*MockMultiAuthNMiddlewareMockRecorder) ValidateToken added in v1.0.0

func (mr *MockMultiAuthNMiddlewareMockRecorder) ValidateToken(ctx, token any) *gomock.Call

ValidateToken indicates an expected call of ValidateToken.

func (*MockMultiAuthNMiddlewareMockRecorder) ValidateTokenAndGetProvider added in v1.0.0

func (mr *MockMultiAuthNMiddlewareMockRecorder) ValidateTokenAndGetProvider(ctx, token any) *gomock.Call

ValidateTokenAndGetProvider indicates an expected call of ValidateTokenAndGetProvider.

type MultiAuthNMiddleware added in v1.0.0

type MultiAuthNMiddleware interface {
	AuthNMiddleware
	ValidateTokenAndGetProvider(ctx context.Context, token string) (AuthNMiddleware, error)
}

type OpenShiftIdentity added in v1.0.0

type OpenShiftIdentity struct {
	*BaseIdentity
	// contains filtered or unexported fields
}

OpenShiftIdentity extends BaseIdentity with OpenShift control plane URL

func NewOpenShiftIdentity added in v1.0.0

func NewOpenShiftIdentity(username string, uID string, organizations []ReportedOrganization, issuer *identity.Issuer, controlPlaneUrl string) *OpenShiftIdentity

func (*OpenShiftIdentity) GetControlPlaneUrl added in v1.0.0

func (i *OpenShiftIdentity) GetControlPlaneUrl() string

type ReportedOrganization added in v1.0.0

type ReportedOrganization struct {
	Name         string
	IsInternalID bool
	ID           string
	Roles        []string
}

func BuildReportedOrganizations added in v1.0.0

func BuildReportedOrganizations(organizations []string, orgRoles map[string][]string, isInternalID bool) ([]ReportedOrganization, bool)

BuildReportedOrganizations creates ReportedOrganization list from organizations and their roles It handles: - Extracting global roles (from "*" key in orgRoles map) - Detecting flightctl-admin role and setting super admin flag - Filtering out flightctl-admin from both global and org-specific roles (it's only used for super admin flag) - Distributing remaining global roles to all organizations - Combining org-specific and global roles for each organization

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL