2020-06-05 07:50:04 +02:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
EndpointRoot = "/"
|
|
|
|
EndpointHealthz = "/healthz"
|
|
|
|
EndpointReadiness = "/ready"
|
|
|
|
EndpointLogin = "/login"
|
2020-06-17 08:06:40 +02:00
|
|
|
EndpointLoginName = "/loginname"
|
2020-06-05 07:50:04 +02:00
|
|
|
EndpointUserSelection = "/userselection"
|
|
|
|
EndpointPassword = "/password"
|
|
|
|
EndpointInitPassword = "/password/init"
|
|
|
|
EndpointChangePassword = "/password/change"
|
|
|
|
EndpointPasswordReset = "/password/reset"
|
|
|
|
EndpointInitUser = "/user/init"
|
|
|
|
EndpointMfaVerify = "/mfa/verify"
|
|
|
|
EndpointMfaPrompt = "/mfa/prompt"
|
|
|
|
EndpointMfaInitVerify = "/mfa/init/verify"
|
|
|
|
EndpointMailVerification = "/mail/verification"
|
|
|
|
EndpointMailVerified = "/mail/verified"
|
|
|
|
EndpointRegister = "/register"
|
|
|
|
EndpointLogoutDone = "/logout/done"
|
|
|
|
|
|
|
|
EndpointResources = "/resources"
|
|
|
|
)
|
|
|
|
|
2020-06-17 08:06:40 +02:00
|
|
|
func CreateRouter(login *Login, staticDir http.FileSystem, interceptors ...mux.MiddlewareFunc) *mux.Router {
|
2020-06-05 07:50:04 +02:00
|
|
|
router := mux.NewRouter()
|
2020-06-17 08:06:40 +02:00
|
|
|
router.Use(interceptors...)
|
2020-06-05 07:50:04 +02:00
|
|
|
router.HandleFunc(EndpointRoot, login.handleLogin).Methods(http.MethodGet)
|
|
|
|
router.HandleFunc(EndpointHealthz, login.handleHealthz).Methods(http.MethodGet)
|
|
|
|
router.HandleFunc(EndpointReadiness, login.handleReadiness).Methods(http.MethodGet)
|
|
|
|
router.HandleFunc(EndpointLogin, login.handleLogin).Methods(http.MethodGet, http.MethodPost)
|
2020-06-17 08:06:40 +02:00
|
|
|
router.HandleFunc(EndpointLoginName, login.handleLoginName).Methods(http.MethodGet)
|
|
|
|
router.HandleFunc(EndpointLoginName, login.handleLoginNameCheck).Methods(http.MethodPost)
|
2020-06-05 07:50:04 +02:00
|
|
|
router.HandleFunc(EndpointUserSelection, login.handleSelectUser).Methods(http.MethodPost)
|
|
|
|
router.HandleFunc(EndpointPassword, login.handlePasswordCheck).Methods(http.MethodPost)
|
|
|
|
router.HandleFunc(EndpointInitPassword, login.handleInitPassword).Methods(http.MethodGet)
|
|
|
|
router.HandleFunc(EndpointInitPassword, login.handleInitPasswordCheck).Methods(http.MethodPost)
|
|
|
|
router.HandleFunc(EndpointPasswordReset, login.handlePasswordReset).Methods(http.MethodGet)
|
|
|
|
router.HandleFunc(EndpointInitUser, login.handleInitUser).Methods(http.MethodGet)
|
|
|
|
router.HandleFunc(EndpointInitUser, login.handleInitUserCheck).Methods(http.MethodPost)
|
|
|
|
router.HandleFunc(EndpointMfaVerify, login.handleMfaVerify).Methods(http.MethodPost)
|
2020-07-22 11:43:32 +02:00
|
|
|
router.HandleFunc(EndpointMfaPrompt, login.handleMfaPromptSelection).Methods(http.MethodGet)
|
2020-06-05 07:50:04 +02:00
|
|
|
router.HandleFunc(EndpointMfaPrompt, login.handleMfaPrompt).Methods(http.MethodPost)
|
|
|
|
router.HandleFunc(EndpointMfaInitVerify, login.handleMfaInitVerify).Methods(http.MethodPost)
|
|
|
|
router.HandleFunc(EndpointMailVerification, login.handleMailVerification).Methods(http.MethodGet)
|
|
|
|
router.HandleFunc(EndpointMailVerification, login.handleMailVerificationCheck).Methods(http.MethodPost)
|
|
|
|
router.HandleFunc(EndpointChangePassword, login.handleChangePassword).Methods(http.MethodPost)
|
|
|
|
router.HandleFunc(EndpointRegister, login.handleRegister).Methods(http.MethodGet)
|
|
|
|
router.HandleFunc(EndpointRegister, login.handleRegisterCheck).Methods(http.MethodPost)
|
|
|
|
router.HandleFunc(EndpointLogoutDone, login.handleLogoutDone).Methods(http.MethodGet)
|
|
|
|
router.PathPrefix(EndpointResources).Handler(login.handleResources(staticDir)).Methods(http.MethodGet)
|
|
|
|
return router
|
|
|
|
}
|