-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(backend): Drop unused `RequiredVerifyTokenOptions` type * chore(backend): Restructure AuthStatus/AuthObject/InterstitialRule types dependencies Instead of passing the `AuthenticateRequestOptions` down the dependency tree `authenticateRequest => interstitialRule => AuthStatus => AuthObjects`, we change the approach to bottom-up by definiting types per layer and importing them to the parent layer. Also options of parent layers extend the options of child layers. * feat(backend): Enforce `request` param in authenticateRequest - replace header related options * chore(backend): Drop usage of x-forwarded-port * chore(repo): Add changeset
- Loading branch information
Showing
11 changed files
with
396 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
'@clerk/backend': major | ||
--- | ||
|
||
Enforce passing `request` param to `authenticateRequest` method of `@clerk/backend` | ||
instead of passing each header or cookie related option that is used internally to | ||
determine the request state. | ||
|
||
Migration guide: | ||
- use `request` param in `clerkClient.authenticateRequest()` instead of: | ||
- `origin` | ||
- `host` | ||
- `forwardedHost` | ||
- `forwardedProto` | ||
- `referrer` | ||
- `userAgent` | ||
- `cookieToken` | ||
- `clientUat` | ||
- `headerToken` | ||
- `searchParams` | ||
|
||
Example | ||
```typescript | ||
// | ||
// current | ||
// | ||
import { clerkClient } from '@clerk/backend' | ||
|
||
const requestState = await clerkClient.authenticateRequest({ | ||
secretKey: 'sk_....' | ||
publishableKey: 'pk_....' | ||
origin: req.headers.get('origin'), | ||
host: req.headers.get('host'), | ||
forwardedHost: req.headers.get('x-forwarded-host'), | ||
forwardedProto: req.headers.get('x-forwarded-proto'), | ||
referrer: req.headers.get('referer'), | ||
userAgent: req.headers.get('user-agent'), | ||
clientUat: req.cookies.get('__client_uat'), | ||
cookieToken: req.cookies.get('__session'), | ||
headerToken: req.headers.get('authorization'), | ||
searchParams: req.searchParams | ||
}); | ||
|
||
// | ||
// new | ||
// | ||
import { clerkClient, } from '@clerk/backend' | ||
|
||
// use req (if it's a fetch#Request instance) or use `createIsomorphicRequest` from `@clerk/backend` | ||
// to re-construct fetch#Request instance | ||
const requestState = await clerkClient.authenticateRequest({ | ||
secretKey: 'sk_....' | ||
publishableKey: 'pk_....' | ||
request: req | ||
}); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.