You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bob DeRemer <bo...@thingworx.com> on 2013/09/04 21:49:34 UTC

Does JSR-356 provide a way for a client to pass security info on connect?

I'm curious if there's anything defined in JSR-356 to enable a client to pass some security claims in the connect that would allow me to perform an auth check - prior to actually establishing the websocket connection.

In an attempt to avoid a websocket DOS, I'm looking to see whether we can do an auth check in the ServerEndpoint onOpen (or, possibly at an earlier stage) - before the actual websocket gets established.  I know we can do this at the application level in the onMessage, but it'd be good to handle this before setting up the actual websocket if possible.

Thanks,

Bob DeRemer
Senior Director, Architecture and Development

[Description: Description: Description: Description: cid:image001.png@01CBE3DE.51A12030]
http://www.thingworx.com<http://www.thingworx.com/>
Skype: bob.deremer.thingworx
O: 610.594.6200 x812
M: 717.881.3986


RE: Does JSR-356 provide a way for a client to pass security info on connect?

Posted by Bob DeRemer <bo...@thingworx.com>.

> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Thursday, September 05, 2013 1:33 PM
> To: Tomcat Users List
> Subject: Re: Does JSR-356 provide a way for a client to pass security info on
> connect?
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Bob,
> 
> On 9/5/13 12:32 PM, Bob DeRemer wrote:
> >> -----Original Message----- From: André Warnier [mailto:aw@ice-sa.com]
> >> Sent: Thursday, September 05, 2013 10:04 AM To: Tomcat Users List
> >> Subject: Re: Does JSR-356 provide a way for a client to pass security
> >> info on connect?
> >>
> >> And when you have done and solved the problem, would you be nice and
> >> post some summary on the list as a conclusion to this thread ? This
> >> way other people who would encounter the same issue later may find
> >> some useful pointers to the solution. (Or even better, write an
> >> article for the Tomcat WiKi)
> >
> > Absolutely, would love to!
> 
> Or, come to this fall's Apache Bar Camp* in Washington, DC and give an
> informal presentation on your exploits with Websocket in Tomcat 7.
> 
Hi chris,

That would be great.  Once you know the WHEN and WHERE, let me know.  If available, I'll definitely try to make it.   I'm just up in PA, so that's only a 2 hr drive.

Thx,bob

