initial commit

This commit is contained in:
ston1th 2022-07-10 01:10:31 +02:00
commit f48fa210bb
49 changed files with 4058 additions and 0 deletions

110
pkg/server/routes.go Normal file
View file

@ -0,0 +1,110 @@
// 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"},
},
}