contract

package
v0.0.0-...-990f775 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessTokenType = "2"
View Source
var RefreshTokenType = "1"

Functions

This section is empty.

Types

type AuthService

type AuthService interface {
	// Sings in a user with authenticating username and password
	SignIn(db *sql.DB, ctx context.Context, username string, password string) *models.User
	// Signs up a user with minimum required fields
	SignUp(db *sql.DB, ctx context.Context, username string, password string, display_name string) *models.User
}

type Claims

type Claims struct {
	Username string `json:"username"`
	Type     string `json:"type"`
	jwt.StandardClaims
}

type TokenService

type TokenService interface {
	// Returns token string, expire time and error
	CreateAccessToken(user *models.User, ctx context.Context) (string, time.Time)
	// Returns refresh token object, expire time and error
	CreateRefreshToken(db *sql.DB, ctx context.Context, user *models.User) (string, time.Time)
	// Returns a refresh token from database
	GetRefreshToken(db *sql.DB, ctx context.Context, token string) *models.RefreshToken
	// Returns a refresh token from database without panic
	SafeGetRefreshToken(db *sql.DB, ctx context.Context, token string) *models.RefreshToken
	// Deletes a refresh token from database
	DeleteRefreshToken(db *sql.DB, ctx context.Context, token string)
}

type UserService

type UserService interface {
	// Returns user model object based on username
	GetUser(db *sql.DB, ctx context.Context, username string) *models.User
	// Returns user model object based on username safe
	SafeGetUser(db *sql.DB, ctx context.Context, username string) *models.User
	// Creates a user based on required data
	CreateUser(db *sql.DB, ctx context.Context, username string, password string, display_name string) *models.User
	// Returns user model object based on id
	GetUserByID(db *sql.DB, ctx context.Context, id string) *models.User
	// Checks if the passwords match
	CheckPasswordHash(password, hash string) bool
	// Hashes received password
	HashPassword(password string) string
}

Jump to

Keyboard shortcuts

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