-
Notifications
You must be signed in to change notification settings - Fork 509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: Protecting TypeScript NestJS Web API Template #2362
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe pull request updates the document Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@djnovin is attempting to deploy a commit to the Unkey Team on Vercel. A member of the Team first needs to authorize it. |
Thank you for following the naming conventions for pull request titles! 🙏 |
private async validateBearerToken(token: string): Promise<boolean> {
const validationResponse = await verifyKey(token);
if (!validationResponse) return false;
if (validationResponse.error) return false;
return true;
} This is completely insecure and does not check the status of verification at all. Also looks like you copy pasted from another template, so your setup and testing instructions are wrong |
Updated to utilise private async validateBearerToken(token: string): Promise<boolean> {
try {
const { result } = await verifyKey(token);
return result.valid;
} catch (err) {
return false;
}
}
I have also updated PR instructions to point to correct |
Awarding djnovin: 750 points 🕹️ Well done! Check out your new contribution on oss.gg/djnovin |
Co-authored-by: Andreas Thomas <[email protected]>
Co-authored-by: Andreas Thomas <[email protected]>
* fix:changed the permission view * fixed issue comments * added validation * added validation * [autofix.ci] apply automated fixes * removed font * Add Template to Markdown (#2362) Co-authored-by: Andreas Thomas <[email protected]> * fix: retry on any error with disabled cache * latest code --------- Co-authored-by: Andreas Thomas <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: djnovin <[email protected]>
* fix: Missing plan check and ip whitelist parsing * fix: adjust tests for ipwhitelist * fix: Rename error code Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: ipwhitelist via features vs enterprise plan * fix: invert condition * chore: add cache log * fix: ensure workspace is loaded (#2470) * chore: more logging and retries (#2475) * Update 7_create_a_template.md (#2471) * increase override limit * Update create-new-override.tsx * fix: Enhance API Key Detail Page: Change Permissions Visualization to Tree Format (#2238) * fix:changed the permission view * fixed issue comments * [autofix.ci] apply automated fixes * removed font --------- Co-authored-by: Andreas Thomas <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix: show shallow permissions followed by nested in alphabetical order (#2273) * fix: show shallow permissions followed by nested in alphabetical order * fix: correct the sorting of nested permissions top level keys * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * Add Template to Markdown (#2362) Co-authored-by: Andreas Thomas <[email protected]> * fix: retry on any error with disabled cache --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: chronark <[email protected]> Co-authored-by: Chirag Arora <[email protected]> Co-authored-by: RajuGangitla <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Anne Deepa Prasanna <[email protected]> Co-authored-by: djnovin <[email protected]>
What does this PR do?
In this pull request, I've integrated Unkey to provide route protection and rate limiting for the application for hackathon. This is a side quest to make a template using a framework.
API Key Verification: Added middleware to verify API keys using Unkey. Only requests with valid API keys in the Authorization header (Bearer token) are allowed to access protected routes.
Fixes #2361
If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists
Type of change
How should this be tested?
curl http://localhost:3000/api/v1/protected -H "Authorization: Bearer <YOUR_API_KEY>"
Checklist
Required
pnpm build
pnpm fmt
console.logs
git pull origin main
Appreciated
Summary by CodeRabbit
Summary by CodeRabbit