11package graphql .kickstart .servlet ;
22
33import static java .util .Arrays .asList ;
4- import static java .util .Collections .emptyList ;
54import static java .util .Collections .singletonList ;
65import static java .util .stream .Collectors .toList ;
76
@@ -66,7 +65,6 @@ public class GraphQLWebsocketServlet extends Endpoint {
6665 private final AtomicBoolean isShuttingDown = new AtomicBoolean (false );
6766 private final AtomicBoolean isShutDown = new AtomicBoolean (false );
6867 private final Object cacheLock = new Object ();
69- private final List <String > allowedOrigins ;
7068
7169 public GraphQLWebsocketServlet (GraphQLConfiguration configuration ) {
7270 this (configuration , null );
@@ -79,23 +77,21 @@ public GraphQLWebsocketServlet(
7977 configuration .getGraphQLInvoker (),
8078 configuration .getInvocationInputFactory (),
8179 configuration .getObjectMapper (),
82- connectionListeners ,
83- configuration .getAllowedOrigins ());
80+ connectionListeners );
8481 }
8582
8683 public GraphQLWebsocketServlet (
8784 GraphQLInvoker graphQLInvoker ,
8885 GraphQLSubscriptionInvocationInputFactory invocationInputFactory ,
8986 GraphQLObjectMapper graphQLObjectMapper ) {
90- this (graphQLInvoker , invocationInputFactory , graphQLObjectMapper , null , emptyList () );
87+ this (graphQLInvoker , invocationInputFactory , graphQLObjectMapper , null );
9188 }
9289
9390 public GraphQLWebsocketServlet (
9491 GraphQLInvoker graphQLInvoker ,
9592 GraphQLSubscriptionInvocationInputFactory invocationInputFactory ,
9693 GraphQLObjectMapper graphQLObjectMapper ,
97- Collection <SubscriptionConnectionListener > connectionListeners ,
98- List <String > allowedOrigins ) {
94+ Collection <SubscriptionConnectionListener > connectionListeners ) {
9995 List <ApolloSubscriptionConnectionListener > listeners = new ArrayList <>();
10096 if (connectionListeners != null ) {
10197 connectionListeners .stream ()
@@ -118,7 +114,6 @@ public GraphQLWebsocketServlet(
118114 Stream .of (fallbackSubscriptionProtocolFactory ))
119115 .map (SubscriptionProtocolFactory ::getProtocol )
120116 .collect (toList ());
121- this .allowedOrigins = allowedOrigins ;
122117 }
123118
124119 public GraphQLWebsocketServlet (
@@ -134,8 +129,6 @@ public GraphQLWebsocketServlet(
134129 Stream .of (fallbackSubscriptionProtocolFactory ))
135130 .map (SubscriptionProtocolFactory ::getProtocol )
136131 .collect (toList ());
137-
138- this .allowedOrigins = emptyList ();
139132 }
140133
141134 @ Override
@@ -206,26 +199,6 @@ private void closeUnexpectedly(Session session, Throwable t) {
206199 }
207200 }
208201
209- public boolean checkOrigin (String originHeaderValue ) {
210- if (originHeaderValue == null || originHeaderValue .isBlank ()) {
211- return allowedOrigins .isEmpty ();
212- }
213- String originToCheck = trimTrailingSlash (originHeaderValue );
214- if (!allowedOrigins .isEmpty ()) {
215- if (allowedOrigins .contains ("*" )) {
216- return true ;
217- }
218- return allowedOrigins .stream ()
219- .map (this ::trimTrailingSlash )
220- .anyMatch (originToCheck ::equalsIgnoreCase );
221- }
222- return true ;
223- }
224-
225- private String trimTrailingSlash (String origin ) {
226- return (origin .endsWith ("/" ) ? origin .substring (0 , origin .length () - 1 ) : origin );
227- }
228-
229202 public void modifyHandshake (
230203 ServerEndpointConfig sec , HandshakeRequest request , HandshakeResponse response ) {
231204 sec .getUserProperties ().put (HANDSHAKE_REQUEST_KEY , request );
0 commit comments