auth

package
v0.0.0-...-95fea5c Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyUsernameOrPasswordError = huma.Error400BadRequest("empty username or password")
View Source
var InvalidUsernameOrPasswordError = huma.Error403Forbidden("invalid username or password")

Functions

func GetSessionName

func GetSessionName(userAgent string) (string, error)

func Init

func Init(api huma.API, db database.DBTX)

Types

type AuthController

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

func (*AuthController) Im

func (controller *AuthController) Im(ctx context.Context, request *ImRequest) (*ImResponse, error)

func (*AuthController) SignIn

func (c *AuthController) SignIn(ctx context.Context, request *SignInRequest) (*SignInResponse, error)

func (*AuthController) SignOut

func (controller *AuthController) SignOut(ctx context.Context, request *SignOutRequest) (*SignOutResponse, error)

func (*AuthController) SignUp

func (controller *AuthController) SignUp(ctx context.Context, request *SignUpRequest) (*SignUpResponse, error)

func (*AuthController) Test

func (controller *AuthController) Test(ctx context.Context, request *TestRequest) (*TestResponse, error)

type AuthService

type AuthService interface {
	NewAccessToken(subject string) (string, error)
	NewRefreshToken(subject string) (string, error)
}

type GetUserParams

type GetUserParams struct {
	Id int64
}

func (GetUserParams) GetId

func (params GetUserParams) GetId() int64

func (GetUserParams) GetUsername

func (params GetUserParams) GetUsername() string

type ImRequest

type ImRequest struct {
	SessionId http.Cookie `cookie:"sessionId"`
}

type ImResponse

type ImResponse struct {
	Body struct {
		Id       int64  `json:"id"`
		Username string `json:"username"`
		IsAdmin  bool   `json:"isAdmin"`
	}
}

type SignInRequest

type SignInRequest struct {
	UserAgent string `header:"User-Agent"`
	Body      struct {
		Username string `json:"username"`
		Password string `json:"password"`
	}
}

func (*SignInRequest) GetId

func (request *SignInRequest) GetId() int64

func (*SignInRequest) GetPassword

func (request *SignInRequest) GetPassword() string

func (*SignInRequest) GetUsername

func (request *SignInRequest) GetUsername() string

type SignInResponse

type SignInResponse struct {
	SetCookie http.Cookie `header:"Set-Cookie"`
	Body      struct {
		Ok bool `json:"bool"`
	}
}

type SignOutRequest

type SignOutRequest struct {
	Session http.Cookie `cookie:"session"`
}

type SignOutResponse

type SignOutResponse struct {
	Body struct {
		Ok bool `json:"ok"`
	}
}

type SignUpRequest

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

type SignUpResponse

type SignUpResponse struct {
	Body struct {
		Id       int64  `json:"id"`
		Username string `json:"username"`
		IsAdmin  bool   `json:"isAdmin"`
	}
}

type TestRequest

type TestRequest struct{}

type TestResponse

type TestResponse struct {
	Body string
}

Jump to

Keyboard shortcuts

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