goacc/pkg/server/routes.go
2022-07-10 01:10:31 +02:00

110 lines
1.7 KiB
Go

// Copyright (C) 2022 Marius Schellenberger
package server
type route struct {
Path string
Handler ctxHandler
Methods []string
}
const (
root = "/"
login = root + "login"
totp = root + "totp"
profile = root + "profile"
consent = root + "consent"
users = root + "users"
logout = root + "logout"
uroot = root + "user/"
userNew = uroot + "new"
userEdit = uroot + "edit/{user:[a-zA-Z0-9]+$}"
userDel = uroot + "del/{user:[a-zA-Z0-9]+$}"
userTotp = uroot + "totp/{user:[a-zA-Z0-9]+$}"
userUnlock = uroot + "unlock/{user:[a-zA-Z0-9]+$}"
)
var routes = []route{
{
root,
jwtHandler(
indexHandler),
[]string{"GET"},
},
{
login,
jwtHandler(
loginHandler),
[]string{"GET", "POST"},
},
{
totp,
jwtHandler(
totpAuthHandler(
loginTotpHandler)),
[]string{"GET", "POST"},
},
{
consent,
jwtHandler(
userAuthHandler(
consentHandler)),
[]string{"GET", "POST"},
},
{
profile,
jwtHandler(
userAuthHandler(
profileHandler)),
[]string{"GET"},
},
{
logout,
jwtHandler(
logoutHandler),
[]string{"GET", "POST"},
},
{
users,
jwtHandler(
adminAuthHandler(
usersHandler)),
[]string{"GET"},
},
{
userNew,
jwtHandler(
adminAuthHandler(
userNewHandler)),
[]string{"GET", "POST"},
},
{
userEdit,
jwtHandler(
userAuthHandler(
userEditHandler)),
[]string{"GET", "POST"},
},
{
userDel,
jwtHandler(
userAuthHandler(
userDelHandler)),
[]string{"GET", "POST"},
},
{
userTotp,
jwtHandler(
userAuthHandler(
userTotpHandler)),
[]string{"GET", "POST"},
},
{
userUnlock,
jwtHandler(
adminAuthHandler(
userUnlockHandler)),
[]string{"POST"},
},
}