Documentation ¶
Index ¶
- Variables
- type BaseAuth
- func (b *BaseAuth) ConfigError(keySuffix string) error
- func (b *BaseAuth) ConfigKey(suffix string) string
- func (b *BaseAuth) DoAuthenticate(authcToken *authc.AuthenticationToken) (*authc.AuthenticationInfo, error)
- func (b *BaseAuth) DoAuthorizationInfo(authcInfo *authc.AuthenticationInfo) *authz.AuthorizationInfo
- func (b *BaseAuth) ExtractAuthenticationToken(r *ahttp.Request) *authc.AuthenticationToken
- func (b *BaseAuth) Init(appCfg *config.Config, keyName string) error
- func (b *BaseAuth) Key() string
- func (b *BaseAuth) Scheme() string
- func (b *BaseAuth) SetAuthenticator(authenticator authc.Authenticator) error
- func (b *BaseAuth) SetAuthorizer(authorizer authz.Authorizer) error
- func (b *BaseAuth) SetPrincipalProvider(principal authc.PrincipalProvider) error
- type BasicAuth
- func (b *BasicAuth) DoAuthenticate(authcToken *authc.AuthenticationToken) (*authc.AuthenticationInfo, error)
- func (b *BasicAuth) DoAuthorizationInfo(authcInfo *authc.AuthenticationInfo) *authz.AuthorizationInfo
- func (b *BasicAuth) ExtractAuthenticationToken(r *ahttp.Request) *authc.AuthenticationToken
- func (b *BasicAuth) Init(cfg *config.Config, keyName string) error
- type FormAuth
- type GenericAuth
- type OAuth2
- func (o *OAuth2) Client(token *oauth2.Token) *http.Client
- func (o *OAuth2) Config() *oauth2.Config
- func (o *OAuth2) Init(appCfg *config.Config, keyName string) error
- func (o *OAuth2) Principal(keyName string, v ess.Valuer) ([]*authc.Principal, error)
- func (o *OAuth2) ProviderAuthURL(r *ahttp.Request) (string, string)
- func (o *OAuth2) RefreshAccessToken(token *oauth2.Token) (*oauth2.Token, error)
- func (o *OAuth2) ValidateCallback(state string, r *ahttp.Request) (*oauth2.Token, error)
- type Schemer
Constants ¶
This section is empty.
Variables ¶
var ( ErrOAuth2MissingStateOrCode = errors.New("oauth2: callback missing state or code") ErrOAuth2InvalidState = errors.New("oauth2: invalid state") ErrOAuth2Exchange = errors.New("oauth2: exchange failed, unable to get token") ErrOAuth2TokenIsValid = errors.New("oauth2: token is vaild") )
OAuth2 Errors
Functions ¶
This section is empty.
Types ¶
type BaseAuth ¶
type BaseAuth struct { // Name contains name of the auth scheme. // For e.g.: form, basic, oauth2, generic Name string // KeyName value is auth scheme configuration KeyName. // For e.g: `security.auth_schemes.<keyname>`. KeyName string // KeyPrefix value is composed auth scheme configuration key. // // For e.g.: KeyName is 'form_auth', then KeyPrefix is // security.auth_schemes.form_auth KeyPrefix string // AppConfig value is application configuration, its suppiled via function `Init`. AppConfig *config.Config // contains filtered or unexported fields }
BaseAuth struct hold base implementation of aah framework's authentication schemes.
func (*BaseAuth) ConfigError ¶
ConfigError method creates config `error` instance for errors in the auth scheme configuration.
func (*BaseAuth) ConfigKey ¶
ConfigKey method returns fully qualified config key name with given suffix key for auth scheme.
func (*BaseAuth) DoAuthenticate ¶
func (b *BaseAuth) DoAuthenticate(authcToken *authc.AuthenticationToken) (*authc.AuthenticationInfo, error)
DoAuthenticate method calls the registered `Authenticator` with authentication token.
func (*BaseAuth) DoAuthorizationInfo ¶
func (b *BaseAuth) DoAuthorizationInfo(authcInfo *authc.AuthenticationInfo) *authz.AuthorizationInfo
DoAuthorizationInfo method calls registered `Authorizer` with authentication information.
func (*BaseAuth) ExtractAuthenticationToken ¶
func (b *BaseAuth) ExtractAuthenticationToken(r *ahttp.Request) *authc.AuthenticationToken
ExtractAuthenticationToken method typically implementated by extending struct.
func (*BaseAuth) Key ¶
Key method returns auth scheme configuration KeyName. For e.g: `security.auth_schemes.<keyname>`.
func (*BaseAuth) SetAuthenticator ¶
func (b *BaseAuth) SetAuthenticator(authenticator authc.Authenticator) error
SetAuthenticator method assigns the given `Authenticator` instance to auth scheme.
func (*BaseAuth) SetAuthorizer ¶
func (b *BaseAuth) SetAuthorizer(authorizer authz.Authorizer) error
SetAuthorizer method assigns the given `Authorizer` instance to auth scheme.
func (*BaseAuth) SetPrincipalProvider ¶
func (b *BaseAuth) SetPrincipalProvider(principal authc.PrincipalProvider) error
SetPrincipalProvider method assigns the given `PrincipalProvider` instance to auth scheme.
type BasicAuth ¶
BasicAuth struct provides aah's OOTB Basic Auth scheme.
func (*BasicAuth) DoAuthenticate ¶
func (b *BasicAuth) DoAuthenticate(authcToken *authc.AuthenticationToken) (*authc.AuthenticationInfo, error)
DoAuthenticate method calls the registered `Authenticator` with authentication token.
func (*BasicAuth) DoAuthorizationInfo ¶
func (b *BasicAuth) DoAuthorizationInfo(authcInfo *authc.AuthenticationInfo) *authz.AuthorizationInfo
DoAuthorizationInfo method calls registered `Authorizer` with authentication information.
func (*BasicAuth) ExtractAuthenticationToken ¶
func (b *BasicAuth) ExtractAuthenticationToken(r *ahttp.Request) *authc.AuthenticationToken
ExtractAuthenticationToken method extracts the authentication token information from the HTTP request.
type FormAuth ¶
type FormAuth struct { BaseAuth IsAlwaysToDefaultTarget bool LoginURL string LoginSubmitURL string LoginFailureURL string DefaultTargetURL string FieldIdentity string FieldCredential string }
FormAuth struct provides aah's OOTB Form Auth scheme.
func (*FormAuth) DoAuthenticate ¶
func (f *FormAuth) DoAuthenticate(authcToken *authc.AuthenticationToken) (*authc.AuthenticationInfo, error)
DoAuthenticate method calls the registered `Authenticator` with authentication token.
func (*FormAuth) ExtractAuthenticationToken ¶
func (f *FormAuth) ExtractAuthenticationToken(r *ahttp.Request) *authc.AuthenticationToken
ExtractAuthenticationToken method extracts the authentication token information from the HTTP request.
type GenericAuth ¶
GenericAuth struct provides generic Auth Scheme for all custom scenario's.
func (*GenericAuth) ExtractAuthenticationToken ¶
func (g *GenericAuth) ExtractAuthenticationToken(r *ahttp.Request) *authc.AuthenticationToken
ExtractAuthenticationToken method extracts an authentication token information from the HTTP request.
type OAuth2 ¶
type OAuth2 struct { BaseAuth LoginURL string RedirectURL string SuccessURL string // contains filtered or unexported fields }
OAuth2 auth scheme implementation for the aah framework.
func (*OAuth2) Principal ¶
Principal method calls the registered interface `SubjectPrincipalProvider` to obtain Subject principals.
func (*OAuth2) ProviderAuthURL ¶
ProviderAuthURL method returns aah generated state value and OAuth2 login URL.
func (*OAuth2) RefreshAccessToken ¶
RefreshAccessToken method returns new OAuth2 token if given token was expried otherwise returns error `scheme.ErrOAuth2TokenIsValid`.
type Schemer ¶
type Schemer interface { // Init method gets called by aah during an application start. // // `keyName` is value of security auth scheme key. // For e.g.: // security.auth_schemes.<keyname> Init(appCfg *config.Config, keyName string) error // Key method returns auth scheme configuration KeyName. // For e.g: `security.auth_schemes.<keyname>`. Key() string // Scheme method returns auth scheme name. For e.g.: form, basic, oauth2, generic, etc. Scheme() string // DoAuthenticate method called by aah SecurityManager to get Subject authentication // information. DoAuthenticate(authcToken *authc.AuthenticationToken) (*authc.AuthenticationInfo, error) // DoAuthorizationInfo method called by aah SecurityManager to get // Subject's authorization information if successful authentication. DoAuthorizationInfo(authcInfo *authc.AuthenticationInfo) *authz.AuthorizationInfo // ExtractAuthenticationToken method called by aah SecurityManager to // extract identity details from the HTTP request. ExtractAuthenticationToken(r *ahttp.Request) *authc.AuthenticationToken }
Schemer interface is used to create new Auth Scheme for aah framework.