Documentation ¶
Index ¶
- Constants
- Variables
- func Clear(ctx context.Context) error
- func DetermineAuthenticationTime(_ context.Context, userAuth Authentication) (authTime time.Time)
- func GetUsername(userAuth Authentication) (string, error)
- func GobRegister()
- func HasAccessToTenant(ctx context.Context, tenantId string) bool
- func HasErrorAccessingTenant(ctx context.Context, tenantId string) error
- func HasPermissions(auth Authentication, permissions ...string) bool
- func IsBeingAuthenticated(from, to Authentication) bool
- func IsBeingUnAuthenticated(from, to Authentication) bool
- func IsFullyAuthenticated(auth Authentication) bool
- func IsResponseWritten(rw http.ResponseWriter) bool
- func IsTenantValid(ctx context.Context, tenantId string) bool
- func MustClear(ctx context.Context)
- func MustSet(ctx context.Context, auth Authentication)
- func NewAccessControlError(value interface{}, causes ...interface{}) error
- func NewAccessDeniedError(value interface{}, causes ...interface{}) error
- func NewAccountStatusError(value interface{}, causes ...interface{}) error
- func NewAuthenticationError(value interface{}, causes ...interface{}) error
- func NewAuthenticationWarningError(value interface{}, causes ...interface{}) error
- func NewAuthenticatorNotAvailableError(value interface{}, causes ...interface{}) error
- func NewBadCredentialsError(value interface{}, causes ...interface{}) error
- func NewCredentialsExpiredError(value interface{}, causes ...interface{}) error
- func NewErrorSubType(code int64, e error) error
- func NewErrorType(code int64, e error) error
- func NewExternalSamlAuthenticationError(value interface{}, causes ...interface{}) error
- func NewInsufficientAuthError(value interface{}, causes ...interface{}) error
- func NewInternalAuthenticationError(value interface{}, causes ...interface{}) error
- func NewInternalError(text string, causes ...interface{}) error
- func NewInvalidCsrfTokenError(value interface{}, causes ...interface{}) error
- func NewMaxAttemptsReachedError(value interface{}, causes ...interface{}) error
- func NewMissingCsrfTokenError(value interface{}, causes ...interface{}) error
- func NewUsernameNotFoundError(value interface{}, causes ...interface{}) error
- func NoopHandlerFunc() gin.HandlerFunc
- func Set(ctx context.Context, auth Authentication) error
- func Use()
- func WriteError(ctx context.Context, r *http.Request, rw http.ResponseWriter, code int, ...)
- func WriteErrorAsHtml(ctx context.Context, rw http.ResponseWriter, code int, err error)
- func WriteErrorAsJson(ctx context.Context, rw http.ResponseWriter, code int, err error)
- type AccessDeniedHandler
- type Account
- type AccountFinalizeOption
- type AccountFinalizeOptions
- type AccountFinalizer
- type AccountHistory
- type AccountLockingRule
- type AccountMetadata
- type AccountPwdAgingRule
- type AccountStore
- type AccountTenancy
- type AccountType
- type AccountUpdater
- type AcctDetails
- type AcctLockingRule
- type AcctMetadata
- type AcctPasswordPolicy
- type AnonymousAuthentication
- type AnonymousAuthenticator
- type AnonymousCandidate
- type Authentication
- type AuthenticationDetails
- type AuthenticationEntryPoint
- type AuthenticationErrorHandler
- type AuthenticationState
- type AuthenticationSuccessHandler
- type Authenticator
- type AuthenticatorBuilder
- type AutoCreateUserDetails
- type Candidate
- type CodedError
- type CompositeAccessDeniedHandler
- func (h *CompositeAccessDeniedHandler) Add(handler AccessDeniedHandler) *CompositeAccessDeniedHandler
- func (h *CompositeAccessDeniedHandler) HandleAccessDenied(c context.Context, r *http.Request, rw http.ResponseWriter, err error)
- func (h *CompositeAccessDeniedHandler) Handlers() []AccessDeniedHandler
- func (h *CompositeAccessDeniedHandler) Merge(composite *CompositeAccessDeniedHandler) *CompositeAccessDeniedHandler
- func (h *CompositeAccessDeniedHandler) Size() int
- type CompositeAuthenticationErrorHandler
- func (h *CompositeAuthenticationErrorHandler) Add(handler AuthenticationErrorHandler) *CompositeAuthenticationErrorHandler
- func (h *CompositeAuthenticationErrorHandler) HandleAuthenticationError(c context.Context, r *http.Request, rw http.ResponseWriter, err error)
- func (h *CompositeAuthenticationErrorHandler) Handlers() []AuthenticationErrorHandler
- func (h *CompositeAuthenticationErrorHandler) Merge(composite *CompositeAuthenticationErrorHandler) *CompositeAuthenticationErrorHandler
- func (h *CompositeAuthenticationErrorHandler) Size() int
- type CompositeAuthenticationSuccessHandler
- func (h *CompositeAuthenticationSuccessHandler) Add(handler AuthenticationSuccessHandler) *CompositeAuthenticationSuccessHandler
- func (h *CompositeAuthenticationSuccessHandler) HandleAuthenticationSuccess(c context.Context, r *http.Request, rw http.ResponseWriter, ...)
- func (h *CompositeAuthenticationSuccessHandler) Handlers() []AuthenticationSuccessHandler
- func (h *CompositeAuthenticationSuccessHandler) Merge(composite *CompositeAuthenticationSuccessHandler) *CompositeAuthenticationSuccessHandler
- type CompositeAuthenticator
- func (a *CompositeAuthenticator) Add(authenticator Authenticator) *CompositeAuthenticator
- func (a *CompositeAuthenticator) Authenticate(ctx context.Context, candidate Candidate) (auth Authentication, err error)
- func (a *CompositeAuthenticator) Authenticators() []Authenticator
- func (a *CompositeAuthenticator) Merge(composite *CompositeAuthenticator) *CompositeAuthenticator
- type CompositeAuthenticatorBuilder
- type CompositeErrorHandler
- func (h *CompositeErrorHandler) Add(handler ErrorHandler) *CompositeErrorHandler
- func (h *CompositeErrorHandler) HandleError(c context.Context, r *http.Request, rw http.ResponseWriter, err error)
- func (h *CompositeErrorHandler) Merge(composite *CompositeErrorHandler) *CompositeErrorHandler
- func (h *CompositeErrorHandler) Size() int
- type Configurer
- type ConfigurerFunc
- type ContextDetails
- type ContextDetailsStore
- type CookieProperties
- type DefaultAccessDeniedHandler
- type DefaultAccount
- func (a *DefaultAccount) CacheableCopy() Account
- func (a *DefaultAccount) Credentials() interface{}
- func (a *DefaultAccount) CurrencyCode() string
- func (a *DefaultAccount) DefaultDesignatedTenantId() string
- func (a *DefaultAccount) DesignatedTenantIds() []string
- func (a *DefaultAccount) Disabled() bool
- func (a *DefaultAccount) Email() string
- func (a *DefaultAccount) FirstName() string
- func (a *DefaultAccount) GracefulAuthCount() int
- func (a *DefaultAccount) GracefulAuthLimit() int
- func (a *DefaultAccount) ID() interface{}
- func (a *DefaultAccount) IncrementGracefulAuthCount()
- func (a *DefaultAccount) LastLoginTime() time.Time
- func (a *DefaultAccount) LastName() string
- func (a *DefaultAccount) LocaleCode() string
- func (a *DefaultAccount) LockAccount()
- func (a *DefaultAccount) Locked() bool
- func (a *DefaultAccount) LockoutDuration() time.Duration
- func (a *DefaultAccount) LockoutEnabled() bool
- func (a *DefaultAccount) LockoutFailuresInterval() time.Duration
- func (a *DefaultAccount) LockoutFailuresLimit() int
- func (a *DefaultAccount) LockoutPolicyName() string
- func (a *DefaultAccount) LockoutTime() time.Time
- func (a *DefaultAccount) LoginFailures() []time.Time
- func (a *DefaultAccount) Permissions() []string
- func (a *DefaultAccount) PwdAgingPolicyName() string
- func (a *DefaultAccount) PwdAgingRuleEnforced() bool
- func (a *DefaultAccount) PwdChangedTime() time.Time
- func (a *DefaultAccount) PwdExpiryWarningPeriod() time.Duration
- func (a *DefaultAccount) PwdMaxAge() time.Duration
- func (a *DefaultAccount) RecordFailure(failureTime time.Time, limit int)
- func (a *DefaultAccount) RecordSuccess(loginTime time.Time)
- func (a *DefaultAccount) ResetFailedAttempts()
- func (a *DefaultAccount) ResetGracefulAuthCount()
- func (a *DefaultAccount) RoleNames() []string
- func (a *DefaultAccount) SerialFailedAttempts() int
- func (a *DefaultAccount) TenantId() string
- func (a *DefaultAccount) Type() AccountType
- func (a *DefaultAccount) UnlockAccount()
- func (a *DefaultAccount) UseMFA() bool
- func (a *DefaultAccount) Username() string
- func (a *DefaultAccount) Value(key string) interface{}
- type DefaultAuthenticationErrorHandler
- type DefaultErrorHandler
- type DefaultIssuer
- func (i DefaultIssuer) BuildUrl(options ...UrlBuilderOptions) (*url.URL, error)
- func (i DefaultIssuer) ContextPath() string
- func (i DefaultIssuer) Domain() string
- func (i DefaultIssuer) Identifier() string
- func (i DefaultIssuer) IsSecured() bool
- func (i DefaultIssuer) LevelOfAssurance(level int) string
- func (i DefaultIssuer) Port() int
- func (i DefaultIssuer) Protocol() string
- type DefaultIssuerDetails
- type EmptyAuthentication
- type ErrorHandler
- type Feature
- type FeatureConfigurer
- type FeatureIdentifier
- type FeatureModifier
- type FeatureRegistrar
- type FederatedAccountStore
- type GlobalSettingReader
- type Initializer
- type Issuer
- type KeyValueDetails
- type MiddlewareTemplate
- type Permissions
- type Provider
- type ProviderDetails
- type ProviderStore
- type ProxiedUserDetails
- type Registrar
- type SessionProperties
- type SimpleMappingTemplate
- type Tenant
- type TenantDetails
- type TenantStore
- type TimeoutSupportProperties
- type UrlBuilderOption
- type UrlBuilderOptions
- type UserDetails
- type WebSecurity
- type WebSecurityMappingBuilder
- type WebSecurityReader
Constants ¶
const ( MinSecurityPrecedence = bootstrap.SecurityPrecedence MaxSecurityPrecedence = bootstrap.SecurityPrecedence + bootstrap.FrameworkModulePrecedenceBandwidth )
const ( // CompatibilityReference /** * Note about compatibility reference: * * Whenever an incompatible security model changes (in terms of serialization) is made to the class, * we should update the version tag. * * For now we use project version + incremental number as tag, but we could also use timestamp or date */ CompatibilityReference = "4000" CompatibilityReferenceTag = "SMCR" // SMCR = Security Model Compatibility Ref )
const ( // SpecialPermissionAccessAllTenant // Deprecated: this permission is no longer sufficient to determine tenancy access // in the case of an oauth2 authentication where the client is also tenanted. // We are deprecating the use case where a user does not select a tenant. SpecialPermissionAccessAllTenant = "ACCESS_ALL_TENANTS" SpecialPermissionAPIAdmin = "IS_API_ADMIN" SpecialPermissionSwitchTenant = "SWITCH_TENANT" SpecialPermissionSwitchUser = "VIEW_OPERATOR_LOGIN_AS_CUSTOMER" )
const ( DetailsKeyAuthWarning = "AuthWarning" DetailsKeyAuthTime = "AuthTime" DetailsKeyAuthMethod = "AuthMethod" DetailsKeyMFAApplied = "MFAApplied" DetailsKeySessionId = "SessionId" )
const ( AuthMethodPassword = "Password" AuthMethodExternalSaml = "ExtSAML" AuthMethodExternalOpenID = "ExtOpenID" )
const ()
const ( MWOrderSessionHandling MWOrderAuthPersistence MWOrderErrorHandling MWOrderCsrfHandling MWOrderOAuth2AuthValidation MWOrderSAMLMetadataRefresh MWOrderPreAuth MWOrderBasicAuth MWOrderFormLogout MWOrderFormAuth MWOrderOAuth2TokenAuth // ... more MW goes here MWOrderAccessControl = LowestMiddlewareOrder - 200 MWOrderOAuth2Endpoints = MWOrderAccessControl + 100 MWOrderSamlAuthEndpoints = MWOrderAccessControl + 100 )
Middleware Orders
const ( FeatureOrderOAuth2ClientAuth FeatureOrderAuthenticator FeatureOrderBasicAuth FeatureOrderFormLogin FeatureOrderSamlLogin FeatureOrderSamlLogout FeatureOrderLogout FeatureOrderOAuth2TokenEndpoint FeatureOrderOAuth2AuthorizeEndpoint FeatureOrderSamlAuthorizeEndpoint FeatureOrderOAuth2TokenAuth FeatureOrderCsrf FeatureOrderAccess FeatureOrderSession FeatureOrderRequestCache // ... more Feature goes here FeatureOrderErrorHandling = order.Lowest - 200 )
Feature Orders, if feature is not listed here, it's unordered. Unordered features are applied at last
const ( HandlerOrderChangeSession = iota * 100 HandlerOrderConcurrentSession )
AuthenticationSuccessHandler Orders, if not listed here, it's unordered. Unordered handlers are applied at last
const ( CsrfParamName = "_csrf" CsrfHeaderName = "X-CSRF-TOKEN" )
CSRF headers and parameter names - shared by CSRF feature and session feature's request cache
const ( HighestMiddlewareOrder = int(-1<<18 + 1) // -0x3ffff = -262143 LowestMiddlewareOrder = HighestMiddlewareOrder + 0xffff // -0x30000 = -196608 )
const ( StateAnonymous = AuthenticationState(iota) StatePrincipalKnown StateAuthenticated )
const ( ErrorTypeCodeAuthentication = Reserved + iota<<errorutils.ErrorTypeOffset ErrorTypeCodeAccessControl ErrorTypeCodeInternal ErrorTypeCodeOAuth2 ErrorTypeCodeSaml ErrorTypeCodeOidc ErrorTypeCodeTenancy )
All "Type" values are used as mask
const ( ErrorSubTypeCodeInternal = ErrorTypeCodeAuthentication + iota<<errorutils.ErrorSubTypeOffset ErrorSubTypeCodeUsernamePasswordAuth ErrorSubTypeCodeExternalSamlAuth ErrorSubTypeCodeAuthWarning )
All "SubType" values are used as mask sub types of ErrorTypeCodeAuthentication
const ( ErrorCodeUsernameNotFound = ErrorSubTypeCodeUsernamePasswordAuth + iota ErrorCodeBadCredentials ErrorCodeCredentialsExpired ErrorCodeMaxAttemptsReached ErrorCodeAccountStatus )
ErrorSubTypeCodeUsernamePasswordAuth
const ( ErrorSubTypeCodeAccessDenied = ErrorTypeCodeAccessControl + iota<<errorutils.ErrorSubTypeOffset ErrorSubTypeCodeInsufficientAuth ErrorSubTypeCodeCsrf )
All "SubType" values are used as mask sub types of ErrorTypeCodeAccessControl
const ( ErrorSubTypeCodeTenantInvalid = ErrorTypeCodeTenancy + iota<<errorutils.ErrorSubTypeOffset ErrorSubTypeCodeTenantAccessDenied )
All "SubType" values are used as mask sub types of ErrorTypeCodeTenancy
const ( ErrorCodeMissingCsrfToken = ErrorSubTypeCodeCsrf + iota ErrorCodeInvalidCsrfToken )
const (
ErrorCodeAuthenticatorNotAvailable = ErrorSubTypeCodeInternal + iota
)
ErrorSubTypeCodeInternal
const ( // security reserved Reserved = 11 << errorutils.ReservedOffset )
const SessionPropertiesPrefix = "security.session"
const (
SpecialTenantIdWildcard = "*"
)
const TimeoutPropertiesPrefix = "security.timeout-support"
Variables ¶
var ( ErrorTypeSecurity = NewErrorCategory(Reserved, errors.New("error type: security")) ErrorTypeAuthentication = NewErrorType(ErrorTypeCodeAuthentication, errors.New("error type: authentication")) ErrorTypeAccessControl = NewErrorType(ErrorTypeCodeAccessControl, errors.New("error type: access control")) ErrorTypeInternal = NewErrorType(ErrorTypeCodeInternal, errors.New("error type: internal")) ErrorTypeSaml = NewErrorType(ErrorTypeCodeSaml, errors.New("error type: saml")) ErrorTypeOidc = NewErrorType(ErrorTypeCodeOidc, errors.New("error type: oidc")) ErrorSubTypeInternalError = NewErrorSubType(ErrorSubTypeCodeInternal, errors.New("error sub-type: internal")) ErrorSubTypeUsernamePasswordAuth = NewErrorSubType(ErrorSubTypeCodeUsernamePasswordAuth, errors.New("error sub-type: internal")) ErrorSubTypeExternalSamlAuth = NewErrorSubType(ErrorSubTypeCodeExternalSamlAuth, errors.New("error sub-type: external saml")) ErrorSubTypeAuthWarning = NewErrorSubType(ErrorSubTypeCodeAuthWarning, errors.New("error sub-type: auth warning")) ErrorSubTypeAccessDenied = NewErrorSubType(ErrorSubTypeCodeAccessDenied, errors.New("error sub-type: access denied")) ErrorSubTypeInsufficientAuth = NewErrorSubType(ErrorSubTypeCodeInsufficientAuth, errors.New("error sub-type: insufficient auth")) ErrorSubTypeCsrf = NewErrorSubType(ErrorSubTypeCodeCsrf, errors.New("error sub-type: csrf")) )
ErrorTypes, can be used in errors.Is
var ( ErrorInvalidTenantId = NewCodedError(ErrorSubTypeCodeTenantInvalid, "Invalid tenant Id") ErrorTenantAccessDenied = NewCodedError(ErrorSubTypeCodeTenantAccessDenied, "No Access to the tenant") )
Concrete error, can be used in errors.Is for exact match
var Module = &bootstrap.Module{ Name: "security", Precedence: MaxSecurityPrecedence, Options: []fx.Option{ fx.Provide(provideSecurityInitialization), fx.Invoke(initialize), }, }
Functions ¶
func Clear ¶
Clear attempt to set security context as "unauthenticated". Return error if not possible
func DetermineAuthenticationTime ¶
func DetermineAuthenticationTime(_ context.Context, userAuth Authentication) (authTime time.Time)
func GetUsername ¶
func GetUsername(userAuth Authentication) (string, error)
func GobRegister ¶
func GobRegister()
func HasAccessToTenant ¶
HasAccessToTenant if no error return true, otherwise return false
func HasErrorAccessingTenant ¶
HasErrorAccessingTenant
if the tenantId is not valid, this method will return false, otherwise the following checks are applied in order 1. If the user has ACCESS_ALL_TENANT permission, this method will return true 2. If the user's designated tenants include the give tenant, this method will return true 3. If the tenant hierarchy is loaded, this method will also check if any of the given tenant's ancestor is in the user's designated tenant. If yes, this method will return true. otherwise, this method return false.
func HasPermissions ¶
func HasPermissions(auth Authentication, permissions ...string) bool
func IsBeingAuthenticated ¶
func IsBeingAuthenticated(from, to Authentication) bool
func IsBeingUnAuthenticated ¶
func IsBeingUnAuthenticated(from, to Authentication) bool
func IsFullyAuthenticated ¶
func IsFullyAuthenticated(auth Authentication) bool
func IsResponseWritten ¶
func IsResponseWritten(rw http.ResponseWriter) bool
func IsTenantValid ¶
IsTenantValid In most cases, the HasAccessToTenant should be used instead. It checks both the tenant's validity and whether the user has access to it
func MustSet ¶
func MustSet(ctx context.Context, auth Authentication)
MustSet is the panicking version of Set.
func NewAccessControlError ¶
func NewAccessControlError(value interface{}, causes ...interface{}) error
func NewAccessDeniedError ¶
func NewAccessDeniedError(value interface{}, causes ...interface{}) error
func NewAccountStatusError ¶
func NewAccountStatusError(value interface{}, causes ...interface{}) error
func NewAuthenticationError ¶
func NewAuthenticationError(value interface{}, causes ...interface{}) error
func NewAuthenticationWarningError ¶
func NewAuthenticationWarningError(value interface{}, causes ...interface{}) error
func NewAuthenticatorNotAvailableError ¶
func NewAuthenticatorNotAvailableError(value interface{}, causes ...interface{}) error
func NewBadCredentialsError ¶
func NewBadCredentialsError(value interface{}, causes ...interface{}) error
func NewCredentialsExpiredError ¶
func NewCredentialsExpiredError(value interface{}, causes ...interface{}) error
func NewErrorSubType ¶
func NewErrorType ¶
func NewExternalSamlAuthenticationError ¶
func NewExternalSamlAuthenticationError(value interface{}, causes ...interface{}) error
func NewInsufficientAuthError ¶
func NewInsufficientAuthError(value interface{}, causes ...interface{}) error
func NewInternalAuthenticationError ¶
func NewInternalAuthenticationError(value interface{}, causes ...interface{}) error
func NewInternalError ¶
func NewInvalidCsrfTokenError ¶
func NewInvalidCsrfTokenError(value interface{}, causes ...interface{}) error
func NewMaxAttemptsReachedError ¶
func NewMaxAttemptsReachedError(value interface{}, causes ...interface{}) error
func NewMissingCsrfTokenError ¶
func NewMissingCsrfTokenError(value interface{}, causes ...interface{}) error
func NewUsernameNotFoundError ¶
func NewUsernameNotFoundError(value interface{}, causes ...interface{}) error
func NoopHandlerFunc ¶
func NoopHandlerFunc() gin.HandlerFunc
func Set ¶
func Set(ctx context.Context, auth Authentication) error
Set security context, return error if the given context is not backed by utils.MutableContext.
func WriteError ¶
func WriteErrorAsHtml ¶
func WriteErrorAsJson ¶
Types ¶
type AccessDeniedHandler ¶
type AccessDeniedHandler interface {
HandleAccessDenied(context.Context, *http.Request, http.ResponseWriter, error)
}
AccessDeniedHandler handles ErrorSubTypeAccessDenied
type Account ¶
type Account interface { ID() interface{} Type() AccountType Username() string Credentials() interface{} Permissions() []string Disabled() bool Locked() bool UseMFA() bool // CacheableCopy should returns a copy of Account that suitable for putting into cache. // e.g. the CacheableCopy should be able to be serialized and shouldn't contains Credentials or any reloadable content CacheableCopy() Account }
type AccountFinalizeOption ¶
type AccountFinalizeOption struct {
Tenant *Tenant // Tenant field can be nil
}
type AccountFinalizeOptions ¶
type AccountFinalizeOptions func(option *AccountFinalizeOption)
func FinalizeWithTenant ¶
func FinalizeWithTenant(tenant *Tenant) AccountFinalizeOptions
type AccountFinalizer ¶
type AccountFinalizer interface { // Finalize is a function that will allow a service to modify the account before it // is put into the security context. An example usage of this is to allow for per-tenant // permissions where a user can have different permissions depending on which tenant is selected. // // Note that the Account.ID and Account.Username should not be changed. If those fields are changed // an error will be reported. Finalize(ctx context.Context, account Account, options ...AccountFinalizeOptions) (Account, error) }
type AccountHistory ¶
type AccountLockingRule ¶
type AccountLockingRule interface { // LockoutPolicyName the name of locking rule LockoutPolicyName() string // LockoutEnabled indicate whether account locking is enabled LockoutEnabled() bool // LockoutDuration specify how long the account should be locked after consecutive login failures LockoutDuration() time.Duration // LockoutFailuresLimit specify how many consecutive login failures required to lock the account LockoutFailuresLimit() int // LockoutFailuresInterval specify how long between the first and the last login failures to be considered as consecutive login failures LockoutFailuresInterval() time.Duration }
type AccountMetadata ¶
type AccountPwdAgingRule ¶
type AccountPwdAgingRule interface { // PwdAgingPolicyName the name of password polcy PwdAgingPolicyName() string // PwdAgingRuleEnforced indicate whether password policy is enabled PwdAgingRuleEnforced() bool // PwdMaxAge specify how long a password is valid before expiry PwdMaxAge() time.Duration // PwdExpiryWarningPeriod specify how long before password expiry the system should warn user PwdExpiryWarningPeriod() time.Duration // GracefulAuthLimit specify how many logins is allowed after password expiry GracefulAuthLimit() int }
type AccountStore ¶
type AccountStore interface { // LoadAccountById find account by its Domain LoadAccountById(ctx context.Context, id interface{}) (Account, error) // LoadAccountByUsername find account by its Username LoadAccountByUsername(ctx context.Context, username string) (Account, error) // LoadLockingRules load given account's locking rule. It's recommended to cache the result LoadLockingRules(ctx context.Context, acct Account) (AccountLockingRule, error) // LoadPwdAgingRules load given account's password policy. It's recommended to cache the result LoadPwdAgingRules(ctx context.Context, acct Account) (AccountPwdAgingRule, error) // Save save the account if necessary Save(ctx context.Context, acct Account) error }
type AccountTenancy ¶
type AccountType ¶
type AccountType int
const ( AccountTypeUnknown AccountType = iota AccountTypeDefault AccountTypeApp AccountTypeFederated AccountTypeSystem )
func ParseAccountType ¶
func ParseAccountType(value interface{}) AccountType
func (AccountType) String ¶
func (t AccountType) String() string
type AccountUpdater ¶
type AcctDetails ¶
type AcctDetails struct { ID string Type AccountType Username string Credentials interface{} Permissions []string Disabled bool Locked bool UseMFA bool DefaultDesignatedTenantId string DesignatedTenantIds []string TenantId string LastLoginTime time.Time LoginFailures []time.Time SerialFailedAttempts int LockoutTime time.Time PwdChangedTime time.Time GracefulAuthCount int PolicyName string }
type AcctLockingRule ¶
type AcctMetadata ¶
type AcctPasswordPolicy ¶
type AnonymousAuthentication ¶
type AnonymousAuthentication struct {
// contains filtered or unexported fields
}
func (*AnonymousAuthentication) Details ¶
func (aa *AnonymousAuthentication) Details() interface{}
func (*AnonymousAuthentication) Permissions ¶
func (_ *AnonymousAuthentication) Permissions() Permissions
func (*AnonymousAuthentication) Principal ¶
func (aa *AnonymousAuthentication) Principal() interface{}
func (*AnonymousAuthentication) State ¶
func (_ *AnonymousAuthentication) State() AuthenticationState
type AnonymousAuthenticator ¶
type AnonymousAuthenticator struct{}
func (*AnonymousAuthenticator) Authenticate ¶
func (a *AnonymousAuthenticator) Authenticate(_ context.Context, candidate Candidate) (auth Authentication, err error)
type AnonymousCandidate ¶
type AnonymousCandidate map[string]interface{}
func (AnonymousCandidate) Credentials ¶
func (_ AnonymousCandidate) Credentials() interface{}
Credentials implements security.Candidate
func (AnonymousCandidate) Details ¶
func (ac AnonymousCandidate) Details() interface{}
Details implements security.Candidate
func (AnonymousCandidate) Principal ¶
func (ac AnonymousCandidate) Principal() interface{}
Principal implements security.Candidate
type Authentication ¶
type Authentication interface { Principal() interface{} Permissions() Permissions State() AuthenticationState Details() interface{} }
func Get ¶
func Get(ctx context.Context) Authentication
type AuthenticationDetails ¶
type AuthenticationEntryPoint ¶
type AuthenticationEntryPoint interface {
Commence(context.Context, *http.Request, http.ResponseWriter, error)
}
AuthenticationEntryPoint kicks off authentication process
type AuthenticationErrorHandler ¶
type AuthenticationErrorHandler interface {
HandleAuthenticationError(context.Context, *http.Request, http.ResponseWriter, error)
}
AuthenticationErrorHandler handles ErrorTypeAuthentication
type AuthenticationState ¶
type AuthenticationState int
type AuthenticationSuccessHandler ¶
type AuthenticationSuccessHandler interface {
HandleAuthenticationSuccess(c context.Context, r *http.Request, rw http.ResponseWriter, from, to Authentication)
}
AuthenticationSuccessHandler handles authentication success event The counterpart of this interface is AuthenticationErrorHandler
type Authenticator ¶
type Authenticator interface { // Authenticate function takes the Candidate and authenticate it. // if the Candidate type is not supported, return nil,nil // if the Candidate is rejected, non-nil error, and the returned Authentication is ignored Authenticate(context.Context, Candidate) (Authentication, error) }
func NewAuthenticator ¶
func NewAuthenticator(authenticators ...Authenticator) Authenticator
type AuthenticatorBuilder ¶
type AuthenticatorBuilder interface {
Build(context.Context) (Authenticator, error)
}
type AutoCreateUserDetails ¶
type Candidate ¶
type Candidate interface { Principal() interface{} Credentials() interface{} Details() interface{} }
type CodedError ¶
type CodedError struct {
errorutils.CodedError
}
CodedError implements errorutils.ErrorCoder, errorutils.ComparableErrorCoder, errorutils.NestedError
func NewCodedError ¶
func NewCodedError(code int64, e interface{}, causes ...interface{}) *CodedError
NewCodedError creates concrete error. it cannot be used as ErrorType or ErrorSubType comparison supported item are string, error, fmt.Stringer
func NewErrorCategory ¶
func NewErrorCategory(code int64, e error) *CodedError
type CompositeAccessDeniedHandler ¶
type CompositeAccessDeniedHandler struct {
// contains filtered or unexported fields
}
CompositeAccessDeniedHandler implement AccessDeniedHandler interface
func NewAccessDeniedHandler ¶
func NewAccessDeniedHandler(handlers ...AccessDeniedHandler) *CompositeAccessDeniedHandler
func (*CompositeAccessDeniedHandler) Add ¶
func (h *CompositeAccessDeniedHandler) Add(handler AccessDeniedHandler) *CompositeAccessDeniedHandler
func (*CompositeAccessDeniedHandler) HandleAccessDenied ¶
func (h *CompositeAccessDeniedHandler) HandleAccessDenied( c context.Context, r *http.Request, rw http.ResponseWriter, err error)
func (*CompositeAccessDeniedHandler) Handlers ¶
func (h *CompositeAccessDeniedHandler) Handlers() []AccessDeniedHandler
Handlers returns list of authentication handlers, any nested composite handlers are flattened
func (*CompositeAccessDeniedHandler) Merge ¶
func (h *CompositeAccessDeniedHandler) Merge(composite *CompositeAccessDeniedHandler) *CompositeAccessDeniedHandler
func (*CompositeAccessDeniedHandler) Size ¶
func (h *CompositeAccessDeniedHandler) Size() int
type CompositeAuthenticationErrorHandler ¶
type CompositeAuthenticationErrorHandler struct {
// contains filtered or unexported fields
}
CompositeAuthenticationErrorHandler implement AuthenticationErrorHandler interface
func NewAuthenticationErrorHandler ¶
func NewAuthenticationErrorHandler(handlers ...AuthenticationErrorHandler) *CompositeAuthenticationErrorHandler
func (*CompositeAuthenticationErrorHandler) Add ¶
func (h *CompositeAuthenticationErrorHandler) Add(handler AuthenticationErrorHandler) *CompositeAuthenticationErrorHandler
func (*CompositeAuthenticationErrorHandler) HandleAuthenticationError ¶
func (h *CompositeAuthenticationErrorHandler) HandleAuthenticationError( c context.Context, r *http.Request, rw http.ResponseWriter, err error)
func (*CompositeAuthenticationErrorHandler) Handlers ¶
func (h *CompositeAuthenticationErrorHandler) Handlers() []AuthenticationErrorHandler
Handlers returns list of authentication handlers, any nested composite handlers are flattened
func (*CompositeAuthenticationErrorHandler) Merge ¶
func (h *CompositeAuthenticationErrorHandler) Merge(composite *CompositeAuthenticationErrorHandler) *CompositeAuthenticationErrorHandler
func (*CompositeAuthenticationErrorHandler) Size ¶
func (h *CompositeAuthenticationErrorHandler) Size() int
type CompositeAuthenticationSuccessHandler ¶
type CompositeAuthenticationSuccessHandler struct {
// contains filtered or unexported fields
}
CompositeAuthenticationSuccessHandler implement AuthenticationSuccessHandler interface
func NewAuthenticationSuccessHandler ¶
func NewAuthenticationSuccessHandler(handlers ...AuthenticationSuccessHandler) *CompositeAuthenticationSuccessHandler
func (*CompositeAuthenticationSuccessHandler) Add ¶
func (h *CompositeAuthenticationSuccessHandler) Add(handler AuthenticationSuccessHandler) *CompositeAuthenticationSuccessHandler
func (*CompositeAuthenticationSuccessHandler) HandleAuthenticationSuccess ¶
func (h *CompositeAuthenticationSuccessHandler) HandleAuthenticationSuccess( c context.Context, r *http.Request, rw http.ResponseWriter, from, to Authentication)
func (*CompositeAuthenticationSuccessHandler) Handlers ¶
func (h *CompositeAuthenticationSuccessHandler) Handlers() []AuthenticationSuccessHandler
Handlers returns list of authentication handlers, any nested composite handlers are flattened
func (*CompositeAuthenticationSuccessHandler) Merge ¶
func (h *CompositeAuthenticationSuccessHandler) Merge(composite *CompositeAuthenticationSuccessHandler) *CompositeAuthenticationSuccessHandler
type CompositeAuthenticator ¶
type CompositeAuthenticator struct {
// contains filtered or unexported fields
}
CompositeAuthenticator implement Authenticator interface
func (*CompositeAuthenticator) Add ¶
func (a *CompositeAuthenticator) Add(authenticator Authenticator) *CompositeAuthenticator
func (*CompositeAuthenticator) Authenticate ¶
func (a *CompositeAuthenticator) Authenticate(ctx context.Context, candidate Candidate) (auth Authentication, err error)
func (*CompositeAuthenticator) Authenticators ¶
func (a *CompositeAuthenticator) Authenticators() []Authenticator
Authenticators returns list of authenticators, any nested composite handlers are flattened
func (*CompositeAuthenticator) Merge ¶
func (a *CompositeAuthenticator) Merge(composite *CompositeAuthenticator) *CompositeAuthenticator
type CompositeAuthenticatorBuilder ¶
type CompositeAuthenticatorBuilder struct {
// contains filtered or unexported fields
}
CompositeAuthenticatorBuilder implements AuthenticatorBuilder
func NewAuthenticatorBuilder ¶
func NewAuthenticatorBuilder() *CompositeAuthenticatorBuilder
func (*CompositeAuthenticatorBuilder) Build ¶
func (b *CompositeAuthenticatorBuilder) Build(c context.Context) (Authenticator, error)
type CompositeErrorHandler ¶
type CompositeErrorHandler struct {
// contains filtered or unexported fields
}
*CompositeErrorHandler implement ErrorHandler interface
func NewErrorHandler ¶
func NewErrorHandler(handlers ...ErrorHandler) *CompositeErrorHandler
func (*CompositeErrorHandler) Add ¶
func (h *CompositeErrorHandler) Add(handler ErrorHandler) *CompositeErrorHandler
func (*CompositeErrorHandler) HandleError ¶
func (h *CompositeErrorHandler) HandleError( c context.Context, r *http.Request, rw http.ResponseWriter, err error)
func (*CompositeErrorHandler) Merge ¶
func (h *CompositeErrorHandler) Merge(composite *CompositeErrorHandler) *CompositeErrorHandler
func (*CompositeErrorHandler) Size ¶
func (h *CompositeErrorHandler) Size() int
type Configurer ¶
type Configurer interface {
Configure(WebSecurity)
}
Configurer can be registered to Registrar. Each Configurer will get a newly created WebSecurity and is responsible to configure for customized security
type ConfigurerFunc ¶
type ConfigurerFunc func(ws WebSecurity)
func (ConfigurerFunc) Configure ¶
func (f ConfigurerFunc) Configure(ws WebSecurity)
type ContextDetails ¶
type ContextDetails interface { AuthenticationDetails KeyValueDetails }
type ContextDetailsStore ¶
type ContextDetailsStore interface { ReadContextDetails(ctx context.Context, key interface{}) (ContextDetails, error) SaveContextDetails(ctx context.Context, key interface{}, details ContextDetails) error RemoveContextDetails(ctx context.Context, key interface{}) error ContextDetailsExists(ctx context.Context, key interface{}) bool }
type CookieProperties ¶
type CookieProperties struct { Domain string `json:"domain"` MaxAge int `json:"max-age"` Secure bool `json:"secure"` HttpOnly bool `json:"http-only"` SameSiteString string `json:"same-site"` Path string `json:"path"` }
func (CookieProperties) SameSite ¶
func (cp CookieProperties) SameSite() http.SameSite
type DefaultAccessDeniedHandler ¶
type DefaultAccessDeniedHandler struct { }
DefaultAccessDeniedHandler implements AccessDeniedHandler
func (*DefaultAccessDeniedHandler) HandleAccessDenied ¶
func (h *DefaultAccessDeniedHandler) HandleAccessDenied(ctx context.Context, r *http.Request, rw http.ResponseWriter, err error)
type DefaultAccount ¶
type DefaultAccount struct { AcctDetails AcctLockingRule AcctPasswordPolicy AcctMetadata }
func NewUsernamePasswordAccount ¶
func NewUsernamePasswordAccount(details *AcctDetails) *DefaultAccount
func (*DefaultAccount) CacheableCopy ¶
func (a *DefaultAccount) CacheableCopy() Account
func (*DefaultAccount) Credentials ¶
func (a *DefaultAccount) Credentials() interface{}
func (*DefaultAccount) CurrencyCode ¶
func (a *DefaultAccount) CurrencyCode() string
func (*DefaultAccount) DefaultDesignatedTenantId ¶
func (a *DefaultAccount) DefaultDesignatedTenantId() string
func (*DefaultAccount) DesignatedTenantIds ¶
func (a *DefaultAccount) DesignatedTenantIds() []string
func (*DefaultAccount) Disabled ¶
func (a *DefaultAccount) Disabled() bool
func (*DefaultAccount) Email ¶
func (a *DefaultAccount) Email() string
func (*DefaultAccount) FirstName ¶
func (a *DefaultAccount) FirstName() string
func (*DefaultAccount) GracefulAuthCount ¶
func (a *DefaultAccount) GracefulAuthCount() int
func (*DefaultAccount) GracefulAuthLimit ¶
func (a *DefaultAccount) GracefulAuthLimit() int
func (*DefaultAccount) ID ¶
func (a *DefaultAccount) ID() interface{}
func (*DefaultAccount) IncrementGracefulAuthCount ¶
func (a *DefaultAccount) IncrementGracefulAuthCount()
func (*DefaultAccount) LastLoginTime ¶
func (a *DefaultAccount) LastLoginTime() time.Time
func (*DefaultAccount) LastName ¶
func (a *DefaultAccount) LastName() string
func (*DefaultAccount) LocaleCode ¶
func (a *DefaultAccount) LocaleCode() string
func (*DefaultAccount) LockAccount ¶
func (a *DefaultAccount) LockAccount()
func (*DefaultAccount) Locked ¶
func (a *DefaultAccount) Locked() bool
func (*DefaultAccount) LockoutDuration ¶
func (a *DefaultAccount) LockoutDuration() time.Duration
func (*DefaultAccount) LockoutEnabled ¶
func (a *DefaultAccount) LockoutEnabled() bool
func (*DefaultAccount) LockoutFailuresInterval ¶
func (a *DefaultAccount) LockoutFailuresInterval() time.Duration
func (*DefaultAccount) LockoutFailuresLimit ¶
func (a *DefaultAccount) LockoutFailuresLimit() int
func (*DefaultAccount) LockoutPolicyName ¶
func (a *DefaultAccount) LockoutPolicyName() string
func (*DefaultAccount) LockoutTime ¶
func (a *DefaultAccount) LockoutTime() time.Time
func (*DefaultAccount) LoginFailures ¶
func (a *DefaultAccount) LoginFailures() []time.Time
func (*DefaultAccount) Permissions ¶
func (a *DefaultAccount) Permissions() []string
func (*DefaultAccount) PwdAgingPolicyName ¶
func (a *DefaultAccount) PwdAgingPolicyName() string
func (*DefaultAccount) PwdAgingRuleEnforced ¶
func (a *DefaultAccount) PwdAgingRuleEnforced() bool
func (*DefaultAccount) PwdChangedTime ¶
func (a *DefaultAccount) PwdChangedTime() time.Time
func (*DefaultAccount) PwdExpiryWarningPeriod ¶
func (a *DefaultAccount) PwdExpiryWarningPeriod() time.Duration
func (*DefaultAccount) PwdMaxAge ¶
func (a *DefaultAccount) PwdMaxAge() time.Duration
func (*DefaultAccount) RecordFailure ¶
func (a *DefaultAccount) RecordFailure(failureTime time.Time, limit int)
func (*DefaultAccount) RecordSuccess ¶
func (a *DefaultAccount) RecordSuccess(loginTime time.Time)
func (*DefaultAccount) ResetFailedAttempts ¶
func (a *DefaultAccount) ResetFailedAttempts()
func (*DefaultAccount) ResetGracefulAuthCount ¶
func (a *DefaultAccount) ResetGracefulAuthCount()
func (*DefaultAccount) RoleNames ¶
func (a *DefaultAccount) RoleNames() []string
func (*DefaultAccount) SerialFailedAttempts ¶
func (a *DefaultAccount) SerialFailedAttempts() int
func (*DefaultAccount) TenantId ¶
func (a *DefaultAccount) TenantId() string
func (*DefaultAccount) Type ¶
func (a *DefaultAccount) Type() AccountType
func (*DefaultAccount) UnlockAccount ¶
func (a *DefaultAccount) UnlockAccount()
func (*DefaultAccount) UseMFA ¶
func (a *DefaultAccount) UseMFA() bool
func (*DefaultAccount) Username ¶
func (a *DefaultAccount) Username() string
func (*DefaultAccount) Value ¶
func (a *DefaultAccount) Value(key string) interface{}
type DefaultAuthenticationErrorHandler ¶
type DefaultAuthenticationErrorHandler struct { }
DefaultAuthenticationErrorHandler implements AuthenticationErrorHandler
func (*DefaultAuthenticationErrorHandler) HandleAuthenticationError ¶
func (h *DefaultAuthenticationErrorHandler) HandleAuthenticationError(ctx context.Context, r *http.Request, rw http.ResponseWriter, err error)
type DefaultErrorHandler ¶
type DefaultErrorHandler struct{}
DefaultErrorHandler implements ErrorHandler
func (*DefaultErrorHandler) HandleError ¶
func (h *DefaultErrorHandler) HandleError(ctx context.Context, r *http.Request, rw http.ResponseWriter, err error)
type DefaultIssuer ¶
type DefaultIssuer struct {
DefaultIssuerDetails
}
func NewIssuer ¶
func NewIssuer(opts ...func(*DefaultIssuerDetails)) *DefaultIssuer
func (DefaultIssuer) BuildUrl ¶
func (i DefaultIssuer) BuildUrl(options ...UrlBuilderOptions) (*url.URL, error)
func (DefaultIssuer) ContextPath ¶
func (i DefaultIssuer) ContextPath() string
func (DefaultIssuer) Domain ¶
func (i DefaultIssuer) Domain() string
func (DefaultIssuer) Identifier ¶
func (i DefaultIssuer) Identifier() string
func (DefaultIssuer) IsSecured ¶
func (i DefaultIssuer) IsSecured() bool
func (DefaultIssuer) LevelOfAssurance ¶
func (i DefaultIssuer) LevelOfAssurance(level int) string
func (DefaultIssuer) Port ¶
func (i DefaultIssuer) Port() int
func (DefaultIssuer) Protocol ¶
func (i DefaultIssuer) Protocol() string
type DefaultIssuerDetails ¶
type EmptyAuthentication ¶
type EmptyAuthentication string
EmptyAuthentication represent unauthenticated user. Note: anonymous user is considered authenticated
func (EmptyAuthentication) Details ¶
func (EmptyAuthentication) Details() interface{}
func (EmptyAuthentication) Permissions ¶
func (EmptyAuthentication) Permissions() Permissions
func (EmptyAuthentication) Principal ¶
func (EmptyAuthentication) Principal() interface{}
func (EmptyAuthentication) State ¶
func (EmptyAuthentication) State() AuthenticationState
type ErrorHandler ¶
type ErrorHandler interface {
HandleError(context.Context, *http.Request, http.ResponseWriter, error)
}
ErrorHandler handles any other type of errors
type Feature ¶
type Feature interface {
Identifier() FeatureIdentifier
}
Feature holds security settings of specific feature. Any Feature should have a corresponding FeatureConfigurer
type FeatureConfigurer ¶
type FeatureConfigurer interface {
Apply(Feature, WebSecurity) error
}
FeatureConfigurer not intended to be used directly in service
type FeatureIdentifier ¶
type FeatureIdentifier interface { fmt.Stringer fmt.GoStringer }
FeatureIdentifier is unique for each feature. Security initializer use this value to locate corresponding FeatureConfigurer or sort configuration order
func FeatureId ¶
func FeatureId(id string, order int) FeatureIdentifier
FeatureId create an ordered FeatureIdentifier
func PriorityFeatureId ¶
func PriorityFeatureId(id string, order int) FeatureIdentifier
PriorityFeatureId create a priority ordered FeatureIdentifier
func SimpleFeatureId ¶
func SimpleFeatureId(id string) FeatureIdentifier
SimpleFeatureId create unordered FeatureIdentifier
type FeatureModifier ¶
type FeatureModifier interface { // Enable kick off configuration of give Feature. // If the given Feature is not enabled yet, it's added to the receiver and returned // If the given Feature is already enabled, the already enabled Feature is returned Enable(Feature) Feature // Disable remove given feature using its FeatureIdentifier Disable(Feature) }
FeatureModifier add or remove features. \ Should not used directly by service use corresponding feature's Configure(WebSecurity) instead
type FeatureRegistrar ¶
type FeatureRegistrar interface { // RegisterFeature is typically used by feature packages, such as session, oauth, etc // not intended to be used directly in service RegisterFeature(featureId FeatureIdentifier, featureConfigurer FeatureConfigurer) // FindFeature is typically used by feature packages FindFeature(featureId FeatureIdentifier) FeatureConfigurer }
type FederatedAccountStore ¶
type GlobalSettingReader ¶
type Initializer ¶
type Initializer interface { // Initialize is the entry point for all security configuration. // Microservice or other library packages typically call this in Provide or Invoke functions // Note: use this function inside fx.Lifecycle takes no effect Initialize(ctx context.Context, lc fx.Lifecycle, registrar *web.Registrar) error }
Initializer is the entry point to bootstrap security
type Issuer ¶
type Issuer interface { Protocol() string Domain() string Port() int ContextPath() string IsSecured() bool // Identifier is the unique identifier of the deployed auth server // Typeical implementation is to use base url of issuer's domain. Identifier() string // LevelOfAssurance construct level-of-assurance string with given string // level-of-assurance represent how confident the auth issuer is about user's identity // ref: https://developer.mobileconnect.io/level-of-assurance LevelOfAssurance(level int) string // BuildUrl build a URL with given url builder options // Implementation specs: // 1. if UrlBuilderOption.FQDN is not specified, Issuer.Domain() should be used // 2. if UrlBuilderOption.FQDN is not a subdomain of Issuer.Domain(), an error should be returned // 3. should assume UrlBuilderOption.Path doesn't includes Issuer.ContextPath and the generated URL always // include Issuer.ContextPath // 4. if UrlBuilderOption.Path is not specified, the generated URL could be used as a base URL // 5. BuildUrl should not returns error when no options provided BuildUrl(...UrlBuilderOptions) (*url.URL, error) }
type KeyValueDetails ¶
type MiddlewareTemplate ¶
type MiddlewareTemplate *middleware.MappingBuilder
MiddlewareTemplate is partially configured middleware.MappingBuilder. it holds the middleware's gin.HandlerFunc and order if its route matcher and condition is not set, WebSecurity would make it matches WebSecurity's own values
type Permissions ¶
type Permissions map[string]interface{}
func (Permissions) Has ¶
func (p Permissions) Has(permission string) bool
type ProviderDetails ¶
type ProviderDetails interface { ProviderId() string ProviderName() string ProviderDisplayName() string ProviderDescription() string ProviderEmail() string ProviderNotificationType() string }
ProviderDetails is available if tenant is selected (tenant dictates provider)
type ProviderStore ¶
type ProxiedUserDetails ¶
type Registrar ¶
type Registrar interface { // Register is the entry point for all security configuration. // Microservice or other library packages typically call this in Provide or Invoke functions // Note: use this function inside fx.Lifecycle takes no effect Register(...Configurer) }
Registrar is the entry point to configure security
type SessionProperties ¶
type SessionProperties struct { Cookie CookieProperties IdleTimeout utils.Duration `json:"idle-timeout"` AbsoluteTimeout utils.Duration `json:"absolute-timeout"` MaxConcurrentSession int `json:"max-concurrent-sessions"` DbIndex int `json:"db-index"` }
func BindSessionProperties ¶
func BindSessionProperties(ctx *bootstrap.ApplicationContext) SessionProperties
BindSessionProperties create and bind SessionProperties, with a optional prefix
func NewSessionProperties ¶
func NewSessionProperties() *SessionProperties
NewSessionProperties create a SessionProperties with default values
type SimpleMappingTemplate ¶
type SimpleMappingTemplate *mapping.MappingBuilder
SimpleMappingTemplate is partially configured mapping.MappingBuilder it holds the simple mapping's path, gin.HandlerFunc and order if its condition is not set, WebSecurity would make it matches WebSecurity's own values
type TenantDetails ¶
TenantDetails is available in the following scenarios:
user auth, tenant can be determined (either selected tenant, or there is a default tenant) client auth, tenant can be determined (either selected tenant, or there is a default tenant)
type TenantStore ¶
type TimeoutSupportProperties ¶
type TimeoutSupportProperties struct {
DbIndex int `json:"db-index"`
}
func BindTimeoutSupportProperties ¶
func BindTimeoutSupportProperties(ctx *bootstrap.ApplicationContext) TimeoutSupportProperties
func NewTimeoutSupportProperties ¶
func NewTimeoutSupportProperties() *TimeoutSupportProperties
type UrlBuilderOption ¶
type UrlBuilderOptions ¶
type UrlBuilderOptions func(opt *UrlBuilderOption)
type UserDetails ¶
type UserDetails interface { UserId() string Username() string AccountType() AccountType // AssignedTenantIds // Deprecated: usage of this method is not encouraged. Designs that require user to select tenancy is preferred // i.e. design tenancy based on TenantDetails instead. AssignedTenantIds() utils.StringSet LocaleCode() string CurrencyCode() string FirstName() string LastName() string Email() string }
UserDetails is available for user authentication
type WebSecurity ¶
type WebSecurity interface { // Context returns the context associated with the WebSecurity. // It's typlically holds bootstrap.ApplicationContext or its derived context // this should not returns nil Context() context.Context // Route configure the path and method pattern which this WebSecurity applies to // Calling this method multiple times concatenate all given matchers with OR operator Route(web.RouteMatcher) WebSecurity // Condition sets additional conditions of incoming request which this WebSecurity applies to // Calling this method multiple times concatenate all given matchers with OR operator Condition(mwcm web.RequestMatcher) WebSecurity // AndCondition sets additional conditions of incoming request which this WebSecurity applies to // Calling this method multiple times concatenate all given matchers with AND operator AndCondition(mwcm web.RequestMatcher) WebSecurity // Add is DSL style setter to add: // - MiddlewareTemplate // - web.MiddlewareMapping // - web.MvcMapping // - web.StaticMapping // - web.SimpleMapping // when MiddlewareTemplate is given, WebSecurity's Route and Condition are applied to it // this method panic if other type is given Add(...interface{}) WebSecurity // Remove is DSL style setter to remove: // - MiddlewareTemplate // - web.MiddlewareMapping // - web.MvcMapping // - web.StaticMapping // - web.SimpleMapping Remove(...interface{}) WebSecurity // With is DSL style setter to enable features With(f Feature) WebSecurity Shared(key string) interface{} AddShared(key string, value interface{}) error // Authenticator returns Authenticator Authenticator() Authenticator // Features get currently configured Feature list Features() []Feature }
WebSecurity holds information on security configuration
type WebSecurityReader ¶
type WebSecurityReader interface { GetRoute() web.RouteMatcher GetCondition() web.RequestMatcher GetHandlers() []interface{} }