> - -chris
> 
> * Details to follow. The organizers (I'm one) are meeting this evening for beers,
> so you know we'll get something accomplished.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.14 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iQIcBAEBCAAGBQJSKMBQAAoJEBzwKT+lPKRYWUMP/igIgZyN2xZsw8WghisyLdq
> I
> 57KvNQTcw2A5RWZIurhCIFuGljDv6E3oWFC/nGAUTY9m74UObBtQsRjlXK/pTrC0
> h3o9txPhPINoKj6CLUpYI2GvDKUW1yR9TRzpJYUoCsVW/YYnp5nsdek3SI4+7Ua9
> I4WsnuRwayfZEWSgP7Rn4q8AmQanBFyHmdWgXmpN9n7IQG8hX9tqCSkkhPfJG
> 97X
> a5vVxqKgBh3MFYW1SpnvFn7uCkCY7shfED2BJhruWVZgnaQAVn/I7dVWCj8Xzrg
> g
> YObM//PGyNceh9wzDU4bwHz9tYQ+XKruMLW7c7yneRgLsKisNc1+orM12zMLpC
> 9f
> Ap+U8zX7Yi7CgQXvdTOkPjrYddEzJL75pNLhj0AfZMTr3XCeVBfmpRAY5dcwd+qq
> +gEKscff9od2koLG3LLSBwps4LVjnfYHPCNkQ+qhKc5DpKKpMmIQOSidTwFnY817
> TJU3/SgXR81y/HdR4NqoLL9N98KqRDlkpZVsXn9NpWQEbazx2875C6CFDmW/8W
> 6H
> BPPR7SR+6/hp15AqFmyOKyOgISdeaReMlhvAFtjxKIy38xmb39bXfJqN17ZPDr2x
> jx3tGD+GRQ0odDblaipp1IwjCW47XXE65gO6Y3p4KydaxtUrcr7P0iQ2/HO9B4Wl
> KigIasG+QYOKqqMw9fWV
> =u0iB
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


Re: Does JSR-356 provide a way for a client to pass security info on connect?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Bob,

On 9/5/13 12:32 PM, Bob DeRemer wrote:
>> -----Original Message----- From: André Warnier
>> [mailto:aw@ice-sa.com] Sent: Thursday, September 05, 2013 10:04
>> AM To: Tomcat Users List Subject: Re: Does JSR-356 provide a way
>> for a client to pass security info on connect?
>> 
>> And when you have done and solved the problem, would you be nice
>> and post some summary on the list as a conclusion to this thread
>> ? This way other people who would encounter the same issue later
>> may find some useful pointers to the solution. (Or even better,
>> write an article for the Tomcat WiKi)
> 
> Absolutely, would love to!

Or, come to this fall's Apache Bar Camp* in Washington, DC and give an
informal presentation on your exploits with Websocket in Tomcat 7.

- -chris

* Details to follow. The organizers (I'm one) are meeting this evening
for beers, so you know we'll get something accomplished.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSKMBQAAoJEBzwKT+lPKRYWUMP/igIgZyN2xZsw8WghisyLdqI
57KvNQTcw2A5RWZIurhCIFuGljDv6E3oWFC/nGAUTY9m74UObBtQsRjlXK/pTrC0
h3o9txPhPINoKj6CLUpYI2GvDKUW1yR9TRzpJYUoCsVW/YYnp5nsdek3SI4+7Ua9
I4WsnuRwayfZEWSgP7Rn4q8AmQanBFyHmdWgXmpN9n7IQG8hX9tqCSkkhPfJG97X
a5vVxqKgBh3MFYW1SpnvFn7uCkCY7shfED2BJhruWVZgnaQAVn/I7dVWCj8Xzrgg
YObM//PGyNceh9wzDU4bwHz9tYQ+XKruMLW7c7yneRgLsKisNc1+orM12zMLpC9f
Ap+U8zX7Yi7CgQXvdTOkPjrYddEzJL75pNLhj0AfZMTr3XCeVBfmpRAY5dcwd+qq
+gEKscff9od2koLG3LLSBwps4LVjnfYHPCNkQ+qhKc5DpKKpMmIQOSidTwFnY817
TJU3/SgXR81y/HdR4NqoLL9N98KqRDlkpZVsXn9NpWQEbazx2875C6CFDmW/8W6H
BPPR7SR+6/hp15AqFmyOKyOgISdeaReMlhvAFtjxKIy38xmb39bXfJqN17ZPDr2x
jx3tGD+GRQ0odDblaipp1IwjCW47XXE65gO6Y3p4KydaxtUrcr7P0iQ2/HO9B4Wl
KigIasG+QYOKqqMw9fWV
=u0iB
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Does JSR-356 provide a way for a client to pass security info on connect?

Posted by Bob DeRemer <bo...@thingworx.com>.

> -----Original Message-----
> From: André Warnier [mailto:aw@ice-sa.com]
> Sent: Thursday, September 05, 2013 10:04 AM
> To: Tomcat Users List
> Subject: Re: Does JSR-356 provide a way for a client to pass security info on
> connect?
> 
> Bob DeRemer wrote:
> >
> >> -----Original Message-----
> >> From: Niki Dokovski [mailto:nickytd@gmail.com]
> >> Sent: Thursday, September 05, 2013 7:22 AM
> >> To: Tomcat Users List
> >> Subject: Re: Does JSR-356 provide a way for a client to pass security
> >> info on connect?
> >>
> >> On Thu, Sep 5, 2013 at 8:48 AM, Niki Dokovski <ni...@gmail.com> wrote:
> >>
> >>>
> >>>
> >>> On Thu, Sep 5, 2013 at 12:44 AM, Bob DeRemer
> >> <bo...@thingworx.com>wrote:
> >>>>
> >>>>> -----Original Message-----
> >>>>> From: André Warnier [mailto:aw@ice-sa.com]
> >>>>> Sent: Wednesday, September 04, 2013 3:59 PM
> >>>>> To: Tomcat Users List
> >>>>> Subject: Re: Does JSR-356 provide a way for a client to pass
> >>>>> security
> >>>> info on
> >>>>> connect?
> >>>>>
> >>>>> Bob DeRemer wrote:
> >>>>>> I'm curious if there's anything defined in JSR-356 to enable a
> >>>>>> client
> >>>> to pass
> >>>>> some security claims in the connect that would allow me to perform
> >>>>> an
> >>>> auth
> >>>>> check - prior to actually establishing the websocket connection.
> >>>>>> In an attempt to avoid a websocket DOS, I'm looking to see
> >>>>>> whether we
> >>>> can
> >>>>> do an auth check in the ServerEndpoint onOpen (or, possibly at an
> >>>> earlier
> >>>>> stage) - before the actual websocket gets established.  I know we
> >>>>> can
> >>>> do this at
> >>>>> the application level in the onMessage, but it'd be good to handle
> >>>>> this
> >>>> before
> >>>>> setting up the actual websocket if possible.
> >>>>>  From a not really websocket specialist :
> >>>>> As I recall, a websocket link starts with a normal HTTP request,
> >>>>> which
> >>>> then gets
> >>>>> upgraded to a websocket connection.  So it should be possible to
> >>>>> do AAA
> >>>> at the
> >>>>> initial HTTP stage, no ?
> >>>>>  From an earlier thread a couple of weeks (?) ago, it seems
> >>>>> however
> >>>> difficult to
> >>>>> retrieve some of that HTTP-level information later, when the
> >>>>> websocket connection is established.
> >>>>>
> >>>> Exactly what I am hoping to do: the WebSocket spec outlines the
> >>>> HTTP Upgrade handshake process.  During this handshake, a client
> >>>> should be able to send additional HTTP headers for this exact purpose (i.e.
> >>>> cookies, auth tokens, etc.).  The server-side just needs an
> >>>> application-level hook that can be called that can effectively link
> >>>> into the pipeline - allowing/rejecting the establishment of the connection.
> >>>>
> >>>> So, the big question(s):
> >>>> 1) does the tomcat client-side JSR impl provide a way to pass HTTP
> >>>> headers in the initial upgrade handshake
> >>>>
> >>> Yes
> >>> background
> >>>
> >>> http://docs.oracle.com/javaee/7/api/javax/websocket/ClientEndpointCo
> >>> nf
> >>> ig.Configurator.html#beforeRequest(java.util.Map)
> >>>
> >>> There is a mutuable headers map.
> >>>
> >>> 2) does the tomcat server-side JSR impl provide a way to hook into
> >>> the
> >>>> upgrade handshake and effectively allow/reject the connection
> >>>>
> >>> Yes and .... (need to check further :)) background
> >>> http://docs.oracle.com/javaee/7/api/javax/websocket/server/ServerEnd
> >>> po
> >>> intConfig.Configurator.html#modifyHandshake(javax.websocket.server.S
> >>> er verEndpointConfig, javax.websocket.server.HandshakeRequest,
> >>> javax.websocket.HandshakeResponse)
> >>>
> >>>
> >>> JSR 356 Specification  - 3.1.5 Handshake Modification I doesn't
> >>> particularly targets the rejection of the connection. The latter is
> >>> defined in http://tools.ietf.org/html/rfc6455#section-1.6 Security
> >>> Model. which simply uses the "origin" mechanism.
> >>>
> >> The status code of the response when connection should be dropped is
> >> 403 Forbidden  defined by
> >> http://tools.ietf.org/html/rfc6455#section-4.2.2 which is in relation to origin
> check.
> >> The  implementation in Tomcat calls checkOrigin either on the default
> >> configurator or on a custom supplied one.
> >> Take a look at org.apache.tomcat.websocket.server.UpgradeUtil
> >> doUpgrade method
> >
> > Awesome - I'll start looking into this today!
> > -thx, bob
> >
> And when you have done and solved the problem, would you be nice and post
> some summary on the list as a conclusion to this thread ?
> This way other people who would encounter the same issue later may find
> some useful pointers to the solution.
> (Or even better, write an article for the Tomcat WiKi)

