aws / aws/aws-sdk-cpp

cognito-idp: "SECRET_HASH was not received" with USER_SRP_AUTH

オープン
#3,246 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug needs-reproduction
主要言語
C++
スター
2.2k
フォーク
1.2k
平均マージ
3日 14時間
マージ済み PR(30日)
12

説明

### Describe the bug

Hello!
I'm trying to authenticate a user using `CognitoIdentityProviderClient`.

**TL;DR:** Using USER_SRP_AUTH flow and a correct secret_hash, I get a response saying SECRET_HASH was not sent.

Here's the relevant portion of the code:
```
Aws::Map authParameters;
authParameters["USERNAME"] = username.c_str();
// authParameters["PASSWORD"] = password.c_str(); // Used to test with USER_PASSWORD_AUTH below

authParameters["SECRET_HASH"] = "some_secret_hash";
authParameters["SRP_A"] = srp.A();

Aws::CognitoIdentityProvider::CognitoIdentityProviderClient cipClient(clientConfig );

Aws::CognitoIdentityProvider::Model::InitiateAuthRequest authRequest;
authRequest.SetClientId( m_clientID.c_str() );
// authRequest.SetAuthFlow(Aws::CognitoIdentityProvider::Model::AuthFlowType::USER_PASSWORD_AUTH );
authRequest.SetAuthFlow(Aws::CognitoIdentityProvider::Model::AuthFlowType::USER_SRP_AUTH );

authRequest.SetAuthParameters( authParameters );
Aws::Map __authParameters = authRequest.GetAuthParameters();
// check if the correct value is in the map. It is.

Aws::CognitoIdentityProvider::Model::InitiateAuthOutcome authResult = cipClient.InitiateAuth( authRequest );
```

Then I get: "NotAuthorizedException: Client is configured with secret but SECRET_HASH was not received"

- I have tested all the credentials (user, password, pool Id, app ID, secret_hash, SRP_A, same flow type, etc...) with both Python's `boto3` and `requests` and it works fine both ways (i get tokens and challange).

- Strangely, in the c++ version above:
- Using USER_PASSWORD_AUTH flow instead (and provide a password in the `authParameters`), I don't get the error of "SECRET_HASH was not received"
- Using USER_SRP_AUTH and `authParameters["SECRET_HASH"] = "some_INCORRECT_secret_hash"`, I get an error saying the hash was not correct (but it was, apparently, received)

From what I have read in several StackOverflow that SRP doesn't work with apps with secrets, but those threads seem outdated, and the python test seems to disprove that?

Could you please advise? Is this a limitation of the c++ sdk or is this a bug?

Many thanks in advance!

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Expected Behavior

Expect to receive either a success response or an invalid credentials error, but not a "not sent" error.

### Current Behavior

See description of the bug

### Reproduction Steps

See description of the bug

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS CPP SDK version used

1.11.483

### Compiler and Version used

clang-1600.0.26.6

### Operating System and version

macOS 15.2

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

CognitoIdentityProviderClient::InitiateAuth と InitiateAuthRequest の認証パラメーター処理から着手し、SECRET_HASH を指定した USER_SRP_AUTH を再現して USER_PASSWORD_AUTH と比較します。macOS 上で clang を使用し、SDK 1.11.483 でシリアライズされたリクエストが SRP フロー用の SECRET_HASH を保持するか確認します。SRP リクエストが SECRET_HASH の欠落を報告しなくなり、無効な認証情報とハッシュの省略を引き続き区別できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, cpp
領域
api, authentication
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
説明が足りない
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。