Explorar el Código

Optimzied redirection uri

Toby Chui hace 6 meses
padre
commit
b4e28e87c9
Se han modificado 1 ficheros con 5 adiciones y 2 borrados
  1. 5 2
      mod/auth/sso/sso.go

+ 5 - 2
mod/auth/sso/sso.go

@@ -68,18 +68,21 @@ func NewSSOHandler(config *SSOConfig) (*SSOHandler, error) {
 // return false if the request is not authorized and shall not be proceed
 // Note that only accounts that have SSO enabled will be handled by this handler
 func (h *SSOHandler) ServeForwardAuth(w http.ResponseWriter, r *http.Request) bool {
+	//Get the current uri for appending to the auth subdomain
+	originalRequestURL := r.RequestURI
+
 	//Check if the user have the cookie "Zoraxy-SSO" set
 	session, err := h.cookieStore.Get(r, "Zoraxy-SSO")
 	if err != nil {
 		//Redirect to auth subdomain
-		http.Redirect(w, r, h.Config.AuthURL, http.StatusFound)
+		http.Redirect(w, r, h.Config.AuthURL+"?m=new&t="+originalRequestURL, http.StatusFound)
 		return false
 	}
 
 	//Check if the user is logged in
 	if session.Values["username"] != true {
 		//Redirect to auth subdomain
-		http.Redirect(w, r, h.Config.AuthURL, http.StatusFound)
+		http.Redirect(w, r, h.Config.AuthURL+"?m=expired&t="+originalRequestURL, http.StatusFound)
 		return false
 	}