Absolutely, would love to!

> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Does JSR-356 provide a way for a client to pass security info on connect?

Posted by André Warnier <aw...@ice-sa.com>.
Bob DeRemer wrote:
> 
>> -----Original Message-----
>> From: Niki Dokovski [mailto:nickytd@gmail.com]
>> Sent: Thursday, September 05, 2013 7:22 AM
>> To: Tomcat Users List
>> Subject: Re: Does JSR-356 provide a way for a client to pass security info on
>> connect?
>>
>> On Thu, Sep 5, 2013 at 8:48 AM, Niki Dokovski <ni...@gmail.com> wrote:
>>
>>>
>>>
>>> On Thu, Sep 5, 2013 at 12:44 AM, Bob DeRemer
>> <bo...@thingworx.com>wrote:
>>>>
>>>>> -----Original Message-----
>>>>> From: André Warnier [mailto:aw@ice-sa.com]
>>>>> Sent: Wednesday, September 04, 2013 3:59 PM
>>>>> To: Tomcat Users List
>>>>> Subject: Re: Does JSR-356 provide a way for a client to pass
>>>>> security
>>>> info on
>>>>> connect?
>>>>>
>>>>> Bob DeRemer wrote:
>>>>>> I'm curious if there's anything defined in JSR-356 to enable a
>>>>>> client
>>>> to pass
>>>>> some security claims in the connect that would allow me to perform
>>>>> an
>>>> auth
>>>>> check - prior to actually establishing the websocket connection.
>>>>>> In an attempt to avoid a websocket DOS, I'm looking to see
>>>>>> whether we
>>>> can
>>>>> do an auth check in the ServerEndpoint onOpen (or, possibly at an
>>>> earlier
>>>>> stage) - before the actual websocket gets established.  I know we
>>>>> can
>>>> do this at
>>>>> the application level in the onMessage, but it'd be good to handle
>>>>> this
>>>> before
>>>>> setting up the actual websocket if possible.
>>>>>  From a not really websocket specialist :
>>>>> As I recall, a websocket link starts with a normal HTTP request,
>>>>> which
>>>> then gets
>>>>> upgraded to a websocket connection.  So it should be possible to do
>>>>> AAA
>>>> at the
>>>>> initial HTTP stage, no ?
>>>>>  From an earlier thread a couple of weeks (?) ago, it seems however
>>>> difficult to
>>>>> retrieve some of that HTTP-level information later, when the
>>>>> websocket connection is established.
>>>>>
>>>> Exactly what I am hoping to do: the WebSocket spec outlines the HTTP
>>>> Upgrade handshake process.  During this handshake, a client should be
>>>> able to send additional HTTP headers for this exact purpose (i.e.
>>>> cookies, auth tokens, etc.).  The server-side just needs an
>>>> application-level hook that can be called that can effectively link
>>>> into the pipeline - allowing/rejecting the establishment of the connection.
>>>>
>>>> So, the big question(s):
>>>> 1) does the tomcat client-side JSR impl provide a way to pass HTTP
>>>> headers in the initial upgrade handshake
>>>>
>>> Yes
>>> background
>>>
>>> http://docs.oracle.com/javaee/7/api/javax/websocket/ClientEndpointConf
>>> ig.Configurator.html#beforeRequest(java.util.Map)
>>>
>>> There is a mutuable headers map.
>>>
>>> 2) does the tomcat server-side JSR impl provide a way to hook into the
>>>> upgrade handshake and effectively allow/reject the connection
>>>>
>>> Yes and .... (need to check further :)) background
>>> http://docs.oracle.com/javaee/7/api/javax/websocket/server/ServerEndpo
>>> intConfig.Configurator.html#modifyHandshake(javax.websocket.server.Ser
>>> verEndpointConfig, javax.websocket.server.HandshakeRequest,
>>> javax.websocket.HandshakeResponse)
>>>
>>>
>>> JSR 356 Specification  - 3.1.5 Handshake Modification I doesn't
>>> particularly targets the rejection of the connection. The latter is
>>> defined in http://tools.ietf.org/html/rfc6455#section-1.6 Security
>>> Model. which simply uses the "origin" mechanism.
>>>
>> The status code of the response when connection should be dropped is 403
>> Forbidden  defined by http://tools.ietf.org/html/rfc6455#section-4.2.2 which is
>> in relation to origin check.
>> The  implementation in Tomcat calls checkOrigin either on the default
>> configurator or on a custom supplied one.
>> Take a look at org.apache.tomcat.websocket.server.UpgradeUtil doUpgrade
>> method
> 
> Awesome - I'll start looking into this today!  
> -thx, bob
> 
And when you have done and solved the problem, would you be nice and post some summary on 
the list as a conclusion to this thread ?
This way other people who would encounter the same issue later may find some useful 
pointers to the solution.
(Or even better, write an article for the Tomcat WiKi)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Does JSR-356 provide a way for a client to pass security info on connect?

