ams-spring-boot-shopping: `/products` always returns 403
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java, spring-boot
- 領域
- api, authentication, backend, security
調査の方向性
ams-spring-boot-shopping/src/main/java/com/sap/cloud/security/ams/samples/config/SecurityConfiguration.java の SecurityConfiguration#filterChain から始めます。有効な IAS トークンを使用してリクエストを再現し、その後、AMS 認可が実行される前にリソースサーバーが Jwt をどのように変換するかを調べます。AMS principal が確立され、GET /products と GET /privileges が 403 ではなく期待される認可済みレスポンスを返せば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
In ams-spring-boot-shopping, calling GET /products (and GET /privileges) with a valid IAS token is rejected with HTTP 403, even though the app is bound, token is valid, policies are pushed.
Steps to reproduce
- Deploy the sample as single-tenant IAS app on CF. Bind the app to a IAS app, create app2app trust, create client credentials for the consumer app.
- Obtain a valid IAS token for the consumer app. Make sure to hit the right dependency. Should look like [1]
curl -H "Authorization: Bearer <token>" https://<app>/products
Expected: 200 with the product list (the GetProducts API maps to internal.GetProducts → shopping.ReadProducts → GRANT read ON products).
Actual: 403.
Root cause
The request is authenticated but no AMS principal is ever established, so the AMS authorization check runs against empty authorizations and denies.
SecurityConfiguration#filterChain wires the resource server with:
With the default converter, Spring produces a plain org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken whose principal is a plain org.springframework.security.oauth2.jwt.Jwt, not a SAP com.sap.cloud.security.spring.token.authentication.AuthenticationToken.
The cloud-security JavaSecurityContextHolderStrategy only copies the SAP Token into com.sap.cloud.security.token.SecurityContext when the Spring Authentication's principal is a SAP Token. Because it isn't, SecurityContext.getToken() stays null, so com.sap.cloud.security.ams.api.Principal.fromSecurityContext() returns null, and SciAuthorizationsProvider short-circuits to empty authorizations. Every @CheckPrivilege then evaluates granted=false → 403. Logs here [2].
Direction for a fix
The app needs a jwtAuthenticationConverter that turns the validated IAS Jwt into a SAP AuthenticationToken, so the AMS principal is established. Worked for me afterwards.
[1]
{
"ias_apis": [
"GetProducts"
],
"sub": "consumer",
"aud": "ams-secured-app",
"app_tid": "app-tid",
"sap_id_type": "app",
"azp": "consumer",
"iss": "https://iasid.ondemand.com",
"azpacr": "1",
"exp": 1787302610,
"iat": 1787299010,
"jti": "096f3ac5-adf2-4516-845b-dd295afbfab0"
}
[2]
IasJwtDecoder : The token of service IAS was successfully validated.
BearerTokenAuthenticationFilter : Set SecurityContextHolder to JwtAuthenticationToken
[Principal=org.springframework.security.oauth2.jwt.Jwt@..., Granted Authorities=[]]
SciAuthorizationsProvider : No principal provided. Using empty authorizations.
...
horizationManagerBeforeMethodInterceptor : Failed to authorize ... ProductsService.getProducts()
... result AuthorizationDecision [granted=false]
- 主要言語
- Java
- スター
- 0
- フォーク
- 0
- 平均マージ
- 4時間 34分
- マージ済み PR(30日)
- 10
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SAP-samples/ams-samples-java のほかの issue
-
docs: Javalin sample README claims AMS authorization is an unimplemented TODO, but it is fully implemented対応中かも @finkmanAtSap が 21 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
SAP-samples/ams-samples-java#98 ·
メンテナーはふだん 1 日以内に返信
SAP-samples/ams-samples-java の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
quelea-projection/Quelea#711 ·
-
bug pdd
難易度 2/5 1時間未満 初心者へのやさしさ 67/100
objectionary/eo#9450 ·
メンテナーはふだん 1 日以内に返信
-
[EC2] DescribeAvailabilityZones should return real AWS error for unknown zone name対応中かも @omatheusmesmo が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
area: core good first issue type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ShaftHQ/SHAFT_ENGINE#6909 ·
メンテナーはふだん 1 日以内に返信