tokens

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	LabelAuthUserId    = "auth.management.llmos.ai/user-id"
	LabelAuthTokenKind = "auth.management.llmos.ai/kind"

	LocalProviderName = "local"
	CookieName        = "L_SESS"
	CSRFCookie        = "CSRF"
)
View Source
const (
	AuthHeaderName  = "Authorization"
	AuthValuePrefix = "Bearer"
	BasicAuthPrefix = "Basic"
)

Variables

View Source
var (
	ErrInvalidTokenFormat = errors.New("invalid token format")
)

Functions

func CheckPasswordHash

func CheckPasswordHash(hash, password string) bool

func ConvertTokenKeyToHash

func ConvertTokenKeyToHash(token string) (string, error)

ConvertTokenKeyToHash helps to convert token key to hash

func ExtractTokenFromRequest

func ExtractTokenFromRequest(req *http.Request) string

func HashPassword

func HashPassword(password string) (string, error)

func IsExpired

func IsExpired(token *mgmtv1.Token) bool

func SetTokenExpiresAt

func SetTokenExpiresAt(token *mgmtv1.Token)

func SplitTokenParts

func SplitTokenParts(tokenID string) (string, string)

func VerifyToken

func VerifyToken(token *mgmtv1.Token, tokenName, tokenKey string) (int, error)

VerifyToken helps to check if the token is valid

Types

type Manager

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

func NewManager

func NewManager(scaled *config.Scaled) *Manager

func (*Manager) Logout

func (m *Manager) Logout(req *http.Request, rw http.ResponseWriter) error

func (*Manager) NewAPIKeyToken

func (m *Manager) NewAPIKeyToken(userId string, ttl int64, token *mgmtv1.Token) (*mgmtv1.Token, string, error)

func (*Manager) NewLoginToken

func (m *Manager) NewLoginToken(userId string, ttl int64) (*mgmtv1.Token, string, error)

Jump to

Keyboard shortcuts

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