Documentation ¶
Index ¶
- Constants
- Variables
- func AuthenticationCheck() (string, error)
- type ActiveUser
- type AuthenticationFailedError
- type AuthenticationFunction
- type AuthenticationProvider
- type AuthenticationService
- type AuthenticationServiceImpl
- func (a *AuthenticationServiceImpl) Authenticate(ctx context.Context) (token string, err error)
- func (a *AuthenticationServiceImpl) ConfigureProviders(c *config.Config)
- func (a *AuthenticationServiceImpl) IsAuthenticated() bool
- func (a *AuthenticationServiceImpl) Logout(ctx context.Context)
- func (a *AuthenticationServiceImpl) Provider() AuthenticationProvider
- func (a *AuthenticationServiceImpl) SetProvider(provider AuthenticationProvider)
- func (a *AuthenticationServiceImpl) UpdateCredentials(newToken string, sendNotification bool, updateApiUrl bool)
- type CliAuthenticationProvider
- func (a *CliAuthenticationProvider) AuthURL(_ context.Context) string
- func (a *CliAuthenticationProvider) Authenticate(ctx context.Context) (string, error)
- func (a *CliAuthenticationProvider) ClearAuthentication(ctx context.Context) error
- func (a *CliAuthenticationProvider) GetCheckAuthenticationFunction() AuthenticationFunction
- type FakeAuthenticationProvider
- func (a *FakeAuthenticationProvider) AuthURL(_ context.Context) string
- func (a *FakeAuthenticationProvider) Authenticate(_ context.Context) (string, error)
- func (a *FakeAuthenticationProvider) ClearAuthentication(_ context.Context) error
- func (a *FakeAuthenticationProvider) GetCheckAuthenticationFunction() AuthenticationFunction
- type Initializer
- type OAuth2Provider
- func (p *OAuth2Provider) AuthURL(_ context.Context) string
- func (p *OAuth2Provider) Authenticate(_ context.Context) (string, error)
- func (p *OAuth2Provider) Authenticator() auth.Authenticator
- func (p *OAuth2Provider) ClearAuthentication(_ context.Context) error
- func (p *OAuth2Provider) GetCheckAuthenticationFunction() AuthenticationFunction
Constants ¶
View Source
const ExpirationMsg = "Your authentication failed due to token expiration. Please re-authenticate to continue using Snyk."
View Source
const InvalidCredsMessage = "" /* 129-byte string literal not displayed */
Variables ¶
View Source
var ErrEmptyAPIToken = errors.New("auth-provider: api token is not set")
Functions ¶
func AuthenticationCheck ¶
Types ¶
type ActiveUser ¶
type ActiveUser struct { Id string `json:"id"` UserName string `json:"username,omitempty"` Orgs []struct { Name string `json:"name,omitempty"` Id string `json:"id,omitempty"` Group struct { Name string `json:"name,omitempty"` Id string `json:"id,omitempty"` } `json:"group,omitempty"` } `json:"orgs,omitempty"` }
func GetActiveUser ¶
func GetActiveUser() (*ActiveUser, error)
type AuthenticationFailedError ¶
type AuthenticationFailedError struct {
ManualAuthentication bool
}
func (*AuthenticationFailedError) Error ¶
func (e *AuthenticationFailedError) Error() string
type AuthenticationFunction ¶
type AuthenticationProvider ¶
type AuthenticationProvider interface { // Authenticate triggers the authentication. This may involve manual steps, like logging in using a browser Authenticate(ctx context.Context) (string, error) // ClearAuthentication removes all authentication information from the configuration ClearAuthentication(ctx context.Context) error // AuthURL returns the latest provided AuthenticationURL. This can be empty. AuthURL(ctx context.Context) string GetCheckAuthenticationFunction() AuthenticationFunction // contains filtered or unexported methods }
func Default ¶
func Default(c *config.Config, authenticationService AuthenticationService) AuthenticationProvider
Default authentication configures an OAuth2 authenticator, the auth service parameter is needed, as the oauth2 provider needs a callback function
func Token ¶
func Token(c *config.Config, errorReporter error_reporting.ErrorReporter) AuthenticationProvider
Token authentication configures token only authentication
type AuthenticationService ¶
type AuthenticationService interface { // Authenticate attempts to authenticate the user, and sends a notification to the client when successful Authenticate(ctx context.Context) (string, error) // Provider returns current authentication provider. Provider() AuthenticationProvider // UpdateCredentials stores the token in the configuration, and sends a $/snyk.hasAuthenticated notification to the // client if sendNotification is true UpdateCredentials(newToken string, sendNotification bool, updateApiUrl bool) Logout(ctx context.Context) // IsAuthenticated returns true if the token is verified IsAuthenticated() bool // SetProvider sets the authentication provider SetProvider(provider AuthenticationProvider) // ConfigureProviders updates the providers based on the stored configuration ConfigureProviders(c *config.Config) // contains filtered or unexported methods }
func NewAuthenticationService ¶
func NewAuthenticationService(c *config.Config, authProviders AuthenticationProvider, errorReporter error_reporting.ErrorReporter, notifier noti.Notifier) AuthenticationService
type AuthenticationServiceImpl ¶
type AuthenticationServiceImpl struct {
// contains filtered or unexported fields
}
func (*AuthenticationServiceImpl) Authenticate ¶
func (a *AuthenticationServiceImpl) Authenticate(ctx context.Context) (token string, err error)
func (*AuthenticationServiceImpl) ConfigureProviders ¶
func (a *AuthenticationServiceImpl) ConfigureProviders(c *config.Config)
func (*AuthenticationServiceImpl) IsAuthenticated ¶
func (a *AuthenticationServiceImpl) IsAuthenticated() bool
IsAuthenticated returns true if the token is verified If the token is set, but not valid IsAuthenticated returns false
func (*AuthenticationServiceImpl) Logout ¶
func (a *AuthenticationServiceImpl) Logout(ctx context.Context)
func (*AuthenticationServiceImpl) Provider ¶
func (a *AuthenticationServiceImpl) Provider() AuthenticationProvider
func (*AuthenticationServiceImpl) SetProvider ¶
func (a *AuthenticationServiceImpl) SetProvider(provider AuthenticationProvider)
func (*AuthenticationServiceImpl) UpdateCredentials ¶
func (a *AuthenticationServiceImpl) UpdateCredentials(newToken string, sendNotification bool, updateApiUrl bool)
type CliAuthenticationProvider ¶
type CliAuthenticationProvider struct {
// contains filtered or unexported fields
}
func NewCliAuthenticationProvider ¶
func NewCliAuthenticationProvider(c *config.Config, errorReporter error_reporting.ErrorReporter) *CliAuthenticationProvider
func (*CliAuthenticationProvider) AuthURL ¶
func (a *CliAuthenticationProvider) AuthURL(_ context.Context) string
func (*CliAuthenticationProvider) Authenticate ¶
func (a *CliAuthenticationProvider) Authenticate(ctx context.Context) (string, error)
func (*CliAuthenticationProvider) ClearAuthentication ¶
func (a *CliAuthenticationProvider) ClearAuthentication(ctx context.Context) error
func (*CliAuthenticationProvider) GetCheckAuthenticationFunction ¶
func (a *CliAuthenticationProvider) GetCheckAuthenticationFunction() AuthenticationFunction
type FakeAuthenticationProvider ¶
type FakeAuthenticationProvider struct { ExpectedAuthURL string IsAuthenticated bool C *config.Config // contains filtered or unexported fields }
func NewFakeCliAuthenticationProvider ¶
func NewFakeCliAuthenticationProvider(c *config.Config) *FakeAuthenticationProvider
func (*FakeAuthenticationProvider) AuthURL ¶
func (a *FakeAuthenticationProvider) AuthURL(_ context.Context) string
func (*FakeAuthenticationProvider) Authenticate ¶
func (a *FakeAuthenticationProvider) Authenticate(_ context.Context) (string, error)
func (*FakeAuthenticationProvider) ClearAuthentication ¶
func (a *FakeAuthenticationProvider) ClearAuthentication(_ context.Context) error
func (*FakeAuthenticationProvider) GetCheckAuthenticationFunction ¶
func (a *FakeAuthenticationProvider) GetCheckAuthenticationFunction() AuthenticationFunction
type Initializer ¶
type Initializer struct {
// contains filtered or unexported fields
}
func NewInitializer ¶
func NewInitializer(c *config.Config, authenticator AuthenticationService, errorReporter error_reporting.ErrorReporter, notifier noti.Notifier) *Initializer
func (*Initializer) Init ¶
func (i *Initializer) Init() error
type OAuth2Provider ¶
type OAuth2Provider struct {
// contains filtered or unexported fields
}
func NewOAuthProvider ¶
func (*OAuth2Provider) Authenticate ¶
func (p *OAuth2Provider) Authenticate(_ context.Context) (string, error)
func (*OAuth2Provider) Authenticator ¶
func (p *OAuth2Provider) Authenticator() auth.Authenticator
func (*OAuth2Provider) ClearAuthentication ¶
func (p *OAuth2Provider) ClearAuthentication(_ context.Context) error
func (*OAuth2Provider) GetCheckAuthenticationFunction ¶
func (p *OAuth2Provider) GetCheckAuthenticationFunction() AuthenticationFunction
Click to show internal directories.
Click to hide internal directories.