auth_module

package
v0.0.0-...-adbf6dd Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoginSessionDuration time.Duration

Functions

func DelLoginSession

func DelLoginSession(ctx context.Context, key LoginSessionKey) error

func GenerateAuthTokenString

func GenerateAuthTokenString(account string, roles ...string) (string, error)

func GetGithubOauthEntryURL

func GetGithubOauthEntryURL(callbackURL string) (*url.URL, error)

func ParseAuthTokenString

func ParseAuthTokenString(tokenString string) (string, []string, error)

func SetLoginSession

func SetLoginSession(ctx context.Context, key LoginSessionKey, data LoginSessionData) error

func UpdateLoginSessionByAccount

func UpdateLoginSessionByAccount(ctx context.Context, account string, data LoginSessionData) error

Types

type AuthToken

type AuthToken struct {
	Account string
	Roles   []string
	Expires time.Time
}

func GetAuthTokenFromJWTMapClaims

func GetAuthTokenFromJWTMapClaims(claims jwt.MapClaims) *AuthToken

func (*AuthToken) ToJWTMapClaims

func (a *AuthToken) ToJWTMapClaims() jwt.MapClaims

func (*AuthToken) Valid

func (a *AuthToken) Valid() error

type GithubAccessTokenResponse

type GithubAccessTokenResponse struct {
	AccessToken string `json:"access_token"`
	Scope       string `json:"scope"`
	TokenType   string `json:"token_type"`
}

func GetGithubAccessToken

func GetGithubAccessToken(code string) (*GithubAccessTokenResponse, error)

type GithubUser

type GithubUser struct {
	Login     string `json:"login"`
	Name      string `json:"name"`
	Email     string `json:"email"`
	AvatarURL string `json:"avatar_url"`
}

func GetGithubUser

func GetGithubUser(accessToken string) (*GithubUser, error)

type LoginSession

type LoginSession struct {
	Key  LoginSessionKey
	Data LoginSessionData
}

func GetLoginSession

func GetLoginSession(ctx context.Context, key LoginSessionKey) (*LoginSession, error)

func NewLoginSession

func NewLoginSession(account string, data LoginSessionData) *LoginSession

func (LoginSession) DelInRedis

func (ls LoginSession) DelInRedis(ctx context.Context) error

func (LoginSession) SaveToRedis

func (ls LoginSession) SaveToRedis(ctx context.Context) error

type LoginSessionData

type LoginSessionData struct {
}

func (LoginSessionData) GetJsonString

func (data LoginSessionData) GetJsonString() (string, error)

type LoginSessionKey

type LoginSessionKey struct {
	Account string
	Id      uuid.UUID
}

Jump to

Keyboard shortcuts

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