Skip to content

Fix SecurityObservationSettings sample in docs - #19583

Open
patbaumgartner wants to merge 1 commit into
spring-projects:mainfrom
patbaumgartner:docs-observation-settings-sample
Open

Fix SecurityObservationSettings sample in docs#19583
patbaumgartner wants to merge 1 commit into
spring-projects:mainfrom
patbaumgartner:docs-observation-settings-sample

Conversation

@patbaumgartner

Copy link
Copy Markdown

The "turn on and off observations individually" sample in the Observability
section does not compile against any released version of Spring Security.

Two problems in the same snippet:

  • The Java sample calls .shouldObserveFilterChains(true).
    SecurityObservationSettings.Builder exposes shouldObserveRequests,
    shouldObserveAuthentications, shouldObserveAuthorizations and build
    there is no shouldObserveFilterChains.
  • The Kotlin sample additionally calls SecurityObservationSettings.builder().
    The class only offers the static factories noObservations() and
    withDefaults(); there is no builder().

Since the surrounding prose is about re-enabling the filter chain observations
that withDefaults() turns off, shouldObserveRequests(true) is the intended
call — observeRequests is the field that gates
spring.security.http.secured.requests.

This changes documentation only; no runtime behaviour is affected.

I ran into this while checking a training module against the reference docs: the
lab used shouldObserveRequests(true) and I initially "corrected" it to match
the documentation, which then failed to compile.

Happy to fold in the Kotlin builder() fix separately if you would rather keep
the two changes apart.

The sample for turning individual observations on and off did not
compile. SecurityObservationSettings.Builder has no
shouldObserveFilterChains method, and SecurityObservationSettings has
no builder() factory. Use shouldObserveRequests and withDefaults
instead, which are the methods the class actually exposes.

Signed-off-by: Patrick Baumgartner <contact@patbaumgartner.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants