Documentation
¶
Index ¶
- Constants
- func CheckAuthStatus() (bool, error)
- func CreateTokenStoreFromLayers(parsedLayers *layers.ParsedLayers) (store.TokenStore, error)
- func CreateTokenStoreFromSettings(s *AuthSettings, dbs *DBAuthSettings, db interface{}) (store.TokenStore, error)
- func GetOAuthTokenStoreLayers() (*layers.ParameterLayers, error)
- func NewAuthParameterLayer() (layers.ParameterLayer, error)
- func NewDBAuthParameterLayer() (layers.ParameterLayer, error)
- func NewGoogleClient(ctx context.Context, opts ...Option) (*http.Client, error)
- func RemoveToken() error
- type AuthResult
- type AuthSettings
- type Authenticator
- type DBAuthSettings
- type Option
- func CreateOptionsFromSettings(s *AuthSettings) ([]Option, error)
- func WithCredentialsFile(path string) Option
- func WithCredentialsJSON(json []byte) Option
- func WithErrorPage(page []byte) Option
- func WithLogger(logger *zerolog.Logger) Option
- func WithOAuthConfig(cfg *oauth2.Config) Option
- func WithScopes(scopes ...string) Option
- func WithServerMode(mode server.ServerMode) Option
- func WithSuccessPage(page []byte) Option
- func WithTimeout(duration time.Duration) Option
- func WithTokenStore(store store.TokenStore) Option
Constants ¶
const ( AuthSlug = "google-auth" DBAuthSlug = "db-auth" )
Variables ¶
This section is empty.
Functions ¶
func CheckAuthStatus ¶
CheckAuthStatus checks if a valid token exists
func CreateTokenStoreFromLayers ¶
func CreateTokenStoreFromLayers(parsedLayers *layers.ParsedLayers) (store.TokenStore, error)
CreateTokenStoreFromLayers creates a token store from parsed layers
func CreateTokenStoreFromSettings ¶
func CreateTokenStoreFromSettings(s *AuthSettings, dbs *DBAuthSettings, db interface{}) (store.TokenStore, error)
CreateTokenStoreFromSettings creates a token store from settings
func GetOAuthTokenStoreLayers ¶
func GetOAuthTokenStoreLayers() (*layers.ParameterLayers, error)
GetOAuthTokenStoreLayers returns all layers required for OAuth token store configuration
func NewAuthParameterLayer ¶
func NewAuthParameterLayer() (layers.ParameterLayer, error)
func NewDBAuthParameterLayer ¶
func NewDBAuthParameterLayer() (layers.ParameterLayer, error)
func NewGoogleClient ¶
NewGoogleClient creates a new authenticated Google Calendar client
Types ¶
type AuthResult ¶
AuthResult contains the authentication result
type AuthSettings ¶
type AuthSettings struct { CredentialsFile string `glazed.parameter:"credentials-file"` TokenStoreType string `glazed.parameter:"token-store-type"` TokenStorePath string `glazed.parameter:"token-store-path"` TokenStorePerms int `glazed.parameter:"token-store-perms"` ServerPort int `glazed.parameter:"server-port"` CallbackPath string `glazed.parameter:"callback-path"` Timeout int `glazed.parameter:"timeout"` }
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator handles OAuth2 authentication flow
func CreateAuthenticatorFromLayers ¶
func CreateAuthenticatorFromLayers(parsedLayers *layers.ParsedLayers) (*Authenticator, error)
CreateAuthenticatorFromLayers creates an authenticator from parsed layers
func NewAuthenticator ¶
func NewAuthenticator(opts ...Option) (*Authenticator, error)
NewAuthenticator creates a new authenticator with the given options
func (*Authenticator) Authenticate ¶
func (a *Authenticator) Authenticate(ctx context.Context) (*AuthResult, error)
Authenticate starts the OAuth2 flow and returns the result
type DBAuthSettings ¶
type Option ¶
type Option func(*config) error
Option is a function that configures the authenticator
func CreateOptionsFromSettings ¶
func CreateOptionsFromSettings(s *AuthSettings) ([]Option, error)
CreateOptionsFromSettings creates authenticator options from AuthSettings
func WithCredentialsFile ¶
WithCredentialsFile sets the OAuth2 credentials from a file
func WithCredentialsJSON ¶
WithCredentialsJSON sets the OAuth2 credentials from JSON bytes
func WithOAuthConfig ¶
WithOAuthConfig sets a pre-configured OAuth2 config
func WithServerMode ¶
func WithServerMode(mode server.ServerMode) Option
WithServerMode sets the server mode implementation
func WithSuccessPage ¶
WithSuccessPage sets a custom success page
func WithTimeout ¶
WithTimeout sets the maximum duration to wait for authentication
func WithTokenStore ¶
func WithTokenStore(store store.TokenStore) Option
WithTokenStore sets the token storage implementation