Posted by Bob DeRemer <bo...@thingworx.com>.

> -----Original Message-----
> From: Niki Dokovski [mailto:nickytd@gmail.com]
> Sent: Thursday, September 05, 2013 7:22 AM
> To: Tomcat Users List
> Subject: Re: Does JSR-356 provide a way for a client to pass security info on
> connect?
> 
> On Thu, Sep 5, 2013 at 8:48 AM, Niki Dokovski <ni...@gmail.com> wrote:
> 
> >
> >
> >
> > On Thu, Sep 5, 2013 at 12:44 AM, Bob DeRemer
> <bo...@thingworx.com>wrote:
> >
> >>
> >>
> >> > -----Original Message-----
> >> > From: André Warnier [mailto:aw@ice-sa.com]
> >> > Sent: Wednesday, September 04, 2013 3:59 PM
> >> > To: Tomcat Users List
> >> > Subject: Re: Does JSR-356 provide a way for a client to pass
> >> > security
> >> info on
> >> > connect?
> >> >
> >> > Bob DeRemer wrote:
> >> > > I'm curious if there's anything defined in JSR-356 to enable a
> >> > > client
> >> to pass
> >> > some security claims in the connect that would allow me to perform
> >> > an
> >> auth
> >> > check - prior to actually establishing the websocket connection.
> >> > >
> >> > > In an attempt to avoid a websocket DOS, I'm looking to see
> >> > > whether we
> >> can
> >> > do an auth check in the ServerEndpoint onOpen (or, possibly at an
> >> earlier
> >> > stage) - before the actual websocket gets established.  I know we
> >> > can
> >> do this at
> >> > the application level in the onMessage, but it'd be good to handle
> >> > this
> >> before
> >> > setting up the actual websocket if possible.
> >> > >
> >> >  From a not really websocket specialist :
> >> > As I recall, a websocket link starts with a normal HTTP request,
> >> > which
> >> then gets
> >> > upgraded to a websocket connection.  So it should be possible to do
> >> > AAA
> >> at the
> >> > initial HTTP stage, no ?
> >> >  From an earlier thread a couple of weeks (?) ago, it seems however
> >> difficult to
> >> > retrieve some of that HTTP-level information later, when the
> >> > websocket connection is established.
> >> >
> >>
> >> Exactly what I am hoping to do: the WebSocket spec outlines the HTTP
> >> Upgrade handshake process.  During this handshake, a client should be
> >> able to send additional HTTP headers for this exact purpose (i.e.
> >> cookies, auth tokens, etc.).  The server-side just needs an
> >> application-level hook that can be called that can effectively link
> >> into the pipeline - allowing/rejecting the establishment of the connection.
> >>
> >> So, the big question(s):
> >> 1) does the tomcat client-side JSR impl provide a way to pass HTTP
> >> headers in the initial upgrade handshake
> >>
> > Yes
> > background
> >
> > http://docs.oracle.com/javaee/7/api/javax/websocket/ClientEndpointConf
> > ig.Configurator.html#beforeRequest(java.util.Map)
> >
> > There is a mutuable headers map.
> >
> > 2) does the tomcat server-side JSR impl provide a way to hook into the
> >> upgrade handshake and effectively allow/reject the connection
> >>
> > Yes and .... (need to check further :)) background
> > http://docs.oracle.com/javaee/7/api/javax/websocket/server/ServerEndpo
> > intConfig.Configurator.html#modifyHandshake(javax.websocket.server.Ser
> > verEndpointConfig, javax.websocket.server.HandshakeRequest,
> > javax.websocket.HandshakeResponse)
> >
> >
> > JSR 356 Specification  - 3.1.5 Handshake Modification I doesn't
> > particularly targets the rejection of the connection. The latter is
> > defined in http://tools.ietf.org/html/rfc6455#section-1.6 Security
> > Model. which simply uses the "origin" mechanism.
> >
> 
> The status code of the response when connection should be dropped is 403
> Forbidden  defined by http://tools.ietf.org/html/rfc6455#section-4.2.2 which is
> in relation to origin check.
> The  implementation in Tomcat calls checkOrigin either on the default
> configurator or on a custom supplied one.
> Take a look at org.apache.tomcat.websocket.server.UpgradeUtil doUpgrade
> method

