Class AbstractAuthenticationWebSocketInterceptor
java.lang.Object
org.springframework.graphql.server.support.AbstractAuthenticationWebSocketInterceptor
- All Implemented Interfaces:
- WebGraphQlInterceptor,- WebSocketGraphQlInterceptor
- Direct Known Subclasses:
- AuthenticationWebSocketInterceptor,- AuthenticationWebSocketInterceptor
public abstract class AbstractAuthenticationWebSocketInterceptor
extends Object
implements WebSocketGraphQlInterceptor
Base class for interceptors that extract an 
Authentication from
 the payload of a "connection_init" GraphQL over WebSocket message.
 The authentication is saved in WebSocket attributes from where it is later
 accessed and propagated to subsequent "subscribe" messages.- Since:
- 1.3.0
- Author:
- Joshua Cummings, Rossen Stoyanchev
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.graphql.server.WebGraphQlInterceptorWebGraphQlInterceptor.Chain
- 
Constructor SummaryConstructorsConstructorDescriptionConstructor with the strategy to use to extract the authentication value from the"connection_init"message.
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract reactor.core.publisher.Mono<org.springframework.security.core.Authentication>authenticate(org.springframework.security.core.Authentication authentication) Subclasses implement this method to return an authenticatedSecurityContextor an error.protected abstract reactor.util.context.ContextViewgetContextToWrite(org.springframework.security.core.context.SecurityContext securityContext) Subclasses implement this to decide how to insert theSecurityContextinto the Reactor context of theWebSocketGraphQlInterceptorchain.reactor.core.publisher.Mono<Object>handleConnectionInitialization(WebSocketSessionInfo info, Map<String, Object> payload) Handle the"connection_init"message at the start of a GraphQL over WebSocket session and return an optional payload for the"connection_ack"message to send back.reactor.core.publisher.Mono<WebGraphQlResponse>intercept(WebGraphQlRequest request, WebGraphQlInterceptor.Chain chain) Intercept a request and delegate to the rest of the chain including other interceptors and aExecutionGraphQlService.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.graphql.server.WebGraphQlInterceptorandThen, applyMethods inherited from interface org.springframework.graphql.server.WebSocketGraphQlInterceptorhandleCancelledSubscription, handleConnectionClosed
- 
Constructor Details- 
AbstractAuthenticationWebSocketInterceptorConstructor with the strategy to use to extract the authentication value from the"connection_init"message.- Parameters:
- authExtractor- the extractor to use
 
 
- 
- 
Method Details- 
handleConnectionInitializationpublic reactor.core.publisher.Mono<Object> handleConnectionInitialization(WebSocketSessionInfo info, Map<String, Object> payload) Description copied from interface:WebSocketGraphQlInterceptorHandle the"connection_init"message at the start of a GraphQL over WebSocket session and return an optional payload for the"connection_ack"message to send back.- Specified by:
- handleConnectionInitializationin interface- WebSocketGraphQlInterceptor
- Parameters:
- info- information about the underlying WebSocket session
- payload- the payload from the- "connection_init"message
- Returns:
- the payload for the "connection_ack", or empty
 
- 
authenticateprotected abstract reactor.core.publisher.Mono<org.springframework.security.core.Authentication> authenticate(org.springframework.security.core.Authentication authentication) Subclasses implement this method to return an authenticatedSecurityContextor an error.- Parameters:
- authentication- the authentication value extracted from the payload
 
- 
interceptpublic reactor.core.publisher.Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, WebGraphQlInterceptor.Chain chain) Description copied from interface:WebGraphQlInterceptorIntercept a request and delegate to the rest of the chain including other interceptors and aExecutionGraphQlService.- Specified by:
- interceptin interface- WebGraphQlInterceptor
- Specified by:
- interceptin interface- WebSocketGraphQlInterceptor
- Parameters:
- request- the request which may be a- WebSocketGraphQlRequestwhen intercepting a GraphQL request over WebSocket
- chain- the rest of the chain to execute the request
- Returns:
- a Monowith the response
 
- 
getContextToWriteprotected abstract reactor.util.context.ContextView getContextToWrite(org.springframework.security.core.context.SecurityContext securityContext) Subclasses implement this to decide how to insert theSecurityContextinto the Reactor context of theWebSocketGraphQlInterceptorchain.- Parameters:
- securityContext- the- SecurityContextto write to the context
 
 
-