[rabbitmq-discuss] STOMP Authentication Idea

Nemanja Stefanovic nemik at nemik.net
Thu Apr 30 18:47:44 BST 2009


Tony,

Thanks! That's a bit more elegant than what I did, which was to change the
startup erl command and add '-s inets' there. Thanks!

BTW, I updated it a little to make the URL to hit customizable and based it
on a version that worked with 1.5.4 (the rabbit-version we plan to use in
production). I have it so the URL is put as an arg along with hostname and
port for the STOMP adapter; so the startup script had to be changed to:

stomp_listeners [{"0.0.0.0",61613,"http://nemik.net/test/test.php"}] or
whatever URL a user might need.

Thanks again,
Nemanja

On Thu, Apr 30, 2009 at 12:35 PM, Tony Garnock-Jones <tonyg at lshift.net>wrote:

> Hi Nemanja,
>
> Interesting stuff!
>
> Re the inets:start() automation issue: set "extra_startup_steps",
> already used to start the STOMP plugin, to include a call to inets too:
>
>  ... extra_startup_steps
>      [{"STOMP-listeners",rabbit_stomp,kickstart,[]},
>       {"inets",inets,start,[]}] ...
>
> You will probably need to use backslash-escaping to make it look like
> the "STOMP-listeners" setting you already have, and make sure there's no
> whitespace anywhere in there. The shell gets mighty confused about
> whitespace.
>
> Regards,
>  Tony
>
>
> Nemanja Stefanovic wrote:
> > Hello,
> >
> > I just wanted to contribute some code I recently changes if anyone needs
> > it. We have a use-case where I'm using STOMP with RabbitMQ's STOMP
> > adapter and Orbited to push updates to a browser, or maybe even allow
> > clients to connect to the STOMP server, not sure yet. Anyway, we need to
> > ensure that only certain users get pushed certain content, hence
> > authentication.
> >
> > The way I have this working is: client connects to STOMP with generic
> > just-TLD cookie (so it can be passed also to STOMP server which would
> > run on another subdomain) and Orbited's io.js can read the cookie and
> > send it up to the STOMP adapter as a 'cookie' header. It (the JS) also
> > generates a random ID for the queue-name for that connection. This is
> > all assuming I have 1 queue per connection as per the broadcast-style
> > suggestion for STOMP adapter.
> >
> > So now the STOMP adapter reads that cookie header and hits a page using
> > http:request (via inets) with that cookie and passes in the queue name
> > too. The web-app will recognize the cookie as belonging to a user and
> > read the queue name. It (the web-app) will then set the appropriate
> > bindings for that user. Since this is a topic exchange, the bindings
> > would be for the topics updates the user will receive on her browser. If
> > there is no cookie or the cookie is invalid, the web-app can take care
> > of all that and just assign some default bindings for guests.
> >
> > This is all working pretty well, except that I have to start
> > 'inets:start()' manually in the erl command prompt. I was wondering how
> > could I get this to be done on startup when the STOMP adapter starts?
> >
> > I've attached the code and a diff (based on the tip of STOMP adapter
> > from hg). Right now the URL is hardcoded but I plan to make that more
> > configurable later.
> >
> > Anyway, I hope maybe it can be of some use to someone who might need
> > similar functionality.
> >
> > -Nemanja
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > rabbitmq-discuss mailing list
> > rabbitmq-discuss at lists.rabbitmq.com
> > http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
> --
>  [][][] Tony Garnock-Jones     | Mob: +44 (0)7905 974 211
>   [][] LShift Ltd             | Tel: +44 (0)20 7729 7060
>  []  [] http://www.lshift.net/ | Email: tonyg at lshift.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20090430/666344fb/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rabbit_stomp.erl_154
Type: application/octet-stream
Size: 20864 bytes
Desc: not available
Url : http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20090430/666344fb/attachment.obj 


More information about the rabbitmq-discuss mailing list