Skip to content

Commit 6e7b652

Browse files
authored
AMS Java 4.0.6 (#25)
* 4.0.6 CHANGELOG * improve migration guide
1 parent 789890d commit 6e7b652

2 files changed

Lines changed: 50 additions & 19 deletions

File tree

docs/Libraries/java/changelog.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Release Notes for AMS Client Library Java
22

3-
## 4.0.0 - 4.0.5*
3+
## Version 4
4+
5+
### 4.0.6
6+
7+
- Fix: Read Number constants from DCN as `Double` instead of `Long/Int` to avoid runtime errors when comparing with `Double` attribute input
8+
- Fix `AmsCapAutoConfiguration`: Use @Order(-100) for `AmsUserInfoProvider` bean to make sure it runs late in the `UserInfoProvider` chain. For example, this fixes incompatibilities with DwcUserInfoProvider which must run before the `AmsUserInfoProvider` to extract user information from the token.
9+
10+
### 4.0.0 - 4.0.5*
411

512
Version 4 drastically changes the core API to streamline it with the Node.js library which received positive feedback since it introduced the same changes.
613

@@ -17,7 +24,7 @@ during application start. As a result, the authorization checks themselves remai
1724
::: tip ZTIS Auto-Configuration
1825
There is out-of-the-box support for ZTIS service bindings via the Spring Boot starters.
1926
:::
20-
- Domain-Specific `Authorizations` by [wrapping](https://github.com/SAP-samples/ams-samples-java/blob/new_lib_v4/ams-javalin-shopping/src/main/java/com/sap/cloud/security/ams/samples/auth/AuthHandler.java#L68) `Authorizations` objects with [domain-specific methods](https://github.com/SAP-samples/ams-samples-java/blob/new_lib_v4/ams-javalin-shopping/src/main/java/com/sap/cloud/security/ams/samples/auth/ShoppingAuthorizations.java#L27-L46) for [better readability](https://github.com/SAP-samples/ams-samples-java/blob/new_lib_v4/ams-javalin-shopping/src/main/java/com/sap/cloud/security/ams/samples/service/OrdersService.java#L151-L153) and reusability of authorization checks across your application.
27+
- Domain-Specific `Authorizations` by [wrapping](https://github.com/SAP-samples/ams-samples-java/blob/main/ams-javalin-shopping/src/main/java/com/sap/cloud/security/ams/samples/auth/AuthHandler.java#L68) `Authorizations` objects with [domain-specific methods](https://github.com/SAP-samples/ams-samples-java/blob/main/ams-javalin-shopping/src/main/java/com/sap/cloud/security/ams/samples/auth/ShoppingAuthorizations.java#L27-L46) for [better readability](https://github.com/SAP-samples/ams-samples-java/blob/main/ams-javalin-shopping/src/main/java/com/sap/cloud/security/ams/samples/service/OrdersService.java#L151-L153) and reusability of authorization checks across your application.
2128
::: tip CdsAuthorizations
2229
The CAP Spring Boot starter already wraps the standard `Authorizations` in a `CdsAuthorizations` adapter that provides CAP-specific methods for role checks.
2330
:::
@@ -51,17 +58,19 @@ Our performance tests have indicated that the performance impact of authorizatio
5158

5259
For example, for both library versions, the request latency for a localhost CAP OData endpoint with instance-based authorization filters was `<= 5ms` of which most of the time was likely spent on database and network handling instead of the AMS library.
5360

54-
## 3.8.0
61+
## Version 3
62+
63+
### 3.8.0
5564

5665
- This release removes the dependencies from `com.sap.cloud.security.ams.dcl` artifacts. All required classes,
5766
interfaces, etc., are now part of the `jakarta-ams` module using the same packages. So, everything should continue
5867
to work without any changes. Please remove any direct dependencies on `com.sap.cloud.security.ams.dcl` artifacts.
5968

60-
## 3.7.0
69+
### 3.7.0
6170

6271
- Maintenance release with updated dependencies and fixes for the Maven Central release process.
6372

64-
## 3.6.0
73+
### 3.6.0
6574

6675
- The property `cds.security.mock.enabled` is now used to enable the mock users in the
6776
`cap-ams-support` module.

docs/Libraries/java/v3/migration-v3-to-v4.md

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,18 @@ boolean allowed = !authorizations
115115

116116
### Spring Route Security
117117

118-
- Replace `SecurityExpressionHandler` with `AmsRouteSecurity` (CAP: `AmsCdsRouteSecurity`) bean in `SecurityFilterChain`.
118+
- Replace `SecurityExpressionHandler` with `AmsRouteSecurity`/`AmsCdsRouteSecurity` (CAP) bean in `SecurityFilterChain`.
119119
- Update route authorization checks based on following mapping:
120120

121-
| v3 Route Check Syntax | v4 Route Check Syntax |
122-
|--------------------------------------------------------------|------------------------------------------------|
123-
| `hasBaseAuthority("action", "resource")` | `precheckPrivilege("action", "resource")` |
124-
| `forAction("action")` | `checkPrivilege("action", "*")` |
125-
| `forResource("resource")` | `checkPrivilege("*", "resource")` |
126-
| `forResourceAction("resource", "action")` | `checkPrivilege("action", "resource")` |
127-
| `forResourceAction("resource", "action", attributes...)` | use method security instead |
121+
| v3 Route Check Syntax | AmsRouteSecurity | AmsCdsRouteSecurity |
122+
|--------------------------------------------------------------|--------------------------------------------|---------------------------------|
123+
| `hasBaseAuthority("read", "products")` | `precheckPrivilege("read", "products")` ||
124+
| `hasBaseAuthority("Admin", "$SCOPES")` | `precheckPrivilege("Admin", "$SCOPES")` | `precheckRole("Admin")` |
125+
| `forAction("read")` | `checkPrivilege("read", "*")` ||
126+
| `forResource("products")` | `checkPrivilege("*", "products")` ||
127+
| `forResourceAction("products", "read")` | `checkPrivilege("read", "products")` ||
128+
| `forResourceAction("$SCOPES", "Admin")` | `checkPrivilege("Admin", "$SCOPES")` | `checkRole("Admin")` |
129+
| `forResourceAction("products", "read", attributes...)` | use method security | use method security |
128130

129131
**Example**:
130132

@@ -139,19 +141,39 @@ public SecurityFilterChain filterChain(
139141
new WebExpressionAuthorizationManager("hasBaseAuthority('read', 'orders')");
140142
readOrders.setExpressionHandler(amsHttpExpressionHandler);
141143

144+
WebExpressionAuthorizationManager adminRole =
145+
new WebExpressionAuthorizationManager("forResourceAction('$SCOPES', 'Admin')");
146+
adminRole.setExpressionHandler(amsHttpExpressionHandler);
147+
142148
http.authorizeHttpRequests(authz -> authz
143-
.requestMatchers(GET, "/orders/**").access(readOrders));
149+
.requestMatchers(GET, "/orders/**").access(readOrders)
150+
.requestMatchers("/admin/**").access(adminRole));
144151
return http.build();
145152
}
146153
```
147154

148-
```java [v4]
155+
```java [v4 AmsRouteSecurity]
149156
@Bean
150157
public SecurityFilterChain filterChain(HttpSecurity http, AmsRouteSecurity via) {
151158

152159
http.authorizeHttpRequests(authz -> authz
153160
.requestMatchers(GET, "/orders/**")
154-
.access(via.precheckPrivilege("read", "orders")));
161+
.access(via.precheckPrivilege("read", "orders"))
162+
.requestMatchers("/admin/**")
163+
.access(via.checkPrivilege("Admin", "$SCOPES")));
164+
return http.build();
165+
}
166+
```
167+
168+
```java [v4 AmsCdsRouteSecurity (CAP)]
169+
@Bean
170+
public SecurityFilterChain filterChain(HttpSecurity http, AmsCdsRouteSecurity via) {
171+
172+
http.authorizeHttpRequests(authz -> authz
173+
.requestMatchers(GET, "/orders/**")
174+
.access(via.precheckPrivilege("read", "orders"))
175+
.requestMatchers("/admin/**")
176+
.access(via.checkRole("Admin")));
155177
return http.build();
156178
}
157179
```
@@ -201,10 +223,10 @@ Replace the DCL output directory with the new default output directory for AMS D
201223

202224
### CAP Java Configuration
203225

204-
- Remove test sources property from `application.yaml`:
226+
- Remove test sources property from `application.yaml`. It is no longer used:
205227

206228
```yaml
207-
cds:
229+
cds: # [!code --:5]
208230
security:
209231
authorization:
210232
ams:
@@ -217,5 +239,5 @@ In v4, the existence of `spring-boot-starter-ams-cap-test` on the classpath dete
217239

218240
### Spring Security Tests
219241

220-
The `MockOidcTokenRequestPostProcessor.userWithPolicies` from `jakarta-ams-test` has been removed because the real AMS production code can now be tested.
242+
The `MockOidcTokenRequestPostProcessor.userWithPolicies` from `jakarta-ams-test` has been removed because now, the full AMS production code can be tested including the real `AuthorizationProvider`.
221243
It requires the definition of a [policy assignments](/Authorization/Testing#assigning-policies-to-mocked-users) map from which AMS determines the used policies based on the `app_tid` and `scim_id` claims of the token, and for advanced token flows: other claims as needed.

0 commit comments

Comments
 (0)