Documentation
¶
Index ¶
- type Account
- type CreateAccountHandler
- type Error
- type FediLogin
- func (f *FediLogin) GenerateInstanceFromDomain(ctx context.Context, domain string, instance Instance) error
- func (f *FediLogin) GetLoginURL(ctx context.Context, redirectURI *url.URL, instance Instance) (*url.URL, bool, error)
- func (f *FediLogin) GetOrCreateAccount(ctx context.Context, instanceAccountID, username string, instance Instance) (Account, error)
- func (f *FediLogin) HandleOauthCallback(r *http.Request, instance Instance, redirectURI *url.URL) (Account, int, error)
- func (f *FediLogin) Helper(s lib.Software) (Helper, error)
- func (f *FediLogin) SetCreateAccountHandler(handler CreateAccountHandler)
- func (f *FediLogin) SetGetAccountHandler(handler GetAccountHandler)
- func (f *FediLogin) SetNewAccountHandler(handler NewAccountHandler)
- type GetAccountHandler
- type Helper
- type Instance
- type KV
- type NewAccountHandler
- type NoHelperError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateAccountHandler ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents a fedihelper specific error.
type FediLogin ¶
type FediLogin struct {
CreateAccountHandler CreateAccountHandler
GetAccountHandler GetAccountHandler
NewAccountHandler NewAccountHandler
// contains filtered or unexported fields
}
FediLogin is a module for working with federated social instances.
func (*FediLogin) GenerateInstanceFromDomain ¶
func (f *FediLogin) GenerateInstanceFromDomain(ctx context.Context, domain string, instance Instance) error
GenerateInstanceFromDomain created a Instance object by querying the apis of the instance.
func (*FediLogin) GetLoginURL ¶
func (f *FediLogin) GetLoginURL(ctx context.Context, redirectURI *url.URL, instance Instance) (*url.URL, bool, error)
GetLoginURL retrieves an oauth url for a federated instance, returns true if instance was updated.
func (*FediLogin) GetOrCreateAccount ¶
func (f *FediLogin) GetOrCreateAccount(ctx context.Context, instanceAccountID, username string, instance Instance) (Account, error)
GetOrCreateAccount gets an account from the database or .
func (*FediLogin) HandleOauthCallback ¶
func (*FediLogin) SetCreateAccountHandler ¶
func (f *FediLogin) SetCreateAccountHandler(handler CreateAccountHandler)
func (*FediLogin) SetGetAccountHandler ¶
func (f *FediLogin) SetGetAccountHandler(handler GetAccountHandler)
func (*FediLogin) SetNewAccountHandler ¶
func (f *FediLogin) SetNewAccountHandler(handler NewAccountHandler)
type GetAccountHandler ¶
type Helper ¶
type Helper interface {
GetAccessToken(ctx context.Context, redirectURI *url.URL, instance Instance, code string) (accessToken string, err error)
GetCurrentAccount(ctx context.Context, instance Instance, accessToken string) (user Account, err error)
GetSoftware() lib.Software
RegisterApp(ctx context.Context, redirectURI *url.URL, instance Instance) (clientID string, clientSecret string, err error)
SetFedi(f *FediLogin)
MakeLoginURI(ctx context.Context, redirectURI *url.URL, instance Instance) (loginURI *url.URL, err error)
}
Helper interacts with a federated social instance.
type Instance ¶
type Instance interface {
GetDomain() string
GetOAuthClientID() string
GetOAuthClientSecret() (string, error)
GetServerHostname() string
GetSoftware() string
SetDomain(domain string)
SetOAuthClientID(clientID string)
SetOAuthClientSecret(clientSecret string) error
SetServerHostname(hostname string)
SetSoftware(software string)
}
type NewAccountHandler ¶
type NoHelperError ¶
type NoHelperError struct {
// contains filtered or unexported fields
}
NoHelperError represents a missing helper error.
func NewNoHelperError ¶
func NewNoHelperError(software string) *NoHelperError
NewNoHelperError wraps a message in a NoHelperError object.
func (*NoHelperError) Error ¶
func (e *NoHelperError) Error() string
Error returns the error message as a string.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.