Documentation ¶
Index ¶
- Constants
- Variables
- func ContextWithSecurity(ctx context.Context, opts ...SecurityContextOptions) context.Context
- func MockedPropertiesBinder[T any](prefix string) func(ctx *bootstrap.ApplicationContext) (T, error)
- func MockedSessionStoreDecorator(_ session.Store) session.Store
- func NewMockedSessionStore() session.Store
- func NewMockedTokenStoreReader(acctsProps map[string]*MockedAccountProperties, ...) oauth2.TokenStoreReader
- func NewMockedUserAuthentication(opts ...MockUserAuthOptions) *mockUserAuthentication
- func RegisterTestConfigurer(opts ...MWMockOptions) func(di mwDI)
- func SessionID(sessionId string) webtest.RequestOptions
- func WithMockedMiddleware(opts ...MWMockOptions) test.Options
- func WithMockedScopes(mocksConfigFS ...embed.FS) test.Options
- func WithMockedSecurity(ctx context.Context, opts ...SecurityMockOptions) context.Context
- type DirectExtractionMWMocker
- type Feature
- type FeatureConfigurer
- type IdpManagerMockOption
- type IdpManagerMockOptions
- type MWMockContext
- type MWMockFunc
- type MWMockOption
- type MWMockOptions
- func MWCondition(matchers ...web.RequestMatcher) MWMockOptions
- func MWCustomConfigurer(configurer security.Configurer) MWMockOptions
- func MWCustomMocker(mocker MWMocker) MWMockOptions
- func MWEnableSession() MWMockOptions
- func MWForceOverride() MWMockOptions
- func MWForcePreOAuth2AuthValidation() MWMockOptions
- func MWRoute(matchers ...web.RouteMatcher) MWMockOptions
- type MWMocker
- type MockAccountStore
- func (m *MockAccountStore) LoadAccountById(_ context.Context, id interface{}) (security.Account, error)
- func (m *MockAccountStore) LoadAccountByUsername(_ context.Context, username string) (security.Account, error)
- func (m *MockAccountStore) LoadLockingRules(ctx context.Context, acct security.Account) (security.AccountLockingRule, error)
- func (m *MockAccountStore) LoadPwdAgingRules(ctx context.Context, acct security.Account) (security.AccountPwdAgingRule, error)
- func (m *MockAccountStore) Save(_ context.Context, _ security.Account) error
- type MockAccountStoreWithFinalize
- type MockAuthenticationMiddleware
- type MockUserAuthOption
- type MockUserAuthOptions
- type MockedAccount
- func (m MockedAccount) CacheableCopy() security.Account
- func (m MockedAccount) Credentials() interface{}
- func (m MockedAccount) DefaultDesignatedTenantId() string
- func (m MockedAccount) DesignatedTenantIds() []string
- func (m MockedAccount) Disabled() bool
- func (m MockedAccount) ID() interface{}
- func (m MockedAccount) Locked() bool
- func (m MockedAccount) Permissions() []string
- func (m MockedAccount) TenantId() string
- func (m MockedAccount) Type() security.AccountType
- func (m MockedAccount) UseMFA() bool
- func (m MockedAccount) Username() string
- type MockedAccountAuthentication
- type MockedAccountDetails
- type MockedAccountModifier
- type MockedAccountProperties
- type MockedClient
- func (m MockedClient) AccessTokenValidity() time.Duration
- func (m MockedClient) AssignedTenantIds() utils.StringSet
- func (m MockedClient) AutoApproveScopes() utils.StringSet
- func (m MockedClient) CacheableCopy() security.Account
- func (m MockedClient) ClientId() string
- func (m MockedClient) Credentials() interface{}
- func (m MockedClient) Disabled() bool
- func (m MockedClient) GrantTypes() utils.StringSet
- func (m MockedClient) ID() interface{}
- func (m MockedClient) Locked() bool
- func (m MockedClient) Permissions() []string
- func (m MockedClient) RedirectUris() utils.StringSet
- func (m MockedClient) RefreshTokenValidity() time.Duration
- func (m MockedClient) ResourceIDs() utils.StringSet
- func (m MockedClient) Scopes() utils.StringSet
- func (m MockedClient) Secret() string
- func (m MockedClient) SecretRequired() bool
- func (m MockedClient) Type() security.AccountType
- func (m MockedClient) UseMFA() bool
- func (m MockedClient) UseSessionTimeout() bool
- func (m MockedClient) Username() string
- type MockedClientProperties
- type MockedClientStore
- type MockedFederatedAccountStore
- type MockedFederatedUserProperties
- type MockedIDPManager
- type MockedPasswdIdentityProvider
- type MockedProperties
- type MockedPropertiesAccounts
- type MockedPropertiesClients
- type MockedPropertiesFederatedUsers
- type MockedPropertiesTenants
- type MockedProviderStore
- type MockedSecurityDetails
- func (d *MockedSecurityDetails) AccountType() security.AccountType
- func (d *MockedSecurityDetails) AssignedTenantIds() utils.StringSetdeprecated
- func (d *MockedSecurityDetails) AuthenticationTime() time.Time
- func (d *MockedSecurityDetails) CurrencyCode() string
- func (d *MockedSecurityDetails) EffectiveAssignedTenantIds() utils.StringSet
- func (d *MockedSecurityDetails) Email() string
- func (d *MockedSecurityDetails) ExpiryTime() time.Time
- func (d *MockedSecurityDetails) FirstName() string
- func (d *MockedSecurityDetails) IssueTime() time.Time
- func (d *MockedSecurityDetails) LastName() string
- func (d *MockedSecurityDetails) LocaleCode() string
- func (d *MockedSecurityDetails) OriginalUsername() string
- func (d *MockedSecurityDetails) Permissions() utils.StringSet
- func (d *MockedSecurityDetails) ProviderDescription() string
- func (d *MockedSecurityDetails) ProviderDisplayName() string
- func (d *MockedSecurityDetails) ProviderEmail() string
- func (d *MockedSecurityDetails) ProviderId() string
- func (d *MockedSecurityDetails) ProviderName() string
- func (d *MockedSecurityDetails) ProviderNotificationType() string
- func (d *MockedSecurityDetails) Proxied() bool
- func (d *MockedSecurityDetails) Roles() utils.StringSet
- func (d *MockedSecurityDetails) TenantExternalId() string
- func (d *MockedSecurityDetails) TenantId() string
- func (d *MockedSecurityDetails) TenantSuspended() bool
- func (d *MockedSecurityDetails) UserId() string
- func (d *MockedSecurityDetails) Username() string
- func (d *MockedSecurityDetails) Value(s string) (interface{}, bool)
- func (d *MockedSecurityDetails) Values() map[string]interface{}
- type MockedSessionStore
- func (ss *MockedSessionStore) AddToPrincipalIndex(principal string, s *session.Session) error
- func (ss *MockedSessionStore) ChangeId(s *session.Session) error
- func (ss *MockedSessionStore) FindByPrincipalName(principal string, sessionName string) ([]*session.Session, error)
- func (ss *MockedSessionStore) Get(id string, name string) (s *session.Session, err error)
- func (ss *MockedSessionStore) Invalidate(sessions ...*session.Session) error
- func (ss *MockedSessionStore) InvalidateByPrincipalName(principal, sessionName string) error
- func (ss *MockedSessionStore) New(name string) (*session.Session, error)
- func (ss *MockedSessionStore) Options() *session.Options
- func (ss *MockedSessionStore) RemoveFromPrincipalIndex(_ string, s *session.Session) error
- func (ss *MockedSessionStore) Save(s *session.Session) error
- func (ss *MockedSessionStore) WithContext(_ context.Context) session.Store
- type MockedTenantProperties
- type MockedTenantStore
- type MockedToken
- func (mt *MockedToken) Details() map[string]interface{}
- func (mt *MockedToken) Expired() bool
- func (mt *MockedToken) ExpiryTime() time.Time
- func (mt *MockedToken) IssueTime() time.Time
- func (mt MockedToken) MarshalText() (text []byte, err error)
- func (mt *MockedToken) RefreshToken() oauth2.RefreshToken
- func (mt *MockedToken) Scopes() utils.StringSet
- func (mt MockedToken) String() string
- func (mt *MockedToken) Type() oauth2.TokenType
- func (mt *MockedToken) UnmarshalText(text []byte) error
- func (mt *MockedToken) Value() string
- type MockedTokenInfo
- type MockedTokenRevoker
- type MockingProperties
- type MocksDIOut
- type SecurityContextOption
- type SecurityContextOptions
- type SecurityDetailsMock
- type SecurityMockOptions
Constants ¶
const ( MockedProviderID = "test-provider" MockedProviderName = "test-provider" )
const (
MockingPropertiesPrefix = "mocking"
)
Variables ¶
var (
FeatureId = security.FeatureId("SecTest", security.FeatureOrderAuthenticator)
)
Functions ¶
func ContextWithSecurity ¶
func ContextWithSecurity(ctx context.Context, opts ...SecurityContextOptions) context.Context
ContextWithSecurity set given SecurityContextOptions in the given context, returning the new context
func MockedPropertiesBinder ¶
func MockedPropertiesBinder[T any](prefix string) func(ctx *bootstrap.ApplicationContext) (T, error)
MockedPropertiesBinder returns a FX provider that bind specific mocked properties type from the properties sub-section specified by "prefix". The root section prefix is defined by MockingPropertiesPrefix e.g. MockedPropertiesBinder[MockedPropertiesAccounts]("accounts"):
The returned binder binds MockedPropertiesAccounts from "mocking.accounts"
func NewMockedSessionStore ¶
func NewMockedTokenStoreReader ¶
func NewMockedTokenStoreReader(acctsProps map[string]*MockedAccountProperties, tenantProps map[string]*MockedTenantProperties) oauth2.TokenStoreReader
NewMockedTokenStoreReader create a mocked oauth2.TokenStoreReader based on properties, The returned reader also implements MockedTokenRevoker
func NewMockedUserAuthentication ¶
func NewMockedUserAuthentication(opts ...MockUserAuthOptions) *mockUserAuthentication
func RegisterTestConfigurer ¶
func RegisterTestConfigurer(opts ...MWMockOptions) func(di mwDI)
func SessionID ¶
func SessionID(sessionId string) webtest.RequestOptions
func WithMockedMiddleware ¶
func WithMockedMiddleware(opts ...MWMockOptions) test.Options
WithMockedMiddleware is a test option that automatically install a middleware that populate/save security.Authentication into gin.Context.
This test option works with webtest.WithMockedServer without any additional settings: - By default extract security.Authentication from request's context. Note: Since gin-gonic v1.8.0+, this test option is not required anymore for webtest.WithMockedServer. Values in request's context is automatically linked with gin.Context.
When using with webtest.WithRealServer, a custom MWMocker is required. The MWMocker can be provided by:
- Using MWCustomMocker option
- Providing a MWMocker using uber/fx
- Providing a security.Configurer with NewMockedMW: <code> func realServerSecConfigurer(ws security.WebSecurity) { ws.Route(matcher.AnyRoute()). With(NewMockedMW(). Mocker(MWMockFunc(realServerMockFunc)), ) } </code>
See examples package for more details.
func WithMockedScopes ¶
WithMockedScopes is a test.Options that initialize github.com/cisco-open/go-lanai/pkg/integrate/security/scope This option configure mocked security scopes based on yaml provided as embed.FS. If no config is provided, the default config is used
func WithMockedSecurity ¶
func WithMockedSecurity(ctx context.Context, opts ...SecurityMockOptions) context.Context
WithMockedSecurity used to mock an oauth2.Authentication in the given context, returning a new context Deprecated: use ContextWithSecurity(ctx, MockedAuthentication(opts...)) instead
Types ¶
type DirectExtractionMWMocker ¶
type DirectExtractionMWMocker struct{}
DirectExtractionMWMocker is an MWMocker that extracts authentication from context. This is the implementation is works together with webtest.WithMockedServer and WithMockedSecurity, where a context is injected with security.Authentication and directly passed into http.Request
func (DirectExtractionMWMocker) Mock ¶
func (m DirectExtractionMWMocker) Mock(mc MWMockContext) security.Authentication
type Feature ¶
func Configure ¶
func Configure(ws security.WebSecurity) *Feature
func NewMockedMW ¶
func NewMockedMW() *Feature
NewMockedMW Standard security.Feature entrypoint, DSL style. Used with security.WebSecurity
func (*Feature) ForceOverride ¶ added in v0.14.0
func (*Feature) Identifier ¶
func (f *Feature) Identifier() security.FeatureIdentifier
func (*Feature) MWMockFunc ¶
func (f *Feature) MWMockFunc(mocker MWMockFunc) *Feature
type FeatureConfigurer ¶
type FeatureConfigurer struct { }
func (*FeatureConfigurer) Apply ¶
func (c *FeatureConfigurer) Apply(feature security.Feature, ws security.WebSecurity) error
type IdpManagerMockOption ¶
type IdpManagerMockOption struct {
PasswdIDPDomain string
}
type IdpManagerMockOptions ¶
type IdpManagerMockOptions func(opt *IdpManagerMockOption)
type MWMockContext ¶
MWMockContext value carrier for mocking authentication in MW
type MWMockFunc ¶
type MWMockFunc func(MWMockContext) security.Authentication
MWMockFunc wrap a function to MWMocker interface
func (MWMockFunc) Mock ¶
func (f MWMockFunc) Mock(mc MWMockContext) security.Authentication
type MWMockOption ¶
type MWMockOption struct { Route web.RouteMatcher Condition web.RequestMatcher MWMocker MWMocker MWOrder int Configurer security.Configurer Session bool ForceOverride bool }
type MWMockOptions ¶
type MWMockOptions func(opt *MWMockOption)
func MWCondition ¶
func MWCondition(matchers ...web.RequestMatcher) MWMockOptions
MWCondition returns option for WithMockedMiddleware. This condition is applied to the default test security.Configurer
func MWCustomConfigurer ¶
func MWCustomConfigurer(configurer security.Configurer) MWMockOptions
MWCustomConfigurer returns option for WithMockedMiddleware. If set to nil, MWMockOption.Route and MWMockOption.Condition are used to generate a default configurer If set to non-nil, MWMockOption.Route and MWMockOption.Condition are ignored
func MWCustomMocker ¶
func MWCustomMocker(mocker MWMocker) MWMockOptions
MWCustomMocker returns option for WithMockedMiddleware. If set to nil, fx provided MWMocker will be used
func MWEnableSession ¶
func MWEnableSession() MWMockOptions
MWEnableSession returns option for WithMockedMiddleware. Enabling in-memory session
func MWForceOverride ¶
func MWForceOverride() MWMockOptions
MWForceOverride returns option for WithMockedMiddleware. Add a middleware after the last auth middleware (before access control) that override any other installed authenticators.
func MWForcePreOAuth2AuthValidation ¶
func MWForcePreOAuth2AuthValidation() MWMockOptions
MWForcePreOAuth2AuthValidation returns option for WithMockedMiddleware. Decrease the order of mocking middleware such that it runs before OAuth2 authorize validation.
func MWRoute ¶
func MWRoute(matchers ...web.RouteMatcher) MWMockOptions
MWRoute returns option for WithMockedMiddleware. This route is applied to the default test security.Configurer
type MWMocker ¶
type MWMocker interface {
Mock(MWMockContext) security.Authentication
}
MWMocker interface that mocked authentication middleware uses to mock authentication at runtime
type MockAccountStore ¶
type MockAccountStore struct {
// contains filtered or unexported fields
}
func NewMockedAccountStore ¶
func NewMockedAccountStore(accountProps []*MockedAccountProperties, modifiers ...MockedAccountModifier) *MockAccountStore
func (*MockAccountStore) LoadAccountById ¶
func (*MockAccountStore) LoadAccountByUsername ¶
func (*MockAccountStore) LoadLockingRules ¶
func (m *MockAccountStore) LoadLockingRules(ctx context.Context, acct security.Account) (security.AccountLockingRule, error)
func (*MockAccountStore) LoadPwdAgingRules ¶
func (m *MockAccountStore) LoadPwdAgingRules(ctx context.Context, acct security.Account) (security.AccountPwdAgingRule, error)
type MockAccountStoreWithFinalize ¶
type MockAccountStoreWithFinalize struct { MockAccountStore // contains filtered or unexported fields }
func NewMockedAccountStoreWithFinalize ¶
func NewMockedAccountStoreWithFinalize(accountProps []*MockedAccountProperties, tenantProps []*MockedTenantProperties, modifiers ...MockedAccountModifier) *MockAccountStoreWithFinalize
func (*MockAccountStoreWithFinalize) Finalize ¶
func (m *MockAccountStoreWithFinalize) Finalize( ctx context.Context, account security.Account, options ...security.AccountFinalizeOptions, ) (security.Account, error)
Finalize will read the tenant details from the security.AccountFinalizeOption and adjust the user permission depending on which tenant is selected. Note that permissions vary depending on the combination of user + tenant. User1 with Tenant1 can have different permissions than User2 with Tenant1.
type MockAuthenticationMiddleware ¶
type MockAuthenticationMiddleware struct { MWMocker MWMocker // deprecated, use MWMocker interface or MWMockFunc. // Recommended to use WithMockedMiddleware test options MockedAuthentication security.Authentication }
func NewMockAuthenticationMiddleware ¶
func NewMockAuthenticationMiddleware(authentication security.Authentication) *MockAuthenticationMiddleware
NewMockAuthenticationMiddleware Deprecated, directly set MWMocker field with MWMocker interface or MWMockFunc, Recommended to use WithMockedMiddleware test options
func (*MockAuthenticationMiddleware) AuthenticationHandlerFunc ¶
func (m *MockAuthenticationMiddleware) AuthenticationHandlerFunc() gin.HandlerFunc
func (*MockAuthenticationMiddleware) ForceOverrideHandlerFunc ¶ added in v0.14.0
func (m *MockAuthenticationMiddleware) ForceOverrideHandlerFunc() gin.HandlerFunc
type MockUserAuthOption ¶
type MockUserAuthOption struct { Principal string Permissions map[string]interface{} State security.AuthenticationState Details interface{} }
type MockUserAuthOptions ¶
type MockUserAuthOptions func(opt *MockUserAuthOption)
type MockedAccount ¶
type MockedAccount struct {
MockedAccountDetails
}
func (MockedAccount) CacheableCopy ¶
func (m MockedAccount) CacheableCopy() security.Account
func (MockedAccount) Credentials ¶
func (m MockedAccount) Credentials() interface{}
func (MockedAccount) DefaultDesignatedTenantId ¶
func (m MockedAccount) DefaultDesignatedTenantId() string
func (MockedAccount) DesignatedTenantIds ¶
func (m MockedAccount) DesignatedTenantIds() []string
func (MockedAccount) Disabled ¶
func (m MockedAccount) Disabled() bool
func (MockedAccount) ID ¶
func (m MockedAccount) ID() interface{}
func (MockedAccount) Locked ¶
func (m MockedAccount) Locked() bool
func (MockedAccount) Permissions ¶
func (m MockedAccount) Permissions() []string
func (MockedAccount) TenantId ¶
func (m MockedAccount) TenantId() string
func (MockedAccount) Type ¶
func (m MockedAccount) Type() security.AccountType
func (MockedAccount) UseMFA ¶
func (m MockedAccount) UseMFA() bool
func (MockedAccount) Username ¶
func (m MockedAccount) Username() string
type MockedAccountAuthentication ¶
type MockedAccountAuthentication struct { Account MockedAccount AuthState security.AuthenticationState DetailsMap map[string]interface{} }
func (MockedAccountAuthentication) Details ¶
func (a MockedAccountAuthentication) Details() interface{}
func (MockedAccountAuthentication) Permissions ¶
func (a MockedAccountAuthentication) Permissions() security.Permissions
func (MockedAccountAuthentication) Principal ¶
func (a MockedAccountAuthentication) Principal() interface{}
func (MockedAccountAuthentication) State ¶
func (a MockedAccountAuthentication) State() security.AuthenticationState
type MockedAccountDetails ¶
type MockedAccountModifier ¶
MockedAccountModifier works with MockAccountStore. It allows tests to modify the mocked account after load
type MockedAccountProperties ¶
type MockedClient ¶
type MockedClient struct {
MockedClientProperties
}
func (MockedClient) AccessTokenValidity ¶
func (m MockedClient) AccessTokenValidity() time.Duration
func (MockedClient) AssignedTenantIds ¶
func (m MockedClient) AssignedTenantIds() utils.StringSet
func (MockedClient) AutoApproveScopes ¶
func (m MockedClient) AutoApproveScopes() utils.StringSet
func (MockedClient) CacheableCopy ¶
func (m MockedClient) CacheableCopy() security.Account
func (MockedClient) ClientId ¶
func (m MockedClient) ClientId() string
func (MockedClient) Credentials ¶
func (m MockedClient) Credentials() interface{}
func (MockedClient) Disabled ¶
func (m MockedClient) Disabled() bool
func (MockedClient) GrantTypes ¶
func (m MockedClient) GrantTypes() utils.StringSet
func (MockedClient) ID ¶
func (m MockedClient) ID() interface{}
func (MockedClient) Locked ¶
func (m MockedClient) Locked() bool
func (MockedClient) Permissions ¶
func (m MockedClient) Permissions() []string
func (MockedClient) RedirectUris ¶
func (m MockedClient) RedirectUris() utils.StringSet
func (MockedClient) RefreshTokenValidity ¶
func (m MockedClient) RefreshTokenValidity() time.Duration
func (MockedClient) ResourceIDs ¶
func (m MockedClient) ResourceIDs() utils.StringSet
func (MockedClient) Scopes ¶
func (m MockedClient) Scopes() utils.StringSet
func (MockedClient) Secret ¶
func (m MockedClient) Secret() string
func (MockedClient) SecretRequired ¶
func (m MockedClient) SecretRequired() bool
func (MockedClient) Type ¶
func (m MockedClient) Type() security.AccountType
func (MockedClient) UseMFA ¶
func (m MockedClient) UseMFA() bool
func (MockedClient) UseSessionTimeout ¶
func (m MockedClient) UseSessionTimeout() bool
func (MockedClient) Username ¶
func (m MockedClient) Username() string
type MockedClientProperties ¶
type MockedClientProperties struct { ClientID string `json:"id"` Secret string `json:"secret"` GrantTypes utils.CommaSeparatedSlice `json:"grant-types"` Scopes utils.CommaSeparatedSlice `json:"scopes"` AutoApproveScopes utils.CommaSeparatedSlice `json:"auto-approve-scopes"` RedirectUris utils.CommaSeparatedSlice `json:"redirect-uris"` ATValidity utils.Duration `json:"access-token-validity"` RTValidity utils.Duration `json:"refresh-token-validity"` AssignedTenantIds utils.CommaSeparatedSlice `json:"tenants"` }
type MockedClientStore ¶
type MockedClientStore struct {
// contains filtered or unexported fields
}
func NewMockedClientStore ¶
func NewMockedClientStore(props ...*MockedClientProperties) *MockedClientStore
func (*MockedClientStore) LoadClientByClientId ¶
func (s *MockedClientStore) LoadClientByClientId(_ context.Context, clientId string) (oauth2.OAuth2Client, error)
type MockedFederatedAccountStore ¶
type MockedFederatedAccountStore struct {
// contains filtered or unexported fields
}
func NewMockedFederatedAccountStore ¶
func NewMockedFederatedAccountStore(props ...*MockedFederatedUserProperties) MockedFederatedAccountStore
func (MockedFederatedAccountStore) LoadAccountByExternalId ¶
func (s MockedFederatedAccountStore) LoadAccountByExternalId(_ context.Context, extIdName string, extIdValue string, extIdpName string, _ security.AutoCreateUserDetails, _ interface{}) (security.Account, error)
LoadAccountByExternalId The externalIdName and value matches the test assertion The externalIdp matches that from the MockedIdpName
type MockedFederatedUserProperties ¶
type MockedFederatedUserProperties struct { MockedAccountProperties ExtIdpName string `json:"ext-idp-name"` ExtIdName string `json:"ext-id-name"` ExtIdValue string `json:"ext-id-value"` }
type MockedIDPManager ¶
type MockedIDPManager struct {
// contains filtered or unexported fields
}
func NewMockedIDPManager ¶
func NewMockedIDPManager(opts ...IdpManagerMockOptions) *MockedIDPManager
func (*MockedIDPManager) GetIdentityProviderByDomain ¶
func (m *MockedIDPManager) GetIdentityProviderByDomain(ctx context.Context, domain string) (idp.IdentityProvider, error)
func (*MockedIDPManager) GetIdentityProvidersWithFlow ¶
func (m *MockedIDPManager) GetIdentityProvidersWithFlow(ctx context.Context, flow idp.AuthenticationFlow) []idp.IdentityProvider
type MockedPasswdIdentityProvider ¶
type MockedPasswdIdentityProvider struct {
// contains filtered or unexported fields
}
func NewMockedPasswdIdentityProvider ¶
func NewMockedPasswdIdentityProvider(domain string) *MockedPasswdIdentityProvider
func (MockedPasswdIdentityProvider) AuthenticationFlow ¶
func (s MockedPasswdIdentityProvider) AuthenticationFlow() idp.AuthenticationFlow
func (MockedPasswdIdentityProvider) Domain ¶
func (s MockedPasswdIdentityProvider) Domain() string
type MockedProperties ¶
func (MockedProperties[T]) MapValues ¶
func (p MockedProperties[T]) MapValues() map[string]*T
func (*MockedProperties[T]) UnmarshalJSON ¶
func (p *MockedProperties[T]) UnmarshalJSON(data []byte) error
func (MockedProperties[T]) Values ¶
func (p MockedProperties[T]) Values() []*T
type MockedPropertiesAccounts ¶
type MockedPropertiesAccounts struct { MockedProperties[MockedAccountProperties] }
type MockedPropertiesClients ¶
type MockedPropertiesClients struct { MockedProperties[MockedClientProperties] }
type MockedPropertiesFederatedUsers ¶
type MockedPropertiesFederatedUsers struct { MockedProperties[MockedFederatedUserProperties] }
type MockedPropertiesTenants ¶
type MockedPropertiesTenants struct { MockedProperties[MockedTenantProperties] }
type MockedProviderStore ¶
type MockedProviderStore struct{}
func (MockedProviderStore) LoadProviderById ¶
type MockedSecurityDetails ¶
type MockedSecurityDetails struct {
SecurityDetailsMock
}
MockedSecurityDetails implements - security.AuthenticationDetails - security.ProxiedUserDetails - security.UserDetails - security.TenantDetails - security.ProviderDetails - security.KeyValueDetails - internal.TenantAccessDetails
func NewMockedSecurityDetails ¶
func NewMockedSecurityDetails(opts ...SecurityMockOptions) *MockedSecurityDetails
func (*MockedSecurityDetails) AccountType ¶
func (d *MockedSecurityDetails) AccountType() security.AccountType
func (*MockedSecurityDetails) AssignedTenantIds
deprecated
func (d *MockedSecurityDetails) AssignedTenantIds() utils.StringSet
Deprecated: the interface is deprecated
func (*MockedSecurityDetails) AuthenticationTime ¶
func (d *MockedSecurityDetails) AuthenticationTime() time.Time
func (*MockedSecurityDetails) CurrencyCode ¶
func (d *MockedSecurityDetails) CurrencyCode() string
func (*MockedSecurityDetails) EffectiveAssignedTenantIds ¶
func (d *MockedSecurityDetails) EffectiveAssignedTenantIds() utils.StringSet
func (*MockedSecurityDetails) Email ¶
func (d *MockedSecurityDetails) Email() string
func (*MockedSecurityDetails) ExpiryTime ¶
func (d *MockedSecurityDetails) ExpiryTime() time.Time
func (*MockedSecurityDetails) FirstName ¶
func (d *MockedSecurityDetails) FirstName() string
func (*MockedSecurityDetails) IssueTime ¶
func (d *MockedSecurityDetails) IssueTime() time.Time
func (*MockedSecurityDetails) LastName ¶
func (d *MockedSecurityDetails) LastName() string
func (*MockedSecurityDetails) LocaleCode ¶
func (d *MockedSecurityDetails) LocaleCode() string
func (*MockedSecurityDetails) OriginalUsername ¶
func (d *MockedSecurityDetails) OriginalUsername() string
func (*MockedSecurityDetails) Permissions ¶
func (d *MockedSecurityDetails) Permissions() utils.StringSet
func (*MockedSecurityDetails) ProviderDescription ¶
func (d *MockedSecurityDetails) ProviderDescription() string
func (*MockedSecurityDetails) ProviderDisplayName ¶
func (d *MockedSecurityDetails) ProviderDisplayName() string
func (*MockedSecurityDetails) ProviderEmail ¶
func (d *MockedSecurityDetails) ProviderEmail() string
func (*MockedSecurityDetails) ProviderId ¶
func (d *MockedSecurityDetails) ProviderId() string
func (*MockedSecurityDetails) ProviderName ¶
func (d *MockedSecurityDetails) ProviderName() string
func (*MockedSecurityDetails) ProviderNotificationType ¶
func (d *MockedSecurityDetails) ProviderNotificationType() string
func (*MockedSecurityDetails) Proxied ¶
func (d *MockedSecurityDetails) Proxied() bool
func (*MockedSecurityDetails) Roles ¶
func (d *MockedSecurityDetails) Roles() utils.StringSet
func (*MockedSecurityDetails) TenantExternalId ¶
func (d *MockedSecurityDetails) TenantExternalId() string
func (*MockedSecurityDetails) TenantId ¶
func (d *MockedSecurityDetails) TenantId() string
func (*MockedSecurityDetails) TenantSuspended ¶
func (d *MockedSecurityDetails) TenantSuspended() bool
func (*MockedSecurityDetails) UserId ¶
func (d *MockedSecurityDetails) UserId() string
func (*MockedSecurityDetails) Username ¶
func (d *MockedSecurityDetails) Username() string
func (*MockedSecurityDetails) Value ¶
func (d *MockedSecurityDetails) Value(s string) (interface{}, bool)
func (*MockedSecurityDetails) Values ¶
func (d *MockedSecurityDetails) Values() map[string]interface{}
type MockedSessionStore ¶
func (*MockedSessionStore) AddToPrincipalIndex ¶
func (ss *MockedSessionStore) AddToPrincipalIndex(principal string, s *session.Session) error
func (*MockedSessionStore) ChangeId ¶
func (ss *MockedSessionStore) ChangeId(s *session.Session) error
func (*MockedSessionStore) FindByPrincipalName ¶
func (*MockedSessionStore) Invalidate ¶
func (ss *MockedSessionStore) Invalidate(sessions ...*session.Session) error
func (*MockedSessionStore) InvalidateByPrincipalName ¶
func (ss *MockedSessionStore) InvalidateByPrincipalName(principal, sessionName string) error
func (*MockedSessionStore) New ¶
func (ss *MockedSessionStore) New(name string) (*session.Session, error)
func (*MockedSessionStore) Options ¶
func (ss *MockedSessionStore) Options() *session.Options
func (*MockedSessionStore) RemoveFromPrincipalIndex ¶
func (ss *MockedSessionStore) RemoveFromPrincipalIndex(_ string, s *session.Session) error
func (*MockedSessionStore) WithContext ¶
func (ss *MockedSessionStore) WithContext(_ context.Context) session.Store
type MockedTenantProperties ¶
type MockedTenantStore ¶
type MockedTenantStore struct {
// contains filtered or unexported fields
}
func NewMockedTenantStore ¶
func NewMockedTenantStore(props ...*MockedTenantProperties) *MockedTenantStore
func (*MockedTenantStore) LoadTenantByExternalId ¶
func (*MockedTenantStore) LoadTenantById ¶
type MockedToken ¶
type MockedToken struct { MockedTokenInfo Token string ExpTime time.Time `json:"-"` IssTime time.Time `json:"-"` }
MockedToken implements oauth2.AccessToken
func (*MockedToken) Details ¶
func (mt *MockedToken) Details() map[string]interface{}
func (*MockedToken) Expired ¶
func (mt *MockedToken) Expired() bool
func (*MockedToken) ExpiryTime ¶
func (mt *MockedToken) ExpiryTime() time.Time
func (*MockedToken) IssueTime ¶
func (mt *MockedToken) IssueTime() time.Time
func (MockedToken) MarshalText ¶
func (mt MockedToken) MarshalText() (text []byte, err error)
func (*MockedToken) RefreshToken ¶
func (mt *MockedToken) RefreshToken() oauth2.RefreshToken
func (*MockedToken) Scopes ¶
func (mt *MockedToken) Scopes() utils.StringSet
func (MockedToken) String ¶
func (mt MockedToken) String() string
func (*MockedToken) Type ¶
func (mt *MockedToken) Type() oauth2.TokenType
func (*MockedToken) UnmarshalText ¶
func (mt *MockedToken) UnmarshalText(text []byte) error
func (*MockedToken) Value ¶
func (mt *MockedToken) Value() string
type MockedTokenInfo ¶
type MockedTokenRevoker ¶
type MockedTokenRevoker interface { Revoke(value string) RevokeAll() }
type MockingProperties ¶
type MockingProperties struct { Accounts MockedPropertiesAccounts `json:"accounts"` Tenants MockedPropertiesTenants `json:"tenants"` Clients MockedPropertiesClients `json:"clients"` FederatedUsers MockedPropertiesFederatedUsers `json:"fed-users"` }
func BindMockingProperties ¶
func BindMockingProperties(ctx *bootstrap.ApplicationContext) (MockingProperties, error)
BindMockingProperties is a FX provider that bind all mocked properties as MockingProperties. All mocked properties should be under the yaml section defined as MockingPropertiesPrefix e.g. "mocking.accounts" defines all account mocks
type MocksDIOut ¶
type MocksDIOut struct { fx.Out AuthClient seclient.AuthenticationClient TokenReader oauth2.TokenStoreReader TokenRevoker MockedTokenRevoker }
func ProvideScopeMocks ¶
func ProvideScopeMocks(ctx *bootstrap.ApplicationContext) MocksDIOut
ProvideScopeMocks is for internal usage. Exported for cross-package reference Try use WithMockedScopes instead
type SecurityContextOption ¶
type SecurityContextOption struct { // Authentication override any other fields Authentication security.Authentication }
type SecurityContextOptions ¶
type SecurityContextOptions func(opt *SecurityContextOption)
func Authentication ¶
func Authentication(auth security.Authentication) SecurityContextOptions
Authentication provides a SecurityContextOptions that sets the authentication to the given value
func MockedAuthentication ¶
func MockedAuthentication(opts ...SecurityMockOptions) SecurityContextOptions
MockedAuthentication provides a SecurityContextOptions that sets the authentication to a mocked oauth2.Authentication
type SecurityDetailsMock ¶
type SecurityDetailsMock struct { Username string UserId string AccountType security.AccountType TenantExternalId string TenantId string ProviderName string ProviderId string ProviderDisplayName string ProviderDescription string ProviderEmail string ProviderNotificationType string AccessToken string Exp time.Time Iss time.Time Permissions utils.StringSet Roles utils.StringSet Tenants utils.StringSet OrigUsername string UserFirstName string UserLastName string KVs map[string]interface{} ClientID string Scopes utils.StringSet OAuth2GrantType string OAuth2ResponseTypes utils.StringSet OAuth2Parameters map[string]string OAuth2Extensions map[string]interface{} }
type SecurityMockOptions ¶
type SecurityMockOptions func(d *SecurityDetailsMock)
Source Files ¶
- configurer.go
- mocks_account.go
- mocks_account_store.go
- mocks_auth_middleware.go
- mocks_client_store.go
- mocks_details.go
- mocks_idp_manager.go
- mocks_properties.go
- mocks_provider_store.go
- mocks_seclient.go
- mocks_session.go
- mocks_tenant_store.go
- mocks_token.go
- mocks_token_base.go
- mocks_token_store.go
- scope.go
- security.go