Comment on Kotlin usages of SecurityContext.getAuthentication()

Proprietary

Spring Security 7 made SecurityContext.getAuthentication() return @Nullable Authentication. In Kotlin this becomes Authentication?, so existing chains like SecurityContextHolder.getContext().authentication.credentials no longer compile. This recipe adds a TODO comment on the line above each Kotlin statement that reads the authentication — both the explicit getAuthentication() form and the Kotlin property form .authentication — so a developer can decide per call site whether to use a safe-call (?.) or a non-null assertion (!!).

io.moderne.java.spring.security7.CommentOnSecurityContextAuthenticationInKotlin
mod run . --recipe=io.moderne.java.spring.security7.CommentOnSecurityContextAuthenticationInKotlin

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.