mirror of
https://github.com/aykhans/bsky-feedgen.git
synced 2025-06-06 12:46:47 +00:00
24 lines
524 B
Go
24 lines
524 B
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
const UserDIDKey ContextKey = "user_did"
|
|
|
|
func JWTAuthMiddleware(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
authHeader := r.Header.Get("Authorization")
|
|
if authHeader == "" {
|
|
// No auth header, continue without authentication
|
|
next.ServeHTTP(w, r)
|
|
return
|
|
}
|
|
|
|
// TODO: Add auth verification
|
|
ctx := context.WithValue(r.Context(), UserDIDKey, "")
|
|
next.ServeHTTP(w, r.WithContext(ctx))
|
|
})
|
|
}
|