Awesome - I'll start looking into this today!  
-thx, bob

> 
> cheers
> Niki
> 
> 
> 
> >
> >
> >
> >
> >
> >> >
> >> > -------------------------------------------------------------------
> >> > -- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> > For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Does JSR-356 provide a way for a client to pass security info on connect?

Posted by Niki Dokovski <ni...@gmail.com>.
On Thu, Sep 5, 2013 at 8:48 AM, Niki Dokovski <ni...@gmail.com> wrote:

>
>
>
> On Thu, Sep 5, 2013 at 12:44 AM, Bob DeRemer <bo...@thingworx.com>wrote:
>
>>
>>
>> > -----Original Message-----
>> > From: André Warnier [mailto:aw@ice-sa.com]
>> > Sent: Wednesday, September 04, 2013 3:59 PM
>> > To: Tomcat Users List
>> > Subject: Re: Does JSR-356 provide a way for a client to pass security
>> info on
>> > connect?
>> >
>> > Bob DeRemer wrote:
>> > > I'm curious if there's anything defined in JSR-356 to enable a client
>> to pass
>> > some security claims in the connect that would allow me to perform an
>> auth
>> > check - prior to actually establishing the websocket connection.
>> > >
>> > > In an attempt to avoid a websocket DOS, I'm looking to see whether we
>> can
>> > do an auth check in the ServerEndpoint onOpen (or, possibly at an
>> earlier
>> > stage) - before the actual websocket gets established.  I know we can
>> do this at
>> > the application level in the onMessage, but it'd be good to handle this
>> before
>> > setting up the actual websocket if possible.
>> > >
>> >  From a not really websocket specialist :
>> > As I recall, a websocket link starts with a normal HTTP request, which
>> then gets
>> > upgraded to a websocket connection.  So it should be possible to do AAA
>> at the
>> > initial HTTP stage, no ?
>> >  From an earlier thread a couple of weeks (?) ago, it seems however
>> difficult to
>> > retrieve some of that HTTP-level information later, when the websocket
>> > connection is established.
>> >
>>
>> Exactly what I am hoping to do: the WebSocket spec outlines the HTTP
>> Upgrade handshake process.  During this handshake, a client should be able
>> to send additional HTTP headers for this exact purpose (i.e. cookies, auth
>> tokens, etc.).  The server-side just needs an application-level hook that
>> can be called that can effectively link into the pipeline -
>> allowing/rejecting the establishment of the connection.
>>
>> So, the big question(s):
>> 1) does the tomcat client-side JSR impl provide a way to pass HTTP
>> headers in the initial upgrade handshake
>>
> Yes
> background
>
> http://docs.oracle.com/javaee/7/api/javax/websocket/ClientEndpointConfig.Configurator.html#beforeRequest(java.util.Map)
>
> There is a mutuable headers map.
>
> 2) does the tomcat server-side JSR impl provide a way to hook into the
>> upgrade handshake and effectively allow/reject the connection
>>
> Yes and .... (need to check further :))
> background
> http://docs.oracle.com/javaee/7/api/javax/websocket/server/ServerEndpointConfig.Configurator.html#modifyHandshake(javax.websocket.server.ServerEndpointConfig,
> javax.websocket.server.HandshakeRequest, javax.websocket.HandshakeResponse)
>
>
> JSR 356 Specification  - 3.1.5 Handshake Modification
> I doesn't particularly targets the rejection of the connection. The latter
> is defined in http://tools.ietf.org/html/rfc6455#section-1.6 Security
> Model. which simply uses the "origin" mechanism.
>

