Skip to content

Chore/2.2.0#607

Merged
Baroshem merged 9 commits intomainfrom
chore/2.2.0
Mar 4, 2025
Merged

Chore/2.2.0#607
Baroshem merged 9 commits intomainfrom
chore/2.2.0

Conversation

@Baroshem
Copy link
Copy Markdown
Owner

@Baroshem Baroshem commented Mar 4, 2025

This pull request introduces a new feature to the rate limiter middleware by adding a whitelist option, along with several related changes to the codebase and documentation.

New Feature: Whitelist Option for Rate Limiter

  • Rate Limiter Configuration:

    • Added a whiteList property to the RateLimiter type, allowing specific IP addresses to bypass rate limiting. (docs/content/3.middleware/1.rate-limiter.md, src/types/middlewares.ts, src/defaultConfig.ts) [1] [2] [3]
    • Updated documentation to include details about the new whiteList property. (docs/content/3.middleware/1.rate-limiter.md)
  • Implementation in Configuration:

    • Configured the rate limiter with the new whiteList option in various configuration files. (playground/nuxt.config.ts, test/fixtures/rateLimiter/nuxt.config.ts) [1] [2]
  • Middleware Updates:

    • Updated the rate limiter middleware to check if the request's IP is in the whitelist and skip rate limiting if it is. (src/runtime/server/middleware/rateLimiter.ts)
  • Testing:

    • Added new test cases to verify the behavior of the rate limiter with different whitelist configurations. (test/rateLimiter.test.ts)
    • Added new test pages to support the rate limiter tests. (test/fixtures/rateLimiter/pages/whitelistBase.vue, test/fixtures/rateLimiter/pages/whitelistEmpty.vue, test/fixtures/rateLimiter/pages/whitelistNotListed.vue) [1] [2] [3]

Additional Changes

  • Security Configuration:

    • Fixed an issue where securityConfig was not correctly initialized in the basic authentication middleware. (src/runtime/server/middleware/basicAuth.ts)
  • Nonce Handling:

    • Improved the handling of nonces in CSP headers by ensuring existing nonces are replaced instead of duplicated. (src/runtime/nitro/plugins/40-cspSsrNonce.ts) [1] [2]

These changes enhance the flexibility and functionality of the rate limiter middleware, allowing certain IP addresses to bypass rate limiting, and improve the overall security configuration and nonce handling in the application.

Resolves #595
Resolves #586
Resolves #517

zguig52 and others added 8 commits November 28, 2024 14:14
Updated the basicAuth middleware to pass event context into `useRuntimeConfig` composable, ensuring proper access to private settings.
fix(nonce): override user-defined nonce values with Nuxt Image
Add basic rate limiter whitelist (specific IPs only)
Refactor basicAuth middleware to use runtime configuration correctly
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuxt-security ❌ Failed (Inspect) Mar 4, 2025 7:49am

@Baroshem Baroshem merged commit 99019bb into main Mar 4, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

access useRuntimeConfig() within handlers fix(nonce): duplication Rate limiter whitelist

4 participants