fedilogin

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account interface {
	GetID() (id int64)
	GetInstance() (instance Instance)
	GetInstanceAccountID() (instanceAccountID string)
	GetUsername() (username string)

	SetInstance(instance Instance)
	SetInstanceAccountID(instanceAccountID string)
	SetUsername(username string)
}

type CreateAccountHandler

type CreateAccountHandler func(ctx context.Context, account Account) (err error)

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error represents a fedihelper specific error.

func NewError

func NewError(m string) *Error

NewError wraps a message in a Error object.

func NewErrorf

func NewErrorf(m string, args ...interface{}) *Error

NewErrorf wraps a message in a Error object.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message as a string.

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 New

func New(t http.RoundTripper, clientName string, helpers []Helper) (*FediLogin, error)

New creates a new fedi module.

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 (f *FediLogin) HandleOauthCallback(r *http.Request, instance Instance, redirectURI *url.URL) (Account, int, error)

func (*FediLogin) Helper

func (f *FediLogin) Helper(s lib.Software) (Helper, error)

Helper returns a helper for a given software package.

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 GetAccountHandler func(ctx context.Context, instance Instance, username string) (account Account, found bool, err error)

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 NewAccountHandler func(ctx context.Context) (account Account, err error)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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