The status code of the response when connection should be dropped is 403
Forbidden  defined by http://tools.ietf.org/html/rfc6455#section-4.2.2 which
is in relation to origin check.
The  implementation in Tomcat calls checkOrigin either on the default
configurator or on a custom supplied one.
Take a look at org.apache.tomcat.websocket.server.UpgradeUtil doUpgrade
method

cheers
Niki



>
>
>
>
>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> > For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

Re: Does JSR-356 provide a way for a client to pass security info on connect?

Posted by Niki Dokovski <ni...@gmail.com>.
On Thu, Sep 5, 2013 at 12:44 AM, Bob DeRemer <bo...@thingworx.com>wrote:

>
>
> > -----Original Message-----
> > From: André Warnier [mailto:aw@ice-sa.com]
> > Sent: Wednesday, September 04, 2013 3:59 PM
> > To: Tomcat Users List
> > Subject: Re: Does JSR-356 provide a way for a client to pass security
> info on
> > connect?
> >
> > Bob DeRemer wrote:
> > > I'm curious if there's anything defined in JSR-356 to enable a client
> to pass
> > some security claims in the connect that would allow me to perform an
> auth
> > check - prior to actually establishing the websocket connection.
> > >
> > > In an attempt to avoid a websocket DOS, I'm looking to see whether we
> can
> > do an auth check in the ServerEndpoint onOpen (or, possibly at an earlier
> > stage) - before the actual websocket gets established.  I know we can do
> this at
> > the application level in the onMessage, but it'd be good to handle this
> before
> > setting up the actual websocket if possible.
> > >
> >  From a not really websocket specialist :
> > As I recall, a websocket link starts with a normal HTTP request, which
> then gets
> > upgraded to a websocket connection.  So it should be possible to do AAA
> at the
> > initial HTTP stage, no ?
> >  From an earlier thread a couple of weeks (?) ago, it seems however
> difficult to
> > retrieve some of that HTTP-level information later, when the websocket
> > connection is established.
> >
>
> Exactly what I am hoping to do: the WebSocket spec outlines the HTTP
> Upgrade handshake process.  During this handshake, a client should be able
> to send additional HTTP headers for this exact purpose (i.e. cookies, auth
> tokens, etc.).  The server-side just needs an application-level hook that
> can be called that can effectively link into the pipeline -
> allowing/rejecting the establishment of the connection.
>
> So, the big question(s):
> 1) does the tomcat client-side JSR impl provide a way to pass HTTP headers
> in the initial upgrade handshake
>
Yes
background
http://docs.oracle.com/javaee/7/api/javax/websocket/ClientEndpointConfig.Configurator.html#beforeRequest(java.util.Map)

