Improve SSE status and event auth handling
This commit is contained in:
@@ -9,6 +9,13 @@ import (
|
||||
func bearerAuthMiddleware(requiredToken string) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path == "/api/events" {
|
||||
if r.URL.Query().Get("access_token") == requiredToken {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
auth := r.Header.Get("Authorization")
|
||||
if !strings.HasPrefix(auth, "Bearer ") {
|
||||
writeError(w, http.StatusUnauthorized, "Missing or invalid Authorization header")
|
||||
|
||||
Reference in New Issue
Block a user