1
1
package graphql .kickstart .servlet ;
2
2
3
3
import static java .util .Arrays .asList ;
4
- import static java .util .Collections .emptyList ;
5
4
import static java .util .Collections .singletonList ;
6
5
import static java .util .stream .Collectors .toList ;
7
6
@@ -66,7 +65,6 @@ public class GraphQLWebsocketServlet extends Endpoint {
66
65
private final AtomicBoolean isShuttingDown = new AtomicBoolean (false );
67
66
private final AtomicBoolean isShutDown = new AtomicBoolean (false );
68
67
private final Object cacheLock = new Object ();
69
- private final List <String > allowedOrigins ;
70
68
71
69
public GraphQLWebsocketServlet (GraphQLConfiguration configuration ) {
72
70
this (configuration , null );
@@ -79,23 +77,21 @@ public GraphQLWebsocketServlet(
79
77
configuration .getGraphQLInvoker (),
80
78
configuration .getInvocationInputFactory (),
81
79
configuration .getObjectMapper (),
82
- connectionListeners ,
83
- configuration .getAllowedOrigins ());
80
+ connectionListeners );
84
81
}
85
82
86
83
public GraphQLWebsocketServlet (
87
84
GraphQLInvoker graphQLInvoker ,
88
85
GraphQLSubscriptionInvocationInputFactory invocationInputFactory ,
89
86
GraphQLObjectMapper graphQLObjectMapper ) {
90
- this (graphQLInvoker , invocationInputFactory , graphQLObjectMapper , null , emptyList () );
87
+ this (graphQLInvoker , invocationInputFactory , graphQLObjectMapper , null );
91
88
}
92
89
93
90
public GraphQLWebsocketServlet (
94
91
GraphQLInvoker graphQLInvoker ,
95
92
GraphQLSubscriptionInvocationInputFactory invocationInputFactory ,
96
93
GraphQLObjectMapper graphQLObjectMapper ,
97
- Collection <SubscriptionConnectionListener > connectionListeners ,
98
- List <String > allowedOrigins ) {
94
+ Collection <SubscriptionConnectionListener > connectionListeners ) {
99
95
List <ApolloSubscriptionConnectionListener > listeners = new ArrayList <>();
100
96
if (connectionListeners != null ) {
101
97
connectionListeners .stream ()
@@ -118,7 +114,6 @@ public GraphQLWebsocketServlet(
118
114
Stream .of (fallbackSubscriptionProtocolFactory ))
119
115
.map (SubscriptionProtocolFactory ::getProtocol )
120
116
.collect (toList ());
121
- this .allowedOrigins = allowedOrigins ;
122
117
}
123
118
124
119
public GraphQLWebsocketServlet (
@@ -134,8 +129,6 @@ public GraphQLWebsocketServlet(
134
129
Stream .of (fallbackSubscriptionProtocolFactory ))
135
130
.map (SubscriptionProtocolFactory ::getProtocol )
136
131
.collect (toList ());
137
-
138
- this .allowedOrigins = emptyList ();
139
132
}
140
133
141
134
@ Override
@@ -206,26 +199,6 @@ private void closeUnexpectedly(Session session, Throwable t) {
206
199
}
207
200
}
208
201
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
-
229
202
public void modifyHandshake (
230
203
ServerEndpointConfig sec , HandshakeRequest request , HandshakeResponse response ) {
231
204
sec .getUserProperties ().put (HANDSHAKE_REQUEST_KEY , request );
0 commit comments