There is a mutuable headers map.

2) does the tomcat server-side JSR impl provide a way to hook into the
> upgrade handshake and effectively allow/reject the connection
>
Yes and .... (need to check further :))
background
http://docs.oracle.com/javaee/7/api/javax/websocket/server/ServerEndpointConfig.Configurator.html#modifyHandshake(javax.websocket.server.ServerEndpointConfig,
javax.websocket.server.HandshakeRequest, javax.websocket.HandshakeResponse)

JSR 356 Specification  - 3.1.5 Handshake Modification
I doesn't particularly targets the rejection of the connection. The latter
is defined in http://tools.ietf.org/html/rfc6455#section-1.6 Security
Model. which simply uses the "origin" mechanism.






> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: Does JSR-356 provide a way for a client to pass security info on connect?

Posted by Bob DeRemer <bo...@thingworx.com>.

> -----Original Message-----
> From: André Warnier [mailto:aw@ice-sa.com]
> Sent: Wednesday, September 04, 2013 3:59 PM
> To: Tomcat Users List
> Subject: Re: Does JSR-356 provide a way for a client to pass security info on
> connect?
> 
> Bob DeRemer wrote:
> > I'm curious if there's anything defined in JSR-356 to enable a client to pass
> some security claims in the connect that would allow me to perform an auth
> check - prior to actually establishing the websocket connection.
> >
> > In an attempt to avoid a websocket DOS, I'm looking to see whether we can
> do an auth check in the ServerEndpoint onOpen (or, possibly at an earlier
> stage) - before the actual websocket gets established.  I know we can do this at
> the application level in the onMessage, but it'd be good to handle this before
> setting up the actual websocket if possible.
> >
>  From a not really websocket specialist :
> As I recall, a websocket link starts with a normal HTTP request, which then gets
> upgraded to a websocket connection.  So it should be possible to do AAA at the
> initial HTTP stage, no ?
>  From an earlier thread a couple of weeks (?) ago, it seems however difficult to
> retrieve some of that HTTP-level information later, when the websocket
> connection is established.
> 

