clerk / clerk-sdk-go

Access the Clerk Backend API from Go
MIT License
87 stars 19 forks source link

Allow custom JWT extractor in HTTP middleware #303

Closed kbrgl closed 1 month ago

kbrgl commented 3 months ago

Currently, this library requires that the JWT be specified as a bearer token in the Authorization header.

However, this doesn't work for WebSockets, since the browser WebSocket API does not allow passing custom headers. The preferred solution in this case is to pass the header value in Sec-WebSocket-Protocol instead.

Would it be possible to support this in this Go library?

Basically, this just means allowing the user to pass a function with signature func(r *http.Request) string as an option, and defaulting this option to a function that extracts the JWT from Authorization header as usual.

gkats commented 1 month ago

Closed by #304