auth

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package auth GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOAuthProviderNotFound = errors.New("OAuthProvider Not Found")
)

Functions

func ContextWithAuth

func ContextWithAuth(ctx context.Context, o Auth) context.Context

func RegisterOAuthProvider

func RegisterOAuthProvider(ctx context.Context, op OAuthProvider)

Types

type AccountExchanger

type AccountExchanger interface {
	Exchange(ctx context.Context, from string, user UserInfo, createIfNotExists bool) ([]string, error)
}

type Auth

type Auth interface {
	ListAuthProvider() (list []*ProviderInfo)
	AuthCodeURL(ctx context.Context, name string, redirectURI string) (redirectTo *url.URL, err error)
	ExchangeToken(ctx context.Context, name string, code string) (token *Token, err error)
}

func FromContext

func FromContext(ctx context.Context) Auth

type Authorizations

type Authorizations map[string]string

func ParseAuthorization

func ParseAuthorization(s string) (auths Authorizations)

func (Authorizations) Add

func (auths Authorizations) Add(k string, v string)

func (Authorizations) Get

func (auths Authorizations) Get(k string) string

func (Authorizations) RuntimeDoc

func (Authorizations) RuntimeDoc(names ...string) ([]string, bool)

func (Authorizations) String

func (auths Authorizations) String() string

type OAuthProvider

type OAuthProvider interface {
	Name() string
	AuthCodeURL(state string, redirectURL string) string
	ExchangeUserInfo(ctx context.Context, code string) (UserInfo, error)
}

type OAuthRegister

type OAuthRegister interface {
	Register(op OAuthProvider)
}

type OIDC

type OIDC struct {
	// OpenIDConnect Endpoint, when empty, oidc feature disabled.
	Endpoint string `flag:",omitempty"`
}

func (*OIDC) Init

func (p *OIDC) Init(ctx context.Context) error

func (*OIDC) New

func (p *OIDC) New(ctx context.Context) (OAuthProvider, error)

func (OIDC) RuntimeDoc

func (v OIDC) RuntimeDoc(names ...string) ([]string, bool)

type Provider

type Provider struct {
	// Should be full callback URI
	// example https://host/authorize/callback/{name}
	RedirectURI   string `flag:",omitempty"`
	AutoCreatedBy string `flag:",omitempty"`
	// contains filtered or unexported fields
}

func (*Provider) Init

func (c *Provider) Init(ctx context.Context) error

func (*Provider) InjectContext

func (c *Provider) InjectContext(ctx context.Context) context.Context

func (Provider) RuntimeDoc

func (v Provider) RuntimeDoc(names ...string) ([]string, bool)

func (*Provider) SetAccountExchanger

func (c *Provider) SetAccountExchanger(ae AccountExchanger)

func (*Provider) SetDefaults

func (c *Provider) SetDefaults()

type ProviderInfo

type ProviderInfo struct {
	Type string `json:"type"`
	Name string `json:"name"`
}

func (ProviderInfo) RuntimeDoc

func (v ProviderInfo) RuntimeDoc(names ...string) ([]string, bool)

type Token

type Token struct {
	AccessToken  string    `json:"access_token"`
	Token        string    `json:"token,omitempty"`
	RefreshToken string    `json:"refresh_token,omitempty"`
	ExpiresIn    int       `json:"expires_in"`
	IssuedAt     time.Time `json:"issued_at"`

	// Token type
	Type string `json:"type"`
	// ext
	ID string `json:"id,omitempty"`
}

func (Token) RuntimeDoc

func (v Token) RuntimeDoc(names ...string) ([]string, bool)

type TokenExchange added in v0.5.4

type TokenExchange struct {
	Type string `json:"type"`
	// When type totp
	Passcode string `json:"passcode,omitempty"`
}

func (TokenExchange) RuntimeDoc added in v0.5.4

func (v TokenExchange) RuntimeDoc(names ...string) ([]string, bool)

type UserInfo

type UserInfo interface {
	ID() string
	Email() string
	Mobile() string
	Nickname() string
}

Jump to

Keyboard shortcuts

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