Exactly what I am hoping to do: the WebSocket spec outlines the HTTP Upgrade handshake process.  During this handshake, a client should be able to send additional HTTP headers for this exact purpose (i.e. cookies, auth tokens, etc.).  The server-side just needs an application-level hook that can be called that can effectively link into the pipeline - allowing/rejecting the establishment of the connection. 

So, the big question(s): 
1) does the tomcat client-side JSR impl provide a way to pass HTTP headers in the initial upgrade handshake
2) does the tomcat server-side JSR impl provide a way to hook into the upgrade handshake and effectively allow/reject the connection

> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Does JSR-356 provide a way for a client to pass security info on connect?

Posted by André Warnier <aw...@ice-sa.com>.
Bob DeRemer wrote:
> I'm curious if there's anything defined in JSR-356 to enable a client to pass some security claims in the connect that would allow me to perform an auth check - prior to actually establishing the websocket connection.
> 
> In an attempt to avoid a websocket DOS, I'm looking to see whether we can do an auth check in the ServerEndpoint onOpen (or, possibly at an earlier stage) - before the actual websocket gets established.  I know we can do this at the application level in the onMessage, but it'd be good to handle this before setting up the actual websocket if possible.
> 
 From a not really websocket specialist :
As I recall, a websocket link starts with a normal HTTP request, which then gets upgraded 
to a websocket connection.  So it should be possible to do AAA at the initial HTTP stage, no ?
 From an earlier thread a couple of weeks (?) ago, it seems however difficult to retrieve 
some of that HTTP-level information later, when the websocket connection is established.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org