Cleaning up revoke auth verification for unescaping data, etc.
1 files changed, 21 insertions(+), 14 deletions(-)

M routes.go
M routes.go +21 -14
@@ 751,26 751,33 @@ func (s *Service) RevokeTokenPOST(c echo
 		return s.accessTokenError(c, "invalid_request",
 			"Invalid Authorization header", 400)
 	}
-	z := strings.SplitN(header, " ", 2)
-	if len(z) != 2 {
-		return s.accessTokenError(c, "invalid_request",
-			"Invalid Authorization header", 400)
-	}
-	if strings.ToLower(z[0]) != "basic" {
-		return s.accessTokenError(c, "invalid_request",
+	parts := strings.SplitN(header, " ", 2)
+	if len(parts) != 2 || parts[0] != "Basic" {
+		return s.accessTokenError(c, "invalid_client",
 			"Invalid Authorization header", 400)
 	}
-	idsec, err := base64.StdEncoding.DecodeString(z[1])
+	bytes, err := base64.StdEncoding.DecodeString(parts[1])
 	if err != nil {
-		return s.accessTokenError(c, "invalid_request",
+		return s.accessTokenError(c, "invalid_client",
+			"Invalid Authorization header contents", 400)
+	}
+	auth := string(bytes)
+	if !strings.Contains(auth, ":") {
+		return s.accessTokenError(c, "invalid_client",
 			"Invalid Authorization header", 400)
 	}
-	z = strings.SplitN(string(idsec), ":", 2)
-	if len(z) != 2 {
-		return s.accessTokenError(c, "invalid_request",
-			"Invalid Authorization header", 400)
+	parts = strings.SplitN(auth, ":", 2)
+	clientID, err := url.PathUnescape(parts[0])
+	if err != nil {
+		return s.accessTokenError(c, "invalid_client",
+			"Invalid Authorization header contents", 400)
 	}
-	clientID, clientSecret := z[0], z[1]
+	clientSecret, err := url.PathUnescape(parts[1])
+	if err != nil {
+		return s.accessTokenError(c, "invalid_client",
+			"Invalid Authorization header contents", 400)
+	}
+
 	client, err := GetClientByID(c.Request().Context(), clientID)
 	if err != nil {
 		c.Response().Header().Set("WWW-Authenticate", "Basic")