Update SAML logs and request ID retrieval#249037
Conversation
x-pack/platform/plugins/shared/security/server/authentication/providers/saml.ts
Show resolved
Hide resolved
x-pack/platform/plugins/shared/security/server/authentication/providers/saml.ts
Outdated
Show resolved
Hide resolved
|
Pinging @elastic/kibana-security (Team:Security) |
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
History
|
azasypkin
left a comment
There was a problem hiding this comment.
Looks great, thank you! Just one logging nit. I've tested various scenarios with a mock IdP and can easily reproduce all the error cases we need to worry about locally. Well done!
x-pack/platform/plugins/shared/security/server/authentication/providers/saml.ts
Outdated
Show resolved
Hide resolved
|
Starting backport for target branches: 9.3 https://github.com/elastic/kibana/actions/runs/21278963552 |
|
Starting backport for target branches: 9.3 https://github.com/elastic/kibana/actions/runs/21278963740 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
1 similar comment
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Closes elastic#246963 ## Summary Adds logging of new "unsolicited InResponseTo" error condition returned from Elasticsearch. This will allow us to identify and filter this specific scenario in serverless logs. Additionally, the request ID is now retrieved directly from the Elasticsearch response metadata rather than parsed from the SAML response. This PR also adds parsing of request ID in our mock SAML IDP plugin. This allows us to use the mock IDP for both SP (service provider) initiated and IDP (identity provider) initiated logins. Lastly, this PR moves the `getSAMLRequestId` utility function to the mock IDP utils package to remove duplication. ### Testing #### Mock IDP - Start ES & KB locally in serverless mode - Navigate to the Kibana URL - Verify the redirect to the mock IDP with a SAML request parameter (http://localhost:5601/mock_idp/login?SAMLRequest=<encoded_value>) - Select a role and click Login - Verify logs ``` [INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: ` _SOME_ID` [INFO ][plugins.security.authentication] Performing login attempt with "saml" provider. [INFO ][plugins.security.saml.cloud-saml-kibana] Removing requestId _SAME_ID from the state. ``` - Log out - Navigate directly to the mock IDP (http://localhost:5601/mock_idp/login) - Select a role and click Login - Verify logs ``` [INFO ][plugins.security.authentication] Performing login attempt with "saml" provider. [INFO ][plugins.security.saml.cloud-saml-kibana] No requestId found in SAML response or state does not contain requestId. ... [INFO ][plugins.security.authentication] Login attempt with "saml" provider succeeded (requires redirect: true). ``` #### Unsolicited InResponseTo - Start ES & KB locally in serverless mode - Navigate to the Kibana URL - Open the browser dev tools and delete the "sid" cookie - Click Login - Verify logs ``` [INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: _SOME_ID [INFO ][plugins.security.authentication] Performing login attempt with "saml" provider. [ERROR][plugins.security.saml.cloud-saml-kibana] Failed to log in with SAML response, SP-initiated, unsolicited InResponseTo: _SAME_ID, no state - possible delayed login, current requestIds: , error: {...} [ERROR][plugins.security.authentication] Login attempt with "saml" provider cannot be handled. ``` --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit f87355a) # Conflicts: # packages/kbn-mock-idp-plugin/server/plugin.ts # src/platform/packages/private/kbn-mock-idp-utils/src/index.ts
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
# Backport This will backport the following commits from `main` to `9.3`: - [Update SAML logs and request ID retrieval (#249037)](#249037) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Jeramy Soucy","email":"jeramy.soucy@elastic.co"},"sourceCommit":{"committedDate":"2026-01-22T18:23:53Z","message":"Update SAML logs and request ID retrieval (#249037)\n\nCloses https://github.com/elastic/kibana/issues/246963\n\n## Summary\n\nAdds logging of new \"unsolicited InResponseTo\" error condition returned\nfrom Elasticsearch. This will allow us to identify and filter this\nspecific scenario in serverless logs. Additionally, the request ID is\nnow retrieved directly from the Elasticsearch response metadata rather\nthan parsed from the SAML response.\n\nThis PR also adds parsing of request ID in our mock SAML IDP plugin.\nThis allows us to use the mock IDP for both SP (service provider)\ninitiated and IDP (identity provider) initiated logins.\n\nLastly, this PR moves the `getSAMLRequestId` utility function to the\nmock IDP utils package to remove duplication.\n\n### Testing\n\n#### Mock IDP\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Verify the redirect to the mock IDP with a SAML request parameter\n(http://localhost:5601/mock_idp/login?SAMLRequest=<encoded_value>)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: ` _SOME_ID`\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] Removing requestId _SAME_ID from the state.\n```\n- Log out\n- Navigate directly to the mock IDP\n(http://localhost:5601/mock_idp/login)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] No requestId found in SAML response or state does not contain requestId.\n...\n[INFO ][plugins.security.authentication] Login attempt with \"saml\" provider succeeded (requires redirect: true).\n```\n\n#### Unsolicited InResponseTo\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Open the browser dev tools and delete the \"sid\" cookie\n- Click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: _SOME_ID\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[ERROR][plugins.security.saml.cloud-saml-kibana] Failed to log in with SAML response, SP-initiated, unsolicited InResponseTo: _SAME_ID, no state - possible delayed login, current requestIds: , error: {...}\n[ERROR][plugins.security.authentication] Login attempt with \"saml\" provider cannot be handled.\n```\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"f87355ace3f903f609fd7974e32db2474b795725","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Security","Feature:Security/Authentication","release_note:skip","backport:version","v9.3.0","v9.4.0"],"title":"Update SAML logs and request ID retrieval","number":249037,"url":"https://github.com/elastic/kibana/pull/249037","mergeCommit":{"message":"Update SAML logs and request ID retrieval (#249037)\n\nCloses https://github.com/elastic/kibana/issues/246963\n\n## Summary\n\nAdds logging of new \"unsolicited InResponseTo\" error condition returned\nfrom Elasticsearch. This will allow us to identify and filter this\nspecific scenario in serverless logs. Additionally, the request ID is\nnow retrieved directly from the Elasticsearch response metadata rather\nthan parsed from the SAML response.\n\nThis PR also adds parsing of request ID in our mock SAML IDP plugin.\nThis allows us to use the mock IDP for both SP (service provider)\ninitiated and IDP (identity provider) initiated logins.\n\nLastly, this PR moves the `getSAMLRequestId` utility function to the\nmock IDP utils package to remove duplication.\n\n### Testing\n\n#### Mock IDP\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Verify the redirect to the mock IDP with a SAML request parameter\n(http://localhost:5601/mock_idp/login?SAMLRequest=<encoded_value>)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: ` _SOME_ID`\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] Removing requestId _SAME_ID from the state.\n```\n- Log out\n- Navigate directly to the mock IDP\n(http://localhost:5601/mock_idp/login)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] No requestId found in SAML response or state does not contain requestId.\n...\n[INFO ][plugins.security.authentication] Login attempt with \"saml\" provider succeeded (requires redirect: true).\n```\n\n#### Unsolicited InResponseTo\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Open the browser dev tools and delete the \"sid\" cookie\n- Click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: _SOME_ID\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[ERROR][plugins.security.saml.cloud-saml-kibana] Failed to log in with SAML response, SP-initiated, unsolicited InResponseTo: _SAME_ID, no state - possible delayed login, current requestIds: , error: {...}\n[ERROR][plugins.security.authentication] Login attempt with \"saml\" provider cannot be handled.\n```\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"f87355ace3f903f609fd7974e32db2474b795725"}},"sourceBranch":"main","suggestedTargetBranches":["9.3"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/249037","number":249037,"mergeCommit":{"message":"Update SAML logs and request ID retrieval (#249037)\n\nCloses https://github.com/elastic/kibana/issues/246963\n\n## Summary\n\nAdds logging of new \"unsolicited InResponseTo\" error condition returned\nfrom Elasticsearch. This will allow us to identify and filter this\nspecific scenario in serverless logs. Additionally, the request ID is\nnow retrieved directly from the Elasticsearch response metadata rather\nthan parsed from the SAML response.\n\nThis PR also adds parsing of request ID in our mock SAML IDP plugin.\nThis allows us to use the mock IDP for both SP (service provider)\ninitiated and IDP (identity provider) initiated logins.\n\nLastly, this PR moves the `getSAMLRequestId` utility function to the\nmock IDP utils package to remove duplication.\n\n### Testing\n\n#### Mock IDP\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Verify the redirect to the mock IDP with a SAML request parameter\n(http://localhost:5601/mock_idp/login?SAMLRequest=<encoded_value>)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: ` _SOME_ID`\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] Removing requestId _SAME_ID from the state.\n```\n- Log out\n- Navigate directly to the mock IDP\n(http://localhost:5601/mock_idp/login)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] No requestId found in SAML response or state does not contain requestId.\n...\n[INFO ][plugins.security.authentication] Login attempt with \"saml\" provider succeeded (requires redirect: true).\n```\n\n#### Unsolicited InResponseTo\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Open the browser dev tools and delete the \"sid\" cookie\n- Click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: _SOME_ID\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[ERROR][plugins.security.saml.cloud-saml-kibana] Failed to log in with SAML response, SP-initiated, unsolicited InResponseTo: _SAME_ID, no state - possible delayed login, current requestIds: , error: {...}\n[ERROR][plugins.security.authentication] Login attempt with \"saml\" provider cannot be handled.\n```\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"f87355ace3f903f609fd7974e32db2474b795725"}}]}] BACKPORT-->
|
Starting backport for target branches: 8.19, 9.2, 9.3 https://github.com/elastic/kibana/actions/runs/24140663394 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
Closes elastic#246963 ## Summary Adds logging of new "unsolicited InResponseTo" error condition returned from Elasticsearch. This will allow us to identify and filter this specific scenario in serverless logs. Additionally, the request ID is now retrieved directly from the Elasticsearch response metadata rather than parsed from the SAML response. This PR also adds parsing of request ID in our mock SAML IDP plugin. This allows us to use the mock IDP for both SP (service provider) initiated and IDP (identity provider) initiated logins. Lastly, this PR moves the `getSAMLRequestId` utility function to the mock IDP utils package to remove duplication. ### Testing #### Mock IDP - Start ES & KB locally in serverless mode - Navigate to the Kibana URL - Verify the redirect to the mock IDP with a SAML request parameter (http://localhost:5601/mock_idp/login?SAMLRequest=<encoded_value>) - Select a role and click Login - Verify logs ``` [INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: ` _SOME_ID` [INFO ][plugins.security.authentication] Performing login attempt with "saml" provider. [INFO ][plugins.security.saml.cloud-saml-kibana] Removing requestId _SAME_ID from the state. ``` - Log out - Navigate directly to the mock IDP (http://localhost:5601/mock_idp/login) - Select a role and click Login - Verify logs ``` [INFO ][plugins.security.authentication] Performing login attempt with "saml" provider. [INFO ][plugins.security.saml.cloud-saml-kibana] No requestId found in SAML response or state does not contain requestId. ... [INFO ][plugins.security.authentication] Login attempt with "saml" provider succeeded (requires redirect: true). ``` #### Unsolicited InResponseTo - Start ES & KB locally in serverless mode - Navigate to the Kibana URL - Open the browser dev tools and delete the "sid" cookie - Click Login - Verify logs ``` [INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: _SOME_ID [INFO ][plugins.security.authentication] Performing login attempt with "saml" provider. [ERROR][plugins.security.saml.cloud-saml-kibana] Failed to log in with SAML response, SP-initiated, unsolicited InResponseTo: _SAME_ID, no state - possible delayed login, current requestIds: , error: {...} [ERROR][plugins.security.authentication] Login attempt with "saml" provider cannot be handled. ``` --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit f87355a) # Conflicts: # packages/kbn-mock-idp-plugin/server/plugin.ts # src/platform/packages/private/kbn-mock-idp-utils/src/index.ts # src/platform/packages/private/kbn-mock-idp-utils/src/utils.test.ts # src/platform/packages/private/kbn-mock-idp-utils/src/utils.ts # x-pack/platform/plugins/shared/security/server/authentication/providers/saml.test.ts
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Closes elastic#246963 ## Summary Adds logging of new "unsolicited InResponseTo" error condition returned from Elasticsearch. This will allow us to identify and filter this specific scenario in serverless logs. Additionally, the request ID is now retrieved directly from the Elasticsearch response metadata rather than parsed from the SAML response. This PR also adds parsing of request ID in our mock SAML IDP plugin. This allows us to use the mock IDP for both SP (service provider) initiated and IDP (identity provider) initiated logins. Lastly, this PR moves the `getSAMLRequestId` utility function to the mock IDP utils package to remove duplication. ### Testing #### Mock IDP - Start ES & KB locally in serverless mode - Navigate to the Kibana URL - Verify the redirect to the mock IDP with a SAML request parameter (http://localhost:5601/mock_idp/login?SAMLRequest=<encoded_value>) - Select a role and click Login - Verify logs ``` [INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: ` _SOME_ID` [INFO ][plugins.security.authentication] Performing login attempt with "saml" provider. [INFO ][plugins.security.saml.cloud-saml-kibana] Removing requestId _SAME_ID from the state. ``` - Log out - Navigate directly to the mock IDP (http://localhost:5601/mock_idp/login) - Select a role and click Login - Verify logs ``` [INFO ][plugins.security.authentication] Performing login attempt with "saml" provider. [INFO ][plugins.security.saml.cloud-saml-kibana] No requestId found in SAML response or state does not contain requestId. ... [INFO ][plugins.security.authentication] Login attempt with "saml" provider succeeded (requires redirect: true). ``` #### Unsolicited InResponseTo - Start ES & KB locally in serverless mode - Navigate to the Kibana URL - Open the browser dev tools and delete the "sid" cookie - Click Login - Verify logs ``` [INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: _SOME_ID [INFO ][plugins.security.authentication] Performing login attempt with "saml" provider. [ERROR][plugins.security.saml.cloud-saml-kibana] Failed to log in with SAML response, SP-initiated, unsolicited InResponseTo: _SAME_ID, no state - possible delayed login, current requestIds: , error: {...} [ERROR][plugins.security.authentication] Login attempt with "saml" provider cannot be handled. ``` --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit f87355a) # Conflicts: # packages/kbn-mock-idp-plugin/server/plugin.ts # src/platform/packages/private/kbn-mock-idp-utils/src/index.ts # src/platform/packages/private/kbn-mock-idp-utils/src/utils.test.ts # src/platform/packages/private/kbn-mock-idp-utils/src/utils.ts # x-pack/platform/plugins/shared/security/server/authentication/providers/saml.test.ts
# Backport This will backport the following commits from `main` to `9.2`: - [Update SAML logs and request ID retrieval (#249037)](#249037) <!--- Backport version: 11.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Jeramy Soucy","email":"jeramy.soucy@elastic.co"},"sourceCommit":{"committedDate":"2026-01-22T18:23:53Z","message":"Update SAML logs and request ID retrieval (#249037)\n\nCloses https://github.com/elastic/kibana/issues/246963\n\n## Summary\n\nAdds logging of new \"unsolicited InResponseTo\" error condition returned\nfrom Elasticsearch. This will allow us to identify and filter this\nspecific scenario in serverless logs. Additionally, the request ID is\nnow retrieved directly from the Elasticsearch response metadata rather\nthan parsed from the SAML response.\n\nThis PR also adds parsing of request ID in our mock SAML IDP plugin.\nThis allows us to use the mock IDP for both SP (service provider)\ninitiated and IDP (identity provider) initiated logins.\n\nLastly, this PR moves the `getSAMLRequestId` utility function to the\nmock IDP utils package to remove duplication.\n\n### Testing\n\n#### Mock IDP\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Verify the redirect to the mock IDP with a SAML request parameter\n(http://localhost:5601/mock_idp/login?SAMLRequest=<encoded_value>)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: ` _SOME_ID`\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] Removing requestId _SAME_ID from the state.\n```\n- Log out\n- Navigate directly to the mock IDP\n(http://localhost:5601/mock_idp/login)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] No requestId found in SAML response or state does not contain requestId.\n...\n[INFO ][plugins.security.authentication] Login attempt with \"saml\" provider succeeded (requires redirect: true).\n```\n\n#### Unsolicited InResponseTo\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Open the browser dev tools and delete the \"sid\" cookie\n- Click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: _SOME_ID\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[ERROR][plugins.security.saml.cloud-saml-kibana] Failed to log in with SAML response, SP-initiated, unsolicited InResponseTo: _SAME_ID, no state - possible delayed login, current requestIds: , error: {...}\n[ERROR][plugins.security.authentication] Login attempt with \"saml\" provider cannot be handled.\n```\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"f87355ace3f903f609fd7974e32db2474b795725","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Security","Feature:Security/Authentication","release_note:skip","backport:all-open","v9.3.0","v9.4.0"],"title":"Update SAML logs and request ID retrieval","number":249037,"url":"https://github.com/elastic/kibana/pull/249037","mergeCommit":{"message":"Update SAML logs and request ID retrieval (#249037)\n\nCloses https://github.com/elastic/kibana/issues/246963\n\n## Summary\n\nAdds logging of new \"unsolicited InResponseTo\" error condition returned\nfrom Elasticsearch. This will allow us to identify and filter this\nspecific scenario in serverless logs. Additionally, the request ID is\nnow retrieved directly from the Elasticsearch response metadata rather\nthan parsed from the SAML response.\n\nThis PR also adds parsing of request ID in our mock SAML IDP plugin.\nThis allows us to use the mock IDP for both SP (service provider)\ninitiated and IDP (identity provider) initiated logins.\n\nLastly, this PR moves the `getSAMLRequestId` utility function to the\nmock IDP utils package to remove duplication.\n\n### Testing\n\n#### Mock IDP\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Verify the redirect to the mock IDP with a SAML request parameter\n(http://localhost:5601/mock_idp/login?SAMLRequest=<encoded_value>)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: ` _SOME_ID`\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] Removing requestId _SAME_ID from the state.\n```\n- Log out\n- Navigate directly to the mock IDP\n(http://localhost:5601/mock_idp/login)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] No requestId found in SAML response or state does not contain requestId.\n...\n[INFO ][plugins.security.authentication] Login attempt with \"saml\" provider succeeded (requires redirect: true).\n```\n\n#### Unsolicited InResponseTo\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Open the browser dev tools and delete the \"sid\" cookie\n- Click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: _SOME_ID\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[ERROR][plugins.security.saml.cloud-saml-kibana] Failed to log in with SAML response, SP-initiated, unsolicited InResponseTo: _SAME_ID, no state - possible delayed login, current requestIds: , error: {...}\n[ERROR][plugins.security.authentication] Login attempt with \"saml\" provider cannot be handled.\n```\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"f87355ace3f903f609fd7974e32db2474b795725"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/250168","number":250168,"state":"MERGED","mergeCommit":{"sha":"d03aa163b11d4729f20c19dd1bcefc87314ee927","message":"[9.3] Update SAML logs and request ID retrieval (#249037) (#250168)\n\n# Backport\n\nThis will backport the following commits from `main` to `9.3`:\n- [Update SAML logs and request ID retrieval\n(#249037)](https://github.com/elastic/kibana/pull/249037)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n"}},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/249037","number":249037,"mergeCommit":{"message":"Update SAML logs and request ID retrieval (#249037)\n\nCloses https://github.com/elastic/kibana/issues/246963\n\n## Summary\n\nAdds logging of new \"unsolicited InResponseTo\" error condition returned\nfrom Elasticsearch. This will allow us to identify and filter this\nspecific scenario in serverless logs. Additionally, the request ID is\nnow retrieved directly from the Elasticsearch response metadata rather\nthan parsed from the SAML response.\n\nThis PR also adds parsing of request ID in our mock SAML IDP plugin.\nThis allows us to use the mock IDP for both SP (service provider)\ninitiated and IDP (identity provider) initiated logins.\n\nLastly, this PR moves the `getSAMLRequestId` utility function to the\nmock IDP utils package to remove duplication.\n\n### Testing\n\n#### Mock IDP\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Verify the redirect to the mock IDP with a SAML request parameter\n(http://localhost:5601/mock_idp/login?SAMLRequest=<encoded_value>)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: ` _SOME_ID`\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] Removing requestId _SAME_ID from the state.\n```\n- Log out\n- Navigate directly to the mock IDP\n(http://localhost:5601/mock_idp/login)\n- Select a role and click Login\n- Verify logs\n```\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[INFO ][plugins.security.saml.cloud-saml-kibana] No requestId found in SAML response or state does not contain requestId.\n...\n[INFO ][plugins.security.authentication] Login attempt with \"saml\" provider succeeded (requires redirect: true).\n```\n\n#### Unsolicited InResponseTo\n- Start ES & KB locally in serverless mode\n- Navigate to the Kibana URL\n- Open the browser dev tools and delete the \"sid\" cookie\n- Click Login\n- Verify logs\n```\n[INFO ][plugins.mockIdpPlugin] Sending SAML response for request ID: _SOME_ID\n[INFO ][plugins.security.authentication] Performing login attempt with \"saml\" provider.\n[ERROR][plugins.security.saml.cloud-saml-kibana] Failed to log in with SAML response, SP-initiated, unsolicited InResponseTo: _SAME_ID, no state - possible delayed login, current requestIds: , error: {...}\n[ERROR][plugins.security.authentication] Login attempt with \"saml\" provider cannot be handled.\n```\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"f87355ace3f903f609fd7974e32db2474b795725"}}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes #246963
Summary
Adds logging of new "unsolicited InResponseTo" error condition returned from Elasticsearch. This will allow us to identify and filter this specific scenario in serverless logs. Additionally, the request ID is now retrieved directly from the Elasticsearch response metadata rather than parsed from the SAML response.
This PR also adds parsing of request ID in our mock SAML IDP plugin. This allows us to use the mock IDP for both SP (service provider) initiated and IDP (identity provider) initiated logins.
Lastly, this PR moves the
getSAMLRequestIdutility function to the mock IDP utils package to remove duplication.Testing
Mock IDP
Unsolicited InResponseTo