Ver Fonte

handle oauth state not valid with appropirate message

abhishek9686 há 1 ano atrás
pai
commit
32bcdc728d
2 ficheiros alterados com 3 adições e 3 exclusões
  1. 1 1
      auth/error.go
  2. 2 2
      auth/oidc.go

+ 1 - 1
auth/error.go

@@ -94,7 +94,7 @@ func handleOauthNotConfigured(response http.ResponseWriter) {
 
 func handleOauthNotValid(response http.ResponseWriter) {
 	response.Header().Set("Content-Type", "text/html; charset=utf-8")
-	response.WriteHeader(http.StatusInternalServerError)
+	response.WriteHeader(http.StatusBadRequest)
 	response.Write([]byte(oauthStateInvalid))
 }
 

+ 2 - 2
auth/oidc.go

@@ -2,9 +2,9 @@ package auth
 
 import (
 	"context"
-	"errors"
 	"fmt"
 	"net/http"
+	"strings"
 	"time"
 
 	"github.com/coreos/go-oidc/v3/oidc"
@@ -72,7 +72,7 @@ func handleOIDCCallback(w http.ResponseWriter, r *http.Request) {
 	var content, err = getOIDCUserInfo(rState, rCode)
 	if err != nil {
 		logger.Log(1, "error when getting user info from callback:", err.Error())
-		if errors.Is(err, errors.New("invalid oauth state")) {
+		if strings.Contains(err.Error(), "invalid oauth state") {
 			handleOauthNotValid(w)
 			return
 		}