auth

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCreds

func NewCreds(creds models.CredentialSlice) []webauthn.Credential

Types

type Auth

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

func New

func New(db *bob.DB, issuer string, key string) *Auth

func (*Auth) GetContext

func (*Auth) GetContext(ctx context.Context) (User, bool)

context -> user

func (*Auth) GetUser

func (a *Auth) GetUser(ctx context.Context, userid int32) (User, error)

userid -> db -> user

func (*Auth) GetUserByName

func (a *Auth) GetUserByName(ctx context.Context, username string) (User, error)

username -> db -> user

func (*Auth) GetUserFromToken

func (a *Auth) GetUserFromToken(tokenString string) (User, error)

token -> user

func (*Auth) NewContext

func (*Auth) NewContext(ctx context.Context, user User) context.Context

user -> context

func (*Auth) NewUser

func (a *Auth) NewUser(ctx context.Context, params NewUserParams) error

Insert new user

type Claims

type Claims struct {
	Password         string `json:"password"`
	ProfilePictureID *int32 `json:"profilePictureID"`
	WebauthnID       string `json:"webauthnID"`
	jwt.RegisteredClaims
}

type NewUserParams

type NewUserParams struct {
	Username string
	Password string
}

type User

type User struct {
	models.User
	// contains filtered or unexported fields
}

func (User) Cookie

func (u User) Cookie(expiration time.Duration) *http.Cookie

func (User) ProfilePictureInt

func (u User) ProfilePictureInt() *int32

func (*User) SetPassword

func (u *User) SetPassword(ctx context.Context, password string) error

Update user password

func (*User) SetProfilePicture

func (u *User) SetProfilePicture(ctx context.Context, name string, data []byte) error

Insert/Update Profile Picture

func (User) Token

func (u User) Token(expiration time.Time) string

func (User) Validate

func (u User) Validate(password string) bool

func (User) WebAuthnCredentials

func (u User) WebAuthnCredentials() []webauthn.Credential

func (User) WebAuthnDisplayName

func (u User) WebAuthnDisplayName() string

func (User) WebAuthnID

func (u User) WebAuthnID() []byte

func (User) WebAuthnName

func (u User) WebAuthnName() string

Jump to

Keyboard shortcuts

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