Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BED-4931: Add Audit Logging for SAML Authentication Attempts #913

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

iustinum
Copy link
Contributor

@iustinum iustinum commented Oct 23, 2024

Description

This PR resolves an issue where successful SAML provider logins were not generating LoginAttempt entries in the /api/v2/audit endpoint, despite being logged in the Elastic logs.

Motivation and Context

This change addresses BED-4931.

For secret-based authentication, audit logging is handled within the authenticator.LoginWithSecret() method via auditLogin(), which creates LoginAttempt entries visible in the /api/v2/audit response body. However, in the SAML authentication flow, login attempts were not being audited, as the handler for the /api/v1/login/saml/{saml_provider_name} endpoint did not create equivalent audit log entries.

This PR resolves the issue by introducing audit logging in the SAML authentication handler and ensuring that all login attempts, including those using SAML, are properly logged in the audit trail.

The solution aligns with the existing audit logging pattern and provides a consistent and complete audit trail for SAML authentication attempts.

How Has This Been Tested?

The changes were tested by extending the existing test cases for the SAML login handler. A mock for CreateAuditLog was added to verify that audit log entries are created as expected. The mocking expectations were also updated to reflect the new code flow, including logging for both successful authentication attempts and failures.

Screenshots (optional):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

@iustinum iustinum added bug Something isn't working api A pull request containing changes affecting the API code. labels Oct 23, 2024
@iustinum iustinum self-assigned this Oct 23, 2024
@iustinum iustinum added the blocked This pull request cannot be completed and should not be merged label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api A pull request containing changes affecting the API code. blocked This pull request cannot be completed and should not be merged bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants