Documentation ¶
Overview ¶
Package auth implements the authentication functions for the server.
Index ¶
- Constants
- func Authenticate(db db.DBContext, c echo.Context) (*models.User, error)
- func CheckPassword(raw, hashed string) (bool, error)
- func GeneratePassword(count int) ([]string, error)
- func MustAuth(db *db.DB) echo.MiddlewareFunc
- func PasswordHash(raw string) ([]byte, error)
- func Remove(c echo.Context) error
- func RemoveAdmin(c echo.Context) error
- func Store(u *models.User, timeout time.Duration, c echo.Context) error
- type AdminAuth
Constants ¶
const AdminKeyEnv = "ADMIN_KEY"
AdminKeyEnv is the admin key environment variable to look for.
const (
// AdminSessionName is the key name for the admin session cookie.
AdminSessionName = "kjudge_admin"
)
const SessionName = "kjudge_user"
SessionName is the kjudge session cookie name.
Variables ¶
This section is empty.
Functions ¶
func Authenticate ¶
Authenticate tries to resolve an authentication from the context. Might return a nil user with a nil error.
func CheckPassword ¶
CheckPassword returns whether the raw password matches the hashed password.
func GeneratePassword ¶
GeneratePassword generates random hex passwords of length 8.
func MustAuth ¶
MustAuth returns the middleware that redirects to /login if authentication is not found.
func PasswordHash ¶
PasswordHash hashes a raw string into a hashed password.
func RemoveAdmin ¶
func RemoveAdmin(c echo.Context) error
RemoveAdmin removes the admin cookie session.
Types ¶
type AdminAuth ¶ added in v0.7.5
type AdminAuth struct {
// contains filtered or unexported fields
}
AdminAuth hosts the authentication module for admin.
func (*AdminAuth) AuthenticateAdmin ¶ added in v0.7.5
AuthenticateAdmin returns whether the context has admin panel access.