sectest

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MockedProviderID   = "test-provider"
	MockedProviderName = "test-provider"
)
View Source
const (
	MockingPropertiesPrefix = "mocking"
)

Variables

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 MockedSessionStoreDecorator

func MockedSessionStoreDecorator(_ session.Store) session.Store

func NewMockedSessionStore

func NewMockedSessionStore() session.Store

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

func WithMockedScopes(mocksConfigFS ...embed.FS) test.Options

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

type Feature

type Feature struct {
	MWOrder  int
	MWMocker MWMocker
	Override bool
}

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 (f *Feature) ForceOverride(override bool) *Feature

func (*Feature) Identifier

func (f *Feature) Identifier() security.FeatureIdentifier

func (*Feature) MWMockFunc

func (f *Feature) MWMockFunc(mocker MWMockFunc) *Feature

func (*Feature) Mocker

func (f *Feature) Mocker(mocker MWMocker) *Feature

func (*Feature) Order

func (f *Feature) Order(mwOrder int) *Feature

type FeatureConfigurer

type FeatureConfigurer struct {
}

func (*FeatureConfigurer) Apply

type IdpManagerMockOption

type IdpManagerMockOption struct {
	PasswdIDPDomain string
}

type IdpManagerMockOptions

type IdpManagerMockOptions func(opt *IdpManagerMockOption)

type MWMockContext

type MWMockContext struct {
	Request *http.Request
}

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

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 (m *MockAccountStore) LoadAccountById(_ context.Context, id interface{}) (security.Account, error)

func (*MockAccountStore) LoadAccountByUsername

func (m *MockAccountStore) LoadAccountByUsername(_ context.Context, username string) (security.Account, error)

func (*MockAccountStore) LoadLockingRules

func (*MockAccountStore) LoadPwdAgingRules

func (*MockAccountStore) Save

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

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 (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 (MockedAccountAuthentication) Principal

func (a MockedAccountAuthentication) Principal() interface{}

func (MockedAccountAuthentication) State

type MockedAccountDetails

type MockedAccountDetails struct {
	UserId          string
	Type            security.AccountType
	Username        string
	Password        string
	TenantId        string
	DefaultTenant   string
	AssignedTenants utils.StringSet
	Permissions     utils.StringSet
}

type MockedAccountModifier

type MockedAccountModifier func(acct security.Account) security.Account

MockedAccountModifier works with MockAccountStore. It allows tests to modify the mocked account after load

type MockedAccountProperties

type MockedAccountProperties struct {
	UserId        string   `json:"id"` // optional field
	Username      string   `json:"username"`
	Password      string   `json:"password"`
	DefaultTenant string   `json:"default-tenant"`
	Tenants       []string `json:"tenants"`
	Perms         []string `json:"permissions"`
}

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 (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"`
	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 (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

type MockedProperties

type MockedProperties[T any] map[string]*T

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

func (s MockedProviderStore) LoadProviderById(_ context.Context, id string) (*security.Provider, error)

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 (*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

type MockedSessionStore struct {
	Sessions map[string]*session.Session
}

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 (ss *MockedSessionStore) FindByPrincipalName(principal string, sessionName string) ([]*session.Session, error)

func (*MockedSessionStore) Get

func (ss *MockedSessionStore) Get(id string, name string) (s *session.Session, err error)

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) Save

func (ss *MockedSessionStore) Save(s *session.Session) error

func (*MockedSessionStore) WithContext

func (ss *MockedSessionStore) WithContext(_ context.Context) session.Store

type MockedTenantProperties

type MockedTenantProperties struct {
	ID         string              `json:"id"` // optional field
	ExternalId string              `json:"external-id"`
	Perms      map[string][]string `json:"permissions"` // permissions are MockedAccountProperties.UserId to permissions
}

type MockedTenantStore

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

func NewMockedTenantStore

func NewMockedTenantStore(props ...*MockedTenantProperties) *MockedTenantStore

func (*MockedTenantStore) LoadTenantByExternalId

func (s *MockedTenantStore) LoadTenantByExternalId(_ context.Context, name string) (*security.Tenant, error)

func (*MockedTenantStore) LoadTenantById

func (s *MockedTenantStore) LoadTenantById(_ context.Context, id string) (*security.Tenant, error)

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 MockedTokenInfo struct {
	ClientID    string   `json:"ClientID"`
	UName       string   `json:"UName"`
	UID         string   `json:"UID"`
	TID         string   `json:"TID"`
	TExternalId string   `json:"TExternalId"`
	OrigU       string   `json:"OrigU"`
	Exp         int64    `json:"Exp"`
	Iss         int64    `json:"Iss"`
	Scopes      []string `json:"Scopes"`
}

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 MockedAuthentication

func MockedAuthentication(opts ...SecurityMockOptions) SecurityContextOptions

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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