aw-spec-cli 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/.appweaver/ORCH-DIALECT.md +17 -5
- package/assets/.appweaver/orchestrator/README.md +1 -1
- package/assets/.appweaver/orchestrator/adapters/claude_agent_sdk.py +2 -2
- package/assets/.appweaver/orchestrator/adapters/google_antigravity.py +28 -6
- package/assets/.appweaver/orchestrator/modules/delta-spec.orch.yaml +13 -1
- package/assets/.appweaver/orchestrator/orchestrator.py +126 -39
- package/assets/.appweaver/orchestrator/workflows/aw-spec-adopt.orch.yaml +5 -0
- package/assets/.appweaver/orchestrator/workflows/aw-spec-characterize.orch.yaml +1 -0
- package/assets/.appweaver/orchestrator/workflows/aw-spec-onboard.orch.yaml +1 -0
- package/assets/.appweaver/orchestrator/workflows/aw-spec-specify.orch.yaml +888 -141
- package/assets/.appweaver/scripts/bash/aw-spec-actions.sh +826 -16
- package/assets/.appweaver/scripts/powershell/aw-spec-actions.ps1 +780 -12
- package/assets/.appweaver/stack-profiles/java-spring.json +3 -3
- package/assets/.appweaver/templates/spec-template.md +73 -62
- package/assets/.appweaver/templates/story-template.md +107 -0
- package/assets/guardrails/technology/java-spring/ai-rules.md +505 -0
- package/assets/guardrails/technology/java-spring/api-versioning.md +782 -0
- package/assets/guardrails/technology/java-spring/authorization.md +618 -0
- package/assets/guardrails/technology/java-spring/clean-architecture.md +960 -0
- package/assets/guardrails/technology/java-spring/coding-standards.md +821 -0
- package/assets/guardrails/technology/java-spring/dependency-policy.md +91 -0
- package/assets/guardrails/technology/java-spring/domain-driven-design.md +467 -0
- package/assets/guardrails/technology/java-spring/domain_abstraction.md +424 -0
- package/assets/guardrails/technology/java-spring/folder-structure.md +1537 -0
- package/assets/guardrails/technology/java-spring/global_exception_handler.md +247 -0
- package/assets/guardrails/technology/java-spring/logging.md +215 -0
- package/assets/guardrails/technology/java-spring/modular-monolith.md +77 -0
- package/assets/guardrails/technology/java-spring/persistence.md +316 -0
- package/assets/guardrails/technology/java-spring/problem_details.md +98 -0
- package/assets/guardrails/technology/java-spring/result_mapping.md +48 -0
- package/assets/guardrails/technology/java-spring/technology-constitution.md +168 -0
- package/assets/guardrails/technology/java-spring/testing.md +601 -0
- package/assets/guardrails/technology/java-spring/zero-trust.md +210 -0
- package/dist/index.js +0 -0
- package/dist/utils/config.d.ts +22 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +76 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/copy-assets.d.ts.map +1 -1
- package/dist/utils/copy-assets.js +4 -11
- package/dist/utils/copy-assets.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +11 -7
- package/dist/utils/paths.js.map +1 -1
- package/package.json +2 -1
- package/assets/guardrails/technology/java-spring/README.md +0 -62
- package/dist/commands/update.d.ts +0 -3
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js +0 -142
- package/dist/commands/update.js.map +0 -1
- package/dist/utils/manifest.d.ts +0 -31
- package/dist/utils/manifest.d.ts.map +0 -1
- package/dist/utils/manifest.js +0 -91
- package/dist/utils/manifest.js.map +0 -1
- package/dist/utils/update-engine.d.ts +0 -52
- package/dist/utils/update-engine.d.ts.map +0 -1
- package/dist/utils/update-engine.js +0 -203
- package/dist/utils/update-engine.js.map +0 -1
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
# Authorization Standards
|
|
2
|
+
|
|
3
|
+
> Common technology guardrail for authorization in AppWeaver Java/Spring applications.
|
|
4
|
+
>
|
|
5
|
+
> Technology-specific and domain-agnostic. Application-specific roles, permissions, and authorization matrices are defined by the applicable application/domain security specification.
|
|
6
|
+
>
|
|
7
|
+
> **NON-NEGOTIABLE where authorization is applicable.**
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Purpose
|
|
12
|
+
|
|
13
|
+
This document defines the standard authorization approach for AppWeaver Java/Spring applications.
|
|
14
|
+
|
|
15
|
+
Authorization MUST ensure that an authenticated identity is permitted to perform an operation according to the application's defined security policy.
|
|
16
|
+
|
|
17
|
+
Authorization is an application/security boundary concern and MUST NOT introduce framework-specific authorization dependencies into the domain model.
|
|
18
|
+
|
|
19
|
+
Application-specific roles and permissions MUST NOT be defined in this common technology guardrail.
|
|
20
|
+
|
|
21
|
+
They MUST be defined by the applicable application security specification, permission matrix, or equivalent project artifact.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 2. Authentication vs Authorization
|
|
26
|
+
|
|
27
|
+
Authentication and authorization are separate concerns.
|
|
28
|
+
|
|
29
|
+
**Authentication** establishes who the caller is.
|
|
30
|
+
|
|
31
|
+
**Authorization** determines what the authenticated caller is allowed to do.
|
|
32
|
+
|
|
33
|
+
An external Identity Provider (IdP), OIDC provider, OAuth 2.0 provider, or locally issued JWT MAY establish identity according to the application's approved authentication architecture.
|
|
34
|
+
|
|
35
|
+
Authorization decisions MUST be based on the application's configured authorization policy.
|
|
36
|
+
|
|
37
|
+
The application MUST NOT assume that an external identity provider's roles or claims automatically represent the application's complete authorization model.
|
|
38
|
+
|
|
39
|
+
External claims MAY be used as authorization inputs when explicitly approved by the application's security architecture.
|
|
40
|
+
|
|
41
|
+
Where application roles and permissions are database-managed, the application's database MUST remain the authoritative source for those application roles and permissions.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 3. Authorization Model
|
|
46
|
+
|
|
47
|
+
AppWeaver supports a role- and permission-based authorization model.
|
|
48
|
+
|
|
49
|
+
Authorization MAY use:
|
|
50
|
+
|
|
51
|
+
* roles;
|
|
52
|
+
* granular permissions/authorities;
|
|
53
|
+
* role-to-permission mappings;
|
|
54
|
+
* resource-specific policies;
|
|
55
|
+
* ownership policies;
|
|
56
|
+
* other explicitly approved authorization policies.
|
|
57
|
+
|
|
58
|
+
The concrete roles, permissions, and mappings are application-specific.
|
|
59
|
+
|
|
60
|
+
They MUST be defined outside this generic technology guardrail.
|
|
61
|
+
|
|
62
|
+
For example:
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
permission-matrix.md
|
|
66
|
+
↓
|
|
67
|
+
Application Authorization Policy
|
|
68
|
+
↓
|
|
69
|
+
Spring Security Authorization
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
AI agents MUST NOT invent application roles or permissions when the applicable permission matrix or security specification already exists.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 4. Secure-by-Default Policy
|
|
77
|
+
|
|
78
|
+
When authorization is applicable, API endpoints MUST be secured by default.
|
|
79
|
+
|
|
80
|
+
Global security configuration SHOULD require authentication for API paths unless an endpoint is explicitly defined as public.
|
|
81
|
+
|
|
82
|
+
Public access MUST be intentional and explicitly configured.
|
|
83
|
+
|
|
84
|
+
AI agents MUST NOT make an endpoint publicly accessible merely to simplify development or testing.
|
|
85
|
+
|
|
86
|
+
The following are examples of endpoints that MAY be public when explicitly required:
|
|
87
|
+
|
|
88
|
+
* health/discovery endpoints;
|
|
89
|
+
* authentication endpoints;
|
|
90
|
+
* authentication callback endpoints;
|
|
91
|
+
* public documentation endpoints.
|
|
92
|
+
|
|
93
|
+
The exact list of public endpoints MUST be determined by the application's security requirements and environment.
|
|
94
|
+
|
|
95
|
+
Documentation endpoints MUST NOT automatically be considered public in every environment.
|
|
96
|
+
|
|
97
|
+
For example:
|
|
98
|
+
|
|
99
|
+
```java
|
|
100
|
+
.authorizeHttpRequests(auth -> auth
|
|
101
|
+
.requestMatchers("/actuator/health").permitAll()
|
|
102
|
+
.requestMatchers("/api/auth/**").permitAll()
|
|
103
|
+
.anyRequest().authenticated()
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The exact public endpoint configuration MUST follow the application's security specification.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 5. Endpoint Authorization
|
|
112
|
+
|
|
113
|
+
Authorization SHOULD be enforced as close as practical to the application operation being protected.
|
|
114
|
+
|
|
115
|
+
Spring Security method authorization MAY be used.
|
|
116
|
+
|
|
117
|
+
For example:
|
|
118
|
+
|
|
119
|
+
```java
|
|
120
|
+
@PreAuthorize("hasAuthority('PROJECT_CREATE')")
|
|
121
|
+
public ResponseEntity<Void> createProject(...) {
|
|
122
|
+
...
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`@PreAuthorize` is an approved implementation mechanism but is not the only valid mechanism.
|
|
127
|
+
|
|
128
|
+
Other approved mechanisms MAY include:
|
|
129
|
+
|
|
130
|
+
* Spring Security request authorization;
|
|
131
|
+
* method-level authorization;
|
|
132
|
+
* custom authorization policies;
|
|
133
|
+
* authorization services;
|
|
134
|
+
* permission evaluators;
|
|
135
|
+
* resource/ownership policies.
|
|
136
|
+
|
|
137
|
+
AI agents MUST use the mechanism established by the application rather than introducing a competing authorization mechanism.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 6. Permission and Authority Naming
|
|
142
|
+
|
|
143
|
+
Application permissions SHOULD use stable, explicit names.
|
|
144
|
+
|
|
145
|
+
Example:
|
|
146
|
+
|
|
147
|
+
```text
|
|
148
|
+
PROJECT_CREATE
|
|
149
|
+
PROJECT_READ
|
|
150
|
+
PROJECT_UPDATE
|
|
151
|
+
PROJECT_DELETE
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Permission names MUST be defined by the application's permission matrix or security specification.
|
|
155
|
+
|
|
156
|
+
AI agents MUST NOT:
|
|
157
|
+
|
|
158
|
+
* invent permissions without a requirement;
|
|
159
|
+
* rename existing permissions without considering compatibility;
|
|
160
|
+
* use database identifiers as externally exposed authority names unless explicitly required;
|
|
161
|
+
* couple domain entities to Spring Security authority names.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 7. Database-Driven Authorization
|
|
166
|
+
|
|
167
|
+
When the application uses database-managed authorization, the database is the authoritative source for application roles and permissions.
|
|
168
|
+
|
|
169
|
+
A typical flow is:
|
|
170
|
+
|
|
171
|
+
```text
|
|
172
|
+
Authenticated Identity
|
|
173
|
+
↓
|
|
174
|
+
Identity Identifier
|
|
175
|
+
↓
|
|
176
|
+
Application Authorization Store
|
|
177
|
+
↓
|
|
178
|
+
Roles / Permissions
|
|
179
|
+
↓
|
|
180
|
+
Granted Authorities
|
|
181
|
+
↓
|
|
182
|
+
Spring Security Authorization
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The authenticated identity may originate from:
|
|
186
|
+
|
|
187
|
+
* an external OIDC/OAuth2 identity provider;
|
|
188
|
+
* a local JWT;
|
|
189
|
+
* another explicitly approved authentication mechanism.
|
|
190
|
+
|
|
191
|
+
The identity provider establishes identity.
|
|
192
|
+
|
|
193
|
+
The application's authorization store determines application-specific permissions when database-driven authorization is configured.
|
|
194
|
+
|
|
195
|
+
AI agents MUST NOT silently replace database-managed authorization with IdP-managed application permissions.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 8. Authentication Identity Mapping
|
|
200
|
+
|
|
201
|
+
When database-backed authorization is used, the authenticated identity MUST be mapped to a stable application identity.
|
|
202
|
+
|
|
203
|
+
A JWT `sub` claim or another stable identity identifier MAY be used.
|
|
204
|
+
|
|
205
|
+
The mapping implementation MUST:
|
|
206
|
+
|
|
207
|
+
* use a stable identifier;
|
|
208
|
+
* avoid relying on mutable display names;
|
|
209
|
+
* handle missing or invalid identities safely;
|
|
210
|
+
* avoid exposing authentication credentials;
|
|
211
|
+
* follow the application's identity model.
|
|
212
|
+
|
|
213
|
+
A custom `AuthenticationProvider`, JWT converter, authorization service, or equivalent mechanism MAY perform this mapping.
|
|
214
|
+
|
|
215
|
+
For example:
|
|
216
|
+
|
|
217
|
+
```java
|
|
218
|
+
@Bean
|
|
219
|
+
SecurityFilterChain securityFilterChain(
|
|
220
|
+
HttpSecurity http,
|
|
221
|
+
DatabaseAuthorizationConverter authorizationConverter
|
|
222
|
+
) throws Exception {
|
|
223
|
+
|
|
224
|
+
http
|
|
225
|
+
.authorizeHttpRequests(auth -> auth
|
|
226
|
+
.requestMatchers("/actuator/health").permitAll()
|
|
227
|
+
.anyRequest().authenticated()
|
|
228
|
+
)
|
|
229
|
+
.oauth2ResourceServer(oauth2 -> oauth2
|
|
230
|
+
.jwt(jwt -> jwt
|
|
231
|
+
.jwtAuthenticationConverter(authorizationConverter)
|
|
232
|
+
)
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
return http.build();
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The exact implementation MUST follow the application's authentication and authorization configuration.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## 9. Authorization and Module Boundaries
|
|
244
|
+
|
|
245
|
+
Authorization MUST respect the Modular Monolith architecture.
|
|
246
|
+
|
|
247
|
+
Authorization checks MUST NOT require direct access to another module's internal implementation.
|
|
248
|
+
|
|
249
|
+
A module MUST NOT bypass another module's authorization boundary by directly accessing:
|
|
250
|
+
|
|
251
|
+
* internal repositories;
|
|
252
|
+
* persistence entities;
|
|
253
|
+
* database tables owned by another module;
|
|
254
|
+
* internal services;
|
|
255
|
+
* internal authorization implementation.
|
|
256
|
+
|
|
257
|
+
Cross-module operations MUST follow the established module contracts and application ports.
|
|
258
|
+
|
|
259
|
+
Authorization policy MAY be centralized when the foundation provides a shared mechanism, but module-specific authorization rules MUST remain owned by the appropriate application/module specification.
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## 10. Domain Independence
|
|
264
|
+
|
|
265
|
+
The domain layer MUST remain independent of Spring Security and HTTP authorization mechanisms.
|
|
266
|
+
|
|
267
|
+
Domain entities, value objects, and domain services MUST NOT depend directly on:
|
|
268
|
+
|
|
269
|
+
* `Authentication`;
|
|
270
|
+
* `SecurityContext`;
|
|
271
|
+
* `GrantedAuthority`;
|
|
272
|
+
* `@PreAuthorize`;
|
|
273
|
+
* Spring Security filters;
|
|
274
|
+
* HTTP request objects;
|
|
275
|
+
* JWT objects;
|
|
276
|
+
* servlet APIs.
|
|
277
|
+
|
|
278
|
+
Authorization decisions that are purely technical/API concerns MUST remain outside the domain layer.
|
|
279
|
+
|
|
280
|
+
Where authorization is itself a domain/business rule, the domain rule MUST remain framework-independent.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## 11. Application Authorization
|
|
285
|
+
|
|
286
|
+
Application/use-case boundaries MAY enforce authorization policies when authorization is required for a business operation.
|
|
287
|
+
|
|
288
|
+
Authorization MUST be applied consistently with the application's security architecture.
|
|
289
|
+
|
|
290
|
+
Example conceptual flow:
|
|
291
|
+
|
|
292
|
+
```text
|
|
293
|
+
HTTP Request
|
|
294
|
+
↓
|
|
295
|
+
Inbound Adapter
|
|
296
|
+
↓
|
|
297
|
+
Authentication
|
|
298
|
+
↓
|
|
299
|
+
Authorization
|
|
300
|
+
↓
|
|
301
|
+
Application Port / Use Case
|
|
302
|
+
↓
|
|
303
|
+
Domain
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Authorization MUST NOT be implemented only in controllers when the same application operation can be invoked through another approved entry point.
|
|
307
|
+
|
|
308
|
+
Where authorization is an application-level concern, the chosen enforcement point MUST protect the actual use case rather than only a specific HTTP route.
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## 12. Resource and Ownership Authorization
|
|
313
|
+
|
|
314
|
+
Some operations require more than a simple permission check.
|
|
315
|
+
|
|
316
|
+
Examples include:
|
|
317
|
+
|
|
318
|
+
* a user can update only their own resource;
|
|
319
|
+
* a manager can access resources belonging to their organization;
|
|
320
|
+
* a user can access only resources belonging to an assigned project.
|
|
321
|
+
|
|
322
|
+
Such policies MAY use resource ownership or contextual authorization.
|
|
323
|
+
|
|
324
|
+
The policy MUST be defined by the application/domain security specification.
|
|
325
|
+
|
|
326
|
+
AI agents MUST NOT infer ownership rules from entity names or database structure.
|
|
327
|
+
|
|
328
|
+
When resource authorization requires domain information, the implementation MUST preserve the domain/application boundaries.
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## 13. Field-Level Data Protection
|
|
333
|
+
|
|
334
|
+
Field-level redaction or data filtering MUST NOT be implemented as ad-hoc controller routing logic.
|
|
335
|
+
|
|
336
|
+
When required, sensitive fields SHOULD be controlled through:
|
|
337
|
+
|
|
338
|
+
* API DTO mapping;
|
|
339
|
+
* projection layers;
|
|
340
|
+
* response mapping;
|
|
341
|
+
* dedicated authorization-aware application services;
|
|
342
|
+
* other approved presentation/application mechanisms.
|
|
343
|
+
|
|
344
|
+
The domain model MUST NOT be modified merely to hide API fields for a particular role.
|
|
345
|
+
|
|
346
|
+
For example:
|
|
347
|
+
|
|
348
|
+
```text
|
|
349
|
+
Domain Object
|
|
350
|
+
↓
|
|
351
|
+
Application Result
|
|
352
|
+
↓
|
|
353
|
+
Authorization-aware Response Mapping
|
|
354
|
+
↓
|
|
355
|
+
API Response
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
The exact mechanism MUST follow the application's established result-mapping and API standards.
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## 14. Cache-Control and Sensitive Responses
|
|
363
|
+
|
|
364
|
+
Sensitive API responses SHOULD prevent unintended caching.
|
|
365
|
+
|
|
366
|
+
Where an endpoint returns sensitive information or performs a security-sensitive state-changing operation, the response SHOULD use:
|
|
367
|
+
|
|
368
|
+
```http
|
|
369
|
+
Cache-Control: no-store
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Example:
|
|
373
|
+
|
|
374
|
+
```java
|
|
375
|
+
return ResponseEntity.ok()
|
|
376
|
+
.cacheControl(CacheControl.noStore())
|
|
377
|
+
.body(response);
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
`no-store` MUST be applied according to the endpoint's data sensitivity and the application's HTTP caching policy.
|
|
381
|
+
|
|
382
|
+
AI agents MUST NOT add or remove cache-control directives arbitrarily.
|
|
383
|
+
|
|
384
|
+
Authorization behavior MUST NOT rely on client-side caching controls as a security mechanism.
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## 15. Error Handling
|
|
389
|
+
|
|
390
|
+
Authorization failures MUST use the application's established API error-handling mechanism.
|
|
391
|
+
|
|
392
|
+
AI agents MUST NOT introduce a separate authorization error response format.
|
|
393
|
+
|
|
394
|
+
When applicable:
|
|
395
|
+
|
|
396
|
+
* exception handling MUST follow `global_exception_handler.md`;
|
|
397
|
+
* API error representation MUST follow `problem_details.md`;
|
|
398
|
+
* HTTP/result mapping MUST follow `result_mapping.md`.
|
|
399
|
+
|
|
400
|
+
Typical HTTP semantics include:
|
|
401
|
+
|
|
402
|
+
```text
|
|
403
|
+
401 Unauthorized
|
|
404
|
+
→ Authentication is missing or invalid.
|
|
405
|
+
|
|
406
|
+
403 Forbidden
|
|
407
|
+
→ Authentication succeeded but authorization failed.
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
The exact API response structure MUST follow the application's established error contract.
|
|
411
|
+
|
|
412
|
+
Sensitive authorization information MUST NOT be exposed through error responses.
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## 16. Security Configuration
|
|
417
|
+
|
|
418
|
+
Spring Security MAY be used as the authorization implementation framework.
|
|
419
|
+
|
|
420
|
+
Security configuration MUST remain within the appropriate adapter/infrastructure areas of the AppWeaver Java foundation.
|
|
421
|
+
|
|
422
|
+
Security configuration MUST:
|
|
423
|
+
|
|
424
|
+
* secure protected API endpoints;
|
|
425
|
+
* explicitly define public endpoints;
|
|
426
|
+
* use approved authentication mechanisms;
|
|
427
|
+
* enforce applicable authorization policies;
|
|
428
|
+
* avoid insecure defaults;
|
|
429
|
+
* preserve existing security behavior.
|
|
430
|
+
|
|
431
|
+
AI agents MUST NOT disable security globally to resolve implementation problems.
|
|
432
|
+
|
|
433
|
+
Examples of forbidden behavior include:
|
|
434
|
+
|
|
435
|
+
```java
|
|
436
|
+
.anyRequest().permitAll()
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
or globally disabling authorization checks to make an endpoint work.
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## 17. Authorization and Environment Configuration
|
|
444
|
+
|
|
445
|
+
Authorization behavior MAY differ by environment where explicitly required.
|
|
446
|
+
|
|
447
|
+
For example:
|
|
448
|
+
|
|
449
|
+
* development;
|
|
450
|
+
* test;
|
|
451
|
+
* staging;
|
|
452
|
+
* production.
|
|
453
|
+
|
|
454
|
+
Environment-specific configuration MUST NOT weaken production authorization controls unintentionally.
|
|
455
|
+
|
|
456
|
+
Development-only bypasses MUST NOT be enabled in production.
|
|
457
|
+
|
|
458
|
+
AI agents MUST NOT hard-code credentials, secrets, production identities, or authorization bypasses into source code.
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## 18. Testing Requirements
|
|
463
|
+
|
|
464
|
+
Authorization behavior MUST be covered by appropriate automated tests when authorization is applicable.
|
|
465
|
+
|
|
466
|
+
Tests SHOULD verify, where relevant:
|
|
467
|
+
|
|
468
|
+
* unauthenticated access;
|
|
469
|
+
* authenticated access;
|
|
470
|
+
* permitted operations;
|
|
471
|
+
* denied operations;
|
|
472
|
+
* role/permission mappings;
|
|
473
|
+
* ownership rules;
|
|
474
|
+
* resource-level authorization;
|
|
475
|
+
* protected endpoints;
|
|
476
|
+
* public endpoints;
|
|
477
|
+
* authorization failure responses;
|
|
478
|
+
* regression behavior for existing permissions.
|
|
479
|
+
|
|
480
|
+
Security tests MUST NOT weaken production security configuration merely to make tests pass.
|
|
481
|
+
|
|
482
|
+
Tests MAY use dedicated test identities, mock authentication, or test authorization stores according to the project's testing standards.
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## 19. AI / AW-Spec Rules
|
|
487
|
+
|
|
488
|
+
When authorization is applicable, AI-generated code MUST:
|
|
489
|
+
|
|
490
|
+
* inspect the existing authorization configuration;
|
|
491
|
+
* inspect the applicable permission matrix or security specification;
|
|
492
|
+
* identify the required permission before implementing endpoint authorization;
|
|
493
|
+
* reuse existing authorization abstractions;
|
|
494
|
+
* preserve existing authentication and authorization behavior;
|
|
495
|
+
* follow the established Spring Security configuration;
|
|
496
|
+
* follow the established error-handling mechanism;
|
|
497
|
+
* respect module boundaries;
|
|
498
|
+
* keep authorization concerns outside the domain unless the authorization rule is genuinely a domain rule;
|
|
499
|
+
* add or update appropriate authorization tests.
|
|
500
|
+
|
|
501
|
+
AI agents MUST NOT:
|
|
502
|
+
|
|
503
|
+
* invent application permissions without a defined requirement;
|
|
504
|
+
* introduce a second authorization mechanism;
|
|
505
|
+
* bypass existing authorization;
|
|
506
|
+
* make protected endpoints public;
|
|
507
|
+
* use `permitAll()` merely to simplify development;
|
|
508
|
+
* expose sensitive fields without considering the applicable authorization policy;
|
|
509
|
+
* put Spring Security dependencies into the domain layer;
|
|
510
|
+
* directly access another module's authorization internals;
|
|
511
|
+
* disable security globally;
|
|
512
|
+
* embed credentials or security secrets;
|
|
513
|
+
* replace database-driven application permissions with IdP claims when database authorization is the approved application model.
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## 20. Forbidden Patterns
|
|
518
|
+
|
|
519
|
+
The following patterns are forbidden:
|
|
520
|
+
|
|
521
|
+
```text
|
|
522
|
+
Controller → Database authorization tables directly
|
|
523
|
+
|
|
524
|
+
Controller → JPA Repository for permission lookup
|
|
525
|
+
|
|
526
|
+
Domain Entity → Spring Security
|
|
527
|
+
|
|
528
|
+
Domain Entity → Authentication
|
|
529
|
+
|
|
530
|
+
Domain Entity → GrantedAuthority
|
|
531
|
+
|
|
532
|
+
Domain Entity → JWT
|
|
533
|
+
|
|
534
|
+
Domain Entity → HTTP security context
|
|
535
|
+
|
|
536
|
+
Feature → Duplicate Authorization Framework
|
|
537
|
+
|
|
538
|
+
Endpoint → permitAll() without an approved public-access requirement
|
|
539
|
+
|
|
540
|
+
Security Configuration → Global authorization bypass
|
|
541
|
+
|
|
542
|
+
Application → Hard-coded credentials
|
|
543
|
+
|
|
544
|
+
Application → Hard-coded production authorization bypass
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
Authorization MUST follow the established architectural boundaries.
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
## 21. Foundation Package Placement
|
|
552
|
+
|
|
553
|
+
Authorization implementation MUST follow the predefined AppWeaver Java foundation.
|
|
554
|
+
|
|
555
|
+
Production code MUST remain under:
|
|
556
|
+
|
|
557
|
+
```text
|
|
558
|
+
backend/src/main/java/io/appweaver/
|
|
559
|
+
├── adapter/
|
|
560
|
+
├── application/
|
|
561
|
+
├── domain/
|
|
562
|
+
└── infrastructure/
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
Authorization-related implementation MUST be placed in the appropriate existing package according to its responsibility.
|
|
566
|
+
|
|
567
|
+
For example:
|
|
568
|
+
|
|
569
|
+
* HTTP/security adapter concerns belong in the appropriate `adapter` package.
|
|
570
|
+
* Application authorization policies belong in the appropriate `application` package when required.
|
|
571
|
+
* Domain authorization rules belong in `domain` only when they represent genuine domain/business rules.
|
|
572
|
+
* Spring Security configuration and infrastructure-specific security implementation belong in the appropriate `infrastructure` package.
|
|
573
|
+
|
|
574
|
+
AI agents MUST NOT create a new top-level package under `io.appweaver`.
|
|
575
|
+
|
|
576
|
+
The exact subpackage structure MUST follow the active Java foundation and existing project conventions.
|
|
577
|
+
|
|
578
|
+
---
|
|
579
|
+
|
|
580
|
+
## 22. Governance
|
|
581
|
+
|
|
582
|
+
Authorization changes MUST comply with:
|
|
583
|
+
|
|
584
|
+
* the project constitution;
|
|
585
|
+
* the AppWeaver Java foundation;
|
|
586
|
+
* the Modular Monolith architecture;
|
|
587
|
+
* the Hexagonal Architecture / Ports and Adapters rules;
|
|
588
|
+
* the application's permission matrix;
|
|
589
|
+
* applicable authentication standards;
|
|
590
|
+
* applicable cross-cutting guardrails;
|
|
591
|
+
* applicable application/module security requirements.
|
|
592
|
+
|
|
593
|
+
Application-specific roles, permissions, and authorization matrices MUST NOT be hard-coded into this generic technology guardrail.
|
|
594
|
+
|
|
595
|
+
Changes to this document MUST follow the project's applicable governance and constitution amendment process.
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
## 23. Summary of Standards
|
|
600
|
+
|
|
601
|
+
When authorization is applicable, AppWeaver Java applications MUST follow these principles:
|
|
602
|
+
|
|
603
|
+
* Authorization MUST be secure by default.
|
|
604
|
+
* Application-specific roles and permissions MUST come from the applicable security specification or permission matrix.
|
|
605
|
+
* Database-backed roles and permissions are the standard AppWeaver model when database-driven authorization is configured.
|
|
606
|
+
* Authentication establishes identity; authorization determines application access.
|
|
607
|
+
* External IdP claims MUST NOT automatically be treated as the application's authoritative permission model when database-driven authorization is configured.
|
|
608
|
+
* Public endpoints MUST be explicitly approved.
|
|
609
|
+
* `@PreAuthorize` and other Spring Security mechanisms MAY be used according to the application's established security design.
|
|
610
|
+
* Authorization MUST respect Modular Monolith module boundaries.
|
|
611
|
+
* Domain code MUST remain independent of Spring Security and HTTP concerns.
|
|
612
|
+
* Sensitive response data MUST be protected according to the applicable authorization and API policies.
|
|
613
|
+
* Sensitive responses SHOULD use `Cache-Control: no-store` where appropriate.
|
|
614
|
+
* Authorization failures MUST follow the application's established error and Problem Details standards.
|
|
615
|
+
* Authorization behavior MUST have appropriate automated tests.
|
|
616
|
+
* Security controls MUST NOT be globally disabled.
|
|
617
|
+
* All production authorization implementation MUST remain within the predefined AppWeaver Java foundation structure.
|
|
618
|
+
* AI-generated authorization changes MUST reuse established AppWeaver security mechanisms rather than creating competing implementations.
|