login

package
v0.0.0-...-b78f4d7 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MPL-2.0 Imports: 30 Imported by: 0

README

Digiposte login module

This module is used to login to digiposte.fr.

This module exists because digiposte.fr does not provide oauth2 credentials to third party applications. This module will get the credentials from the digiposte.fr website and store them in the rclone config file.

Documentation

Index

Constants

View Source
const (
	ConfigURL       = "url"
	ConfigCookieJar = "cookie"
)
View Source
const (
	// DefaultTimeout is the default timeout for the login process.
	DefaultTimeout = 30 * time.Second
	// DefaultRefreshFrequency is the default refresh frequency for the login process.
	DefaultRefreshFrequency = 1500 * time.Millisecond
)
View Source
const (

	// ReconnectURL is redirect to local webserver when active.
	ReconnectURL = "http://" + bindAddress + "/"

	// ReconnectPublicURL is redirect to local webserver when active with public name.
	ReconnectPublicURL = "http://localhost.rclone.org:" + bindPort + "/"

	// ReconnectLocalhostURL is redirect to local webserver when active with localhost.
	ReconnectLocalhostURL = "http://localhost:" + bindPort + "/"

	TokenPath     = "token"
	AuthorizePath = "authorize"
)
View Source
const (
	UsernameParam  = "username"
	PasswordParam  = "password"
	OTPSecretParam = "otp_secret"
)
View Source
const LogPrefix = "digiposte-login"

Variables

This section is empty.

Functions

func ConfigOut

func ConfigOut(ctx context.Context, state string, creds *Credentials, opts ...Option) (*fs.ConfigOut, error)

func StartServer

func StartServer(codeVerifier pkce.Code, mapper configmap.Mapper, client *models.Client) error

StartServer starts a local webserver to receive the auth.

func StopServer

func StopServer() error

func UsingChrome

func UsingChrome(ctx context.Context, creds *Credentials, opts ...Option) (*oauth2.Token, []*http.Cookie, error)

Types

type Credentials

type Credentials struct {
	Username  string
	Password  string
	OTPSecret string
}

func (*Credentials) Valid

func (c *Credentials) Valid() error

type ErrorType

type ErrorType int
const (
	InternalError             ErrorType = 500 // internal_error
	InvalidRequestError       ErrorType = 400 // invalid_request
	InvalidClientError        ErrorType = 400 // invalid_client
	InvalidGrantError         ErrorType = 400 // invalid_grant
	InvalidScopeError         ErrorType = 400 // invalid_scope
	UnauthorizedClientError   ErrorType = 401 // unauthorized_client
	UnsupportedGrantTypeError ErrorType = 400 // unsupported_grant_type
	CancelledRequestError     ErrorType = 499 // reauest_cancelled
)

https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/#error

func (ErrorType) String

func (i ErrorType) String() string

type HTTPError

type HTTPError struct {
	Status     int64
	StatusText string
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type InvalidTokenError

type InvalidTokenError struct {
	Token *oauth2.Token
}

func (*InvalidTokenError) Error

func (e *InvalidTokenError) Error() string

type MissingOptionError

type MissingOptionError struct {
	Option func(string) Option
}

func (*MissingOptionError) Error

func (e *MissingOptionError) Error() string

func (*MissingOptionError) Is

func (e *MissingOptionError) Is(target error) bool

type NilTokenError

type NilTokenError struct{}

func (*NilTokenError) Error

func (e *NilTokenError) Error() string

type Option

type Option func(*chromeLogin)

func WithCookies

func WithCookies(cookies []*http.Cookie) Option

func WithRefreshFrequency

func WithRefreshFrequency(frequency time.Duration) Option

func WithScreenShortOnError

func WithScreenShortOnError(screenShortOnError bool) Option

func WithURL

func WithURL(url string) Option

type RequiredFieldError

type RequiredFieldError struct {
	Field string
}

func (*RequiredFieldError) Error

func (e *RequiredFieldError) Error() string

type Screen

type Screen interface {
	CurrentPageMatches(ctx context.Context) bool
	chromedp.Action
}

type Screens

type Screens []Screen

func (Screens) Do

func (s Screens) Do(ctx context.Context) error

type UnsupportedTokenError

type UnsupportedTokenError struct {
	Token interface{}
}

func (*UnsupportedTokenError) Error

func (e *UnsupportedTokenError) Error() string

type WithScreenshotError

type WithScreenshotError struct {
	Err        error
	Screenshot []byte
}

func (*WithScreenshotError) Error

func (e *WithScreenshotError) Error() string

func (*WithScreenshotError) Unwrap

func (e *WithScreenshotError) Unwrap() error

Jump to

Keyboard shortcuts

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