Skip to content

[8.19] Update SAML logs and request ID retrieval (#249037)#262023

Open
jeramysoucy wants to merge 7 commits intoelastic:8.19from
jeramysoucy:backport/8.19/pr-249037
Open

[8.19] Update SAML logs and request ID retrieval (#249037)#262023
jeramysoucy wants to merge 7 commits intoelastic:8.19from
jeramysoucy:backport/8.19/pr-249037

Conversation

@jeramysoucy
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.19:

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
@jeramysoucy jeramysoucy added the backport This PR is a backport of another PR label Apr 8, 2026
@jeramysoucy jeramysoucy enabled auto-merge (squash) April 8, 2026 15:18
@jeramysoucy jeramysoucy requested review from a team and kc13greiner April 9, 2026 14:10
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Apr 9, 2026

💔 Build Failed

Failed CI Steps

Metrics [docs]

Async chunks

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

id before after diff
mockIdpPlugin 35.8KB 35.8KB +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 7.9KB 7.9KB +25.0B

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants