You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5a7b5c4
Browse filesBrowse the repository at this point in the historyBrowse files
Fix an authentication bypass where a `req.auth` value set by another library (such as `express-jwt`, Passport, or `express-openid-connect`) caused `clerkMiddleware()` and `requireAuth()` to silently skip Clerk authentication, and `getAuth()` to return the unverified foreign value. Clerk now brands the `req.auth` handler it installs and only trusts that handler: `clerkMiddleware()` authenticates the request and overwrites a foreign `req.auth` (logging a warning when it does), and `getAuth()` throws its "middleware required" error instead of reading foreign data.
// Skip authentication only when a Clerk middleware has already processed
152
+
// this request. The brand check matters: a truthy `req.auth` is not proof
153
+
// of that, since express-jwt, passport and other libraries set the same
154
+
// property, and treating their value as ours would silently disable Clerk
155
+
// authentication.
156
+
if(requestHasAuthObject(request)){
144
157
returnnext();
145
158
}
146
159
160
+
if('auth'inrequest){
161
+
logger.warnOnce(
162
+
'Clerk: another middleware has already set `req.auth` on this request. Clerk authentication will run anyway and overwrite it. To use another auth library alongside Clerk, configure it to store its state on a different request property.',
0 commit comments