oauth

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const CodeGoogle = "google"
View Source
const CodeYandex = "yandex"

Variables

This section is empty.

Functions

This section is empty.

Types

type CallBack

type CallBack func(http.ResponseWriter, *http.Request, User)

type Config

type Config struct {
	Provider []ConfigItem `yaml:"oauth"`
}

type ConfigItem

type ConfigItem struct {
	Code         string `yaml:"code"`
	ClientID     string `yaml:"client_id"`
	ClientSecret string `yaml:"client_secret"`
	RedirectURL  string `yaml:"redirect_url"`
}

type IspGoogle

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

func (*IspGoogle) AuthCodeKey

func (v *IspGoogle) AuthCodeKey() string

func (*IspGoogle) AuthCodeURL

func (v *IspGoogle) AuthCodeURL() string

func (*IspGoogle) Code

func (v *IspGoogle) Code() string

func (*IspGoogle) Config

func (v *IspGoogle) Config(c ConfigItem)

func (*IspGoogle) Exchange

func (v *IspGoogle) Exchange(ctx context.Context, code string) (User, error)

type IspYandex

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

func (*IspYandex) AuthCodeKey

func (v *IspYandex) AuthCodeKey() string

func (*IspYandex) AuthCodeURL

func (v *IspYandex) AuthCodeURL() string

func (*IspYandex) Code

func (v *IspYandex) Code() string

func (*IspYandex) Config

func (v *IspYandex) Config(c ConfigItem)

func (*IspYandex) Exchange

func (v *IspYandex) Exchange(ctx context.Context, code string) (User, error)

type OAuth

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

func New

func New(c *Config) *OAuth

func (*OAuth) AddProviders

func (v *OAuth) AddProviders(p ...Provider)

func (*OAuth) CallBack

func (v *OAuth) CallBack(name string, call CallBack) func(w http.ResponseWriter, r *http.Request)

func (*OAuth) Down

func (v *OAuth) Down() error

func (*OAuth) GetProvider

func (v *OAuth) GetProvider(name string) (Provider, error)

func (*OAuth) Request

func (v *OAuth) Request(name string) func(http.ResponseWriter, *http.Request)

func (*OAuth) Up

func (v *OAuth) Up() error

type Provider

type Provider interface {
	Code() string
	Config(conf ConfigItem)
	AuthCodeURL() string
	AuthCodeKey() string
	Exchange(ctx context.Context, code string) (User, error)
}

type User

type User interface {
	GetName() string
	GetEmail() string
	GetIcon() string
}

type UserGoogle

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

func (*UserGoogle) GetEmail

func (v *UserGoogle) GetEmail() string

func (*UserGoogle) GetIcon

func (v *UserGoogle) GetIcon() string

func (*UserGoogle) GetName

func (v *UserGoogle) GetName() string

func (*UserGoogle) UnmarshalJSON

func (v *UserGoogle) UnmarshalJSON(data []byte) error

type UserYandex

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

func (*UserYandex) GetEmail

func (v *UserYandex) GetEmail() string

func (*UserYandex) GetIcon

func (v *UserYandex) GetIcon() string

func (*UserYandex) GetName

func (v *UserYandex) GetName() string

func (*UserYandex) UnmarshalJSON

func (v *UserYandex) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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