auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthenticationHeader = "MixerAuth"
)
View Source
const (
	UserTable = "user"
)

Variables

View Source
var ErrInvalidToken = errors.New("invalid token")
View Source
var UserModelStruct = sqlbuilder.NewStruct(new(UserModel))

Functions

func GenerateAccessToken

func GenerateAccessToken(i TokenInputs) (string, error)

func Init

func Init(r *mux.Router, db *sql.DB) error

func RequiresValidAccessToken

func RequiresValidAccessToken(handler ClaimsHttpHandler) common.HttpHandler

Types

type Claims

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

type ClaimsHttpHandler

type ClaimsHttpHandler func(http.ResponseWriter, *http.Request, Claims)

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	Error        string `json:"error,omitempty"`
	Success      bool   `json:"success"`
	AccessToken  string `json:"access_token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
}

type RefreshTokenResponse

type RefreshTokenResponse struct {
	Error       string `json:"error,omitempty"`
	Success     bool   `json:"success"`
	AccessToken string `json:"access_token,omitempty"`
}

type RegisterNewUserRequest

type RegisterNewUserRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type RegisterNewUserResponse

type RegisterNewUserResponse struct {
	Error   string `json:"error,omitempty"`
	Success bool   `json:"success"`
}

type TokenInputs

type TokenInputs struct {
	Username string
}

type User

type User struct {
	Username string
	Password string
}

type UserModel

type UserModel struct {
	Username string `db:"username"`
	Password string `db:"password"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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