Skip to content

Conversation

@supersven
Copy link
Contributor

@supersven supersven commented Jan 6, 2026

Log all changes to SAML IdPs that are triggered via the IdP REST API in Spar.

This was extracted from #4926 to make it easier to digest (i.e. smaller) and to not be blocked on waiting for the email template.

Ticket: https://wearezeta.atlassian.net/browse/WPB-22124

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Jan 6, 2026
@supersven supersven force-pushed the sventennie/log-idp-changes branch 3 times, most recently from b840dbc to 71300fa Compare January 12, 2026 10:44
@supersven supersven marked this pull request as ready for review January 13, 2026 10:57
@supersven supersven requested review from a team as code owners January 13, 2026 10:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds structured logging for all SAML IdP configuration changes (create, update, delete) made through the Spar REST API. The changes include adding a new helper module for certificate string representation, enhancing existing API functions to accept and log user information, and comprehensive unit tests.

Changes:

  • Added logging for IdP create, update, and delete operations with detailed information including team, user, issuer, domain, and certificate details
  • Introduced Data.X509.Extended module with certToString function to format certificate information for logs
  • Added Maybe UserId parameter to IdP API handlers to capture the user making changes

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
services/spar/src/Spar/API.hs Added logging calls to idpCreate, idpDelete, and idpUpdate; changed logger type from String to (Msg -> Msg); added helper functions for logging
libs/wire-api/src/Wire/API/Routes/Public/Spar.hs Added ZOptUser parameter to IdP creation routes to capture user information
libs/wire-api/src/Wire/API/User/IdentityProvider.hs Converted IdPMetadataInfo from simple constructor to record with lenses for easier field access
libs/extended/src/Data/X509.Extended.hs New module providing certificate-to-string formatting for logging
libs/extended/test/Test/Data/X509/ExtendedSpec.hs Unit tests for certificate string formatting
services/spar/test/Test/Spar/Saml/IdPSpec.hs Comprehensive unit tests verifying log output for IdP operations
services/spar/src/Spar/Sem/SAMLUserStore/Mem.hs Implemented previously stubbed mock functions for paginated queries
services/spar/test/resources/okta-keyinfo-1.xml Test data file for certificate parsing tests
libs/extended/test/data/*.pem Test certificate files for extended library tests
services/spar/spar.cabal, services/spar/default.nix Added filepath dependency and test module
libs/extended/extended.cabal, libs/extended/default.nix Added dependencies for X509 and cryptography support
changelog.d/2-features/log-saml-idp-changes Changelog entry describing the feature
Comments suppressed due to low confidence (1)

services/spar/src/Spar/API.hs:870

  • Corrected spelling of 'ommitted' to 'omitted'.
  -- if this step is ommitted (due to a crash) resending the update request should fix the inconsistent state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
deriving (Eq, Show, Generic)

makeLenses ''IdPMetadataInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the value of using lenses here? I thought, we planned to migrate away from them.

Copy link
Contributor Author

@supersven supersven Jan 15, 2026

Choose a reason for hiding this comment

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

Thanks for pointing this out.

Yeah, I was probably under the influence of all the Lenses-code in Spar... 😅 I've removed this makeLenses call now.

@supersven supersven force-pushed the sventennie/log-idp-changes branch from c8f3bac to 8e974b0 Compare January 15, 2026 15:40
@supersven supersven merged commit 80f4236 into develop Jan 16, 2026
11 checks passed
@supersven supersven deleted the sventennie/log-idp-changes branch January 16, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants