1
0
Fork 0
mirror of https://github.com/Luzifer/nginx-sso.git synced 2024-10-18 07:34:22 +00:00

Add redirect on root URL to login page

fixes #34
closes #37

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2019-04-21 03:40:28 +02:00
parent 1cb9199bd9
commit e67316431b
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -130,6 +130,7 @@ func main() {
cookieStore = sessions.NewCookieStore([]byte(mainCfg.Cookie.AuthKey))
http.HandleFunc("/", handleRootRequest)
http.HandleFunc("/auth", handleAuthRequest)
http.HandleFunc("/login", handleLoginRequest)
http.HandleFunc("/logout", handleLogoutRequest)
@ -155,6 +156,11 @@ func main() {
}
}
func handleRootRequest(res http.ResponseWriter, r *http.Request) {
// In case of a request to `/` redirect to login utilizing the default redirect
http.Redirect(res, r, "login", http.StatusFound)
}
func handleAuthRequest(res http.ResponseWriter, r *http.Request) {
user, groups, err := detectUser(res, r)