Skip to content

Retrieving Authentication Information of Reactive Application in JDBC Auditing #2029

Closed as not planned
@kschlesselmann

Description

@kschlesselmann

Currently we're trying to migrate our R2DBC application to JDBC because the MSSQL driver seems to be completely unusable. Right now everything looks fine except user auditing information. It seems the the security context information is simply missing if you try to access the ReactiveSecurityContextHolder from a AuditorAware implementation which @EnableJdbcAuditing seem to require.

To wrap our blocking calls we use this simple pattern

Mono.fromCallable { thingRepository.save(Thing()) }
    .subscribeOn(Schedulers.boundedElastic())

and our JDBC configuration looks like

@Configuration(proxyBeanMethods = false)
@EnableJdbcAuditing
class JdbcConfiguration {

    @Bean
    fun auditorAware(): AuditorAware<String> = AuditorAware {
        ReactiveSecurityContextHolder.getContext()
            .map { it.authentication.name }
            .defaultIfEmpty("NOTHING")
            .blockOptional()
    }
}

We've had a look at the reactor context and it seems that it is properly filled in our code but missing in the AuditorAware. Do you have any suggestions how we can bridge blocking auditing with reactive security?

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: stackoverflowA question that's better suited to stackoverflow.com

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions