Skip to content

Update SAML logs and request ID retrieval#249037

Merged
jeramysoucy merged 11 commits intoelastic:mainfrom
jeramysoucy:update-saml-logs
Jan 22, 2026
Merged

Update SAML logs and request ID retrieval#249037
jeramysoucy merged 11 commits intoelastic:mainfrom
jeramysoucy:update-saml-logs

Conversation

@jeramysoucy
Copy link
Copy Markdown
Contributor

@jeramysoucy jeramysoucy commented Jan 14, 2026

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 getSAMLRequestId utility function to the mock IDP utils package to remove duplication.

Testing

Mock IDP

[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.
[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.

@jeramysoucy jeramysoucy added Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t// Feature:Security/Authentication Platform Security - Authentication release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Jan 14, 2026
@azasypkin azasypkin self-requested a review January 14, 2026 15:39
@jeramysoucy jeramysoucy marked this pull request as ready for review January 15, 2026 16:22
@jeramysoucy jeramysoucy requested review from a team as code owners January 15, 2026 16:22
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-security (Team:Security)

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/mock-idp-utils 38 40 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
mockIdpPlugin 36.7KB 36.7KB +25.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
mockIdpPlugin 6.7KB 6.7KB +25.0B
Unknown metric groups

API count

id before after diff
@kbn/mock-idp-utils 44 46 +2

History

@rgodfrey-elastic rgodfrey-elastic removed their request for review January 20, 2026 20:46
@jeramysoucy jeramysoucy requested a review from azasypkin January 21, 2026 13:19
Copy link
Copy Markdown
Contributor

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@jeramysoucy jeramysoucy enabled auto-merge (squash) January 22, 2026 16:31
@jeramysoucy jeramysoucy merged commit f87355a into elastic:main Jan 22, 2026
16 checks passed
@jeramysoucy jeramysoucy added backport:version Backport to applied version labels v9.3.0 and removed backport:skip This PR does not require backporting labels Jan 23, 2026
@kibanamachine kibanamachine added backport:skip This PR does not require backporting and removed backport:version Backport to applied version labels labels Jan 23, 2026
@jeramysoucy jeramysoucy added backport:version Backport to applied version labels and removed backport:skip This PR does not require backporting labels Jan 23, 2026
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.3

https://github.com/elastic/kibana/actions/runs/21278963552

@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.3

https://github.com/elastic/kibana/actions/runs/21278963740

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
9.3 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 249037

Questions ?

Please refer to the Backport tool documentation

1 similar comment
@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
9.3 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 249037

Questions ?

Please refer to the Backport tool documentation

@jeramysoucy
Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
9.3

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

jeramysoucy added a commit to jeramysoucy/kibana that referenced this pull request Jan 23, 2026
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
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jan 26, 2026
@kibanamachine
Copy link
Copy Markdown
Contributor

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.
cc: @jeramysoucy

jeramysoucy added a commit that referenced this pull request Jan 26, 2026
# 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-->
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jan 26, 2026
@jeramysoucy jeramysoucy added backport:all-open Backport to all branches that could still receive a release and removed backport:version Backport to applied version labels labels Apr 8, 2026
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19, 9.2, 9.3

https://github.com/elastic/kibana/actions/runs/24140663394

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.19:
- [Ai4DSoc][Serverless] Update search_ai_lake tier specific roles (#229919)
9.2 Backport failed because of merge conflicts
9.3 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 249037

Questions ?

Please refer to the Backport tool documentation

jeramysoucy added a commit to jeramysoucy/kibana that referenced this pull request Apr 8, 2026
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
@jeramysoucy
Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
9.2
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

jeramysoucy added a commit to jeramysoucy/kibana that referenced this pull request Apr 8, 2026
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
jeramysoucy added a commit that referenced this pull request Apr 9, 2026
# 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:all-open Backport to all branches that could still receive a release Feature:Security/Authentication Platform Security - Authentication release_note:skip Skip the PR/issue when compiling release notes Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t// v9.2.9 v9.3.0 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update SAML logs & request id retrieval

5 participants