auth

package
v1.2.179 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: GPL-3.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Amazon = iota
	Bitbucket
	GitHub
	GitLab
	Facebook
	Instagram
	LinkedIn
	Microsoft
	Mira
	PayPal
)
View Source
const UserValueToken = "UserToken"

Variables

This section is empty.

Functions

func IsAJAXRequest added in v1.2.130

func IsAJAXRequest(r *fasthttp.Request) bool

IsAJAXRequest - is this AJAX-request

func SetAuthManager added in v1.2.93

func SetAuthManager(ctx *fasthttp.RequestCtx, a FncAuth)

Types

type AjaxOnly added in v1.2.93

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

AjaxOnly wrap auth manager for ajax endpoint on case full refresh web-page

func NewAjaxOnly added in v1.2.93

func NewAjaxOnly(auth FncAuth) *AjaxOnly

func (*AjaxOnly) AdminAuth added in v1.2.93

func (r *AjaxOnly) AdminAuth(ctx *fasthttp.RequestCtx) bool

func (*AjaxOnly) Auth added in v1.2.93

func (r *AjaxOnly) Auth(ctx *fasthttp.RequestCtx) bool

func (*AjaxOnly) GetAuthManager added in v1.2.93

func (r *AjaxOnly) GetAuthManager(ctx *fasthttp.RequestCtx, isAdmin bool) bool

func (*AjaxOnly) String added in v1.2.93

func (r *AjaxOnly) String() string

type AuthBasic added in v1.0.11512

type AuthBasic struct {
	NewTokenData fncNewTokenData
	// contains filtered or unexported fields
}

func NewAuthBasic added in v1.0.11512

func NewAuthBasic(tokens Tokens, fnc fncNewTokenData) *AuthBasic

func (*AuthBasic) AdminAuth added in v1.0.11512

func (a *AuthBasic) AdminAuth(ctx *fasthttp.RequestCtx) bool

func (*AuthBasic) Auth added in v1.0.11512

func (a *AuthBasic) Auth(ctx *fasthttp.RequestCtx) bool

func (*AuthBasic) String added in v1.0.11512

func (a *AuthBasic) String() string

type AuthBearer

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

func NewAuthBearer

func NewAuthBearer(tokens Tokens) *AuthBearer

func (*AuthBearer) AdminAuth

func (a *AuthBearer) AdminAuth(ctx *fasthttp.RequestCtx) bool

func (*AuthBearer) Auth

func (a *AuthBearer) Auth(ctx *fasthttp.RequestCtx) bool

func (*AuthBearer) GetToken

func (a *AuthBearer) GetToken(ctx *fasthttp.RequestCtx) TokenData

func (*AuthBearer) NewToken added in v1.0.11512

func (a *AuthBearer) NewToken(userData TokenData) (string, error)

func (*AuthBearer) RemoveToken added in v1.0.11512

func (a *AuthBearer) RemoveToken(s string) error

func (*AuthBearer) String

func (a *AuthBearer) String() string

type AuthServer added in v1.2.3

type AuthServer uint8

type FncAuth added in v1.2.93

type FncAuth interface {
	Auth(ctx *fasthttp.RequestCtx) bool
	AdminAuth(ctx *fasthttp.RequestCtx) bool
	String() string
}

func GetAuthManager added in v1.2.93

func GetAuthManager(ctx *fasthttp.RequestCtx) (a FncAuth, ok bool)

type MapTokens added in v1.0.11512

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

func NewMapTokens added in v1.0.11512

func NewMapTokens(expiresIn time.Duration) *MapTokens

func (*MapTokens) GetToken added in v1.0.11512

func (m *MapTokens) GetToken(s string) TokenData

func (*MapTokens) NewToken added in v1.0.11512

func (m *MapTokens) NewToken(userData TokenData) (string, error)

func (*MapTokens) RemoveToken added in v1.0.11512

func (m *MapTokens) RemoveToken(s string) error

func (*MapTokens) SetToken added in v1.2.46

func (m *MapTokens) SetToken(s string, userData TokenData)

type OAuth2 added in v1.2.3

type OAuth2 struct {
	*oauth2.Config
	*AuthBearer
}

func NewOAuth2 added in v1.2.3

func NewOAuth2(clientID, clientSecret, redirectURL string, scopes ...string) *OAuth2

func NewOAuth2WithCustomTokens added in v1.2.3

func NewOAuth2WithCustomTokens(tokens Tokens, clientID, clientSecret, redirectURL string, scopes ...string) *OAuth2

func (*OAuth2) AdminAuth added in v1.2.3

func (a *OAuth2) AdminAuth(ctx *fasthttp.RequestCtx) bool

func (*OAuth2) Auth added in v1.2.3

func (a *OAuth2) Auth(ctx *fasthttp.RequestCtx) bool

func (*OAuth2) DoAuth added in v1.2.3

func (a *OAuth2) DoAuth(ctx *fasthttp.RequestCtx, s AuthServer, state string, authOpts ...oauth2.AuthCodeOption) error

func (*OAuth2) String added in v1.2.3

func (a *OAuth2) String() string

type SimpleTokenData added in v1.2.8

type SimpleTokenData struct {
	Name       string         `json:"name"`
	Desc       string         `json:"desc"`
	Lang       string         `json:"lang"`
	Token      string         `json:"token"`
	Expiry     time.Time      `json:"expiry,omitempty"`
	Extensions map[string]any `json:"extensions,omitempty"`

	Id    int  `json:"id"`
	Admin bool `json:"admin"`
}

func NewSimpleTokenData added in v1.2.8

func NewSimpleTokenData(name, desc, lang string, id int, isAdmin bool, expiry time.Time) *SimpleTokenData

func (*SimpleTokenData) GetUserID added in v1.2.8

func (s *SimpleTokenData) GetUserID() int

func (*SimpleTokenData) IsAdmin added in v1.2.8

func (s *SimpleTokenData) IsAdmin() bool

func (*SimpleTokenData) IsNotExpired added in v1.2.50

func (s *SimpleTokenData) IsNotExpired() bool

func (*SimpleTokenData) WithExtension added in v1.2.47

func (s *SimpleTokenData) WithExtension(key string, value any) *SimpleTokenData

WithExtension sets extension to SimpleTokenData.Extensions and returns SimpleTokenData.

func (*SimpleTokenData) WithToken added in v1.2.48

func (s *SimpleTokenData) WithToken(token string) *SimpleTokenData

WithToken sets token and returns SimpleTokenData.

type TokenData added in v1.0.11512

type TokenData interface {
	IsAdmin() bool
	GetUserID() int
}

type Tokens

type Tokens interface {
	NewToken(userData TokenData) (string, error)
	GetToken(s string) TokenData
	RemoveToken(s string) error
}

Jump to

Keyboard shortcuts

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