mirror of
https://github.com/Luzifer/nginx-sso.git
synced 2025-04-14 03:01:52 +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:
parent
1cb9199bd9
commit
e67316431b
1 changed files with 6 additions and 0 deletions
6
main.go
6
main.go
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue