auth

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AUTH_REQUIRED_GQL_ERROR = &gqlerror.Error{
	Message: "Authentication required to perform this action",
	Extensions: map[string]interface{}{
		"code": 401,
	},
}
View Source
var PERMISSION_DENIED_GQL_ERROR = &gqlerror.Error{
	Message: "User is not authorized to perform this action",
	Extensions: map[string]interface{}{
		"code": 403,
	},
}

Functions

func AuthMiddleware

func AuthMiddleware(cbleConfig *config.Config, client *ent.Client) gin.HandlerFunc

Looks up the ENT user object from the session token and injects into context

func DeleteAuthCookie

func DeleteAuthCookie(c *gin.Context, cbleConfig *config.Config)

func ForContext

func ForContext(ctx context.Context) (*ent.User, error)

ForContext finds the user from the context. REQUIRES Middleware to have run.

func Login

func Login(cbleConfig *config.Config, client *ent.Client) gin.HandlerFunc

func Logout

func Logout(cbleConfig *config.Config) gin.HandlerFunc

Types

type UserLoginInput

type UserLoginInput struct {
	Username string `form:"username" json:"username" binding:"required" example:"admin"`
	Password string `form:"password" json:"password" binding:"required" example:"password123"`
}

Jump to

Keyboard shortcuts

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