Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -898,8 +898,6 @@ curl -i -H "Authorization: Bearer $TOKEN" https://<YOUR_GATEWAY>/writer-only
- 🐛 Report bugs via [GitHub Issues](https://github.com/davidcrowe/gatewaystack/issues)
- ⭐ Star the repo if this helps you!

## License

MIT License - see [LICENSE](LICENSE) for details.

Built by [reducibl applied AI studio](https://reducibl.com)
23 changes: 21 additions & 2 deletions apps/gateway-server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { explicablRouter } from "@gatewaystack/explicabl";

import { testEchoRoutes } from "./routes/testEcho";

import rateLimit from "express-rate-limit";

/**
* GatewayStack reference server
*
Expand Down Expand Up @@ -57,6 +59,12 @@ export function buildApp(env: NodeJS.ProcessEnv) {
const windowMs = +(process.env.RATE_LIMIT_WINDOW_MS ?? 60_000);
const limit = +(process.env.RATE_LIMIT_MAX ?? 10);

// Very loose limiter for PRM metadata (satisfies CodeQL, effectively no impact)
const prmLimiter = rateLimit({
windowMs,
max: limit * 100, // extremely generous
});

// -----------------------------
// Core Express setup
// -----------------------------
Expand Down Expand Up @@ -90,14 +98,25 @@ export function buildApp(env: NodeJS.ProcessEnv) {
// Layer 3: Mount validatabl’s PRM router early for public metadata
// validatabl is added as added via requireScope() in the protected area below
// -----------------------------
// app.use(
// protectedResourceRouter({
// issuer: OAUTH_ISSUER.replace(/\/+$/, ""),
// audience: OAUTH_AUDIENCE,
// scopes: OAUTH_SCOPES,
// }) as unknown as RequestHandler
// );

app.use(
"/prm",
prmLimiter,
protectedResourceRouter({
issuer: OAUTH_ISSUER.replace(/\/+$/, ""),
audience: OAUTH_AUDIENCE,
scopes: OAUTH_SCOPES,
}) as unknown as RequestHandler
);


// -----------------------------
// Layer 4: limitabl (per-identity rate limiting)
// -----------------------------
Expand All @@ -109,9 +128,9 @@ export function buildApp(env: NodeJS.ProcessEnv) {
// -----------------------------
app.use(
"/protected",
limitablMiddleware,
identifiablMiddleware,
transformablMiddleware,
limitablMiddleware
transformablMiddleware
);

// READ example (no extra scope)
Expand Down
31 changes: 24 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading