I am wondering if it is possible to obtain the Authentication
from within the onField
function contained in a SchemaDirectiveWiring
.
I've looked into using the ReactiveSecurityContextHolder
and SecurityContextHolder.getContext().getAuthentication()
and ReactiveSecurityContextHolder.getContext().block().getAuthentication()
, but both return null (which does make sense since its being called from within an asynchronous thread).
I therefore looked into using the [ReactiveDgsContext][1]
which looks promising as when debugging the code, I can see within the reactorContext that there is a SecurityContext key/value, but I don't know how to access it/retrieve it properly.
Currently, my code looks as follows:
DataFetcher<?> authDataFetcher = DataFetcherFactories
.wrapDataFetcher(originalFetcher, ((dataFetchingEnvironment, value) -> {
ReactiveDgsContext context = ReactiveDgsContext.from(dataFetchingEnvironment);
if(context != null){
ContextView reactiveContext = context.getReactorContext();
...
}
Any help would be much appreciated!