Commit 9f1ee3a
feat(security): add automatic production security defaults (#59)
Adds environment-aware security configuration that protects GraphQL APIs in production:
## Features
- **Introspection control**: Auto-disabled in production (NODE_ENV=production)
- **Playground control**: Auto-disabled in production
- **Error masking**: Auto-enabled in production to hide internal errors
- **Field suggestions**: Auto-disabled in production to prevent field discovery
## Configuration
```typescript
// nitro.config.ts
graphql: {
security: {
introspection: true, // default: auto (false in prod)
playground: true, // default: auto (false in prod)
maskErrors: false, // default: auto (true in prod)
disableSuggestions: false, // default: auto (true in prod)
}
}
```
## Console Output
Security status is now shown in the startup box:
```
╭─────────────Nitro GraphQL────────────────╮
│ Security: │
│ ├─ Introspection: disabled │
│ ├─ Playground: disabled │
│ ├─ Error Masking: enabled │
│ └─ Field Suggestions: disabled │
╰──────────────────────────────────────────╯
```
## Research Sources
Based on recommendations from:
- OWASP GraphQL Cheat Sheet
- Apollo Security Best Practices
- GraphQL Yoga Production Guide
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <[email protected]>1 parent 842fae6 commit 9f1ee3a
File tree
5 files changed
+139
-13
lines changed- src
- routes
- types
5 files changed
+139
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
36 | 51 | | |
37 | 52 | | |
38 | 53 | | |
| |||
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
89 | 107 | | |
90 | 108 | | |
91 | 109 | | |
92 | 110 | | |
93 | 111 | | |
94 | | - | |
| 112 | + | |
| 113 | + | |
95 | 114 | | |
96 | 115 | | |
97 | 116 | | |
| |||
214 | 233 | | |
215 | 234 | | |
216 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
217 | 239 | | |
218 | 240 | | |
219 | 241 | | |
220 | 242 | | |
| 243 | + | |
221 | 244 | | |
222 | 245 | | |
223 | 246 | | |
224 | 247 | | |
225 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
226 | 255 | | |
227 | 256 | | |
228 | 257 | | |
229 | | - | |
| 258 | + | |
230 | 259 | | |
231 | 260 | | |
232 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
318 | 323 | | |
319 | 324 | | |
320 | 325 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
105 | 121 | | |
106 | 122 | | |
107 | 123 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
112 | 151 | | |
113 | 152 | | |
114 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
124 | 131 | | |
125 | 132 | | |
126 | | - | |
127 | | - | |
128 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
129 | 148 | | |
130 | 149 | | |
131 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
217 | 246 | | |
218 | 247 | | |
219 | 248 | | |
| |||
268 | 297 | | |
269 | 298 | | |
270 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
271 | 305 | | |
0 commit comments