aesteve / nubes

Annotation layer on top of Vert.x 3
Apache License 2.0
120 stars 35 forks source link

Provide an EventBusBridge #35

Closed aesteve closed 9 years ago

aesteve commented 9 years ago

@SockJS controllers could be annotated with @EventBusBridge to act as an eventbus bridge for Javascript clients.

See : http://vertx.io/docs/vertx-web/java/#_sockjs_event_bus_bridge

Problem is : the security options for the bridge, which are specified in vertx-web thanks to PermittedOptions for both the inbound and outbound traffic.

How to map these permitted options and address / regex matching onto an annotation ?

Probably use several annotations like :

@SockJS("/eventbus/*")
@EventBusBridge
@InboundPermitted("echo.*")
@OutboundPermitted("*")
public class MyBridge {
}
ldallen commented 9 years ago

What you suggest is a good solution imo. Maybe adding some optional parameters for the Inbound/Outbound annotations would be great, in order to be able to add some required authority when it is necessary. I don't know if it's possible, but maybe you could put the inbound/outbound permitted options into the config file, in order to avoid to have a class definition with 10 annotations...

aesteve commented 9 years ago

See : https://github.com/aesteve/vertx-nubes/blob/master/src/test/java/mock/controllers/sockjs/EBBridgeDefaultController.java

It should do what you need for now. It should be tested automatically.

I also implemented the Inbound/Outbound permitted options but didn't write any test yet. So it's very likely to be broken... That's why I'll leave this issue opened for now :)

ldallen commented 9 years ago

Hi Arnaud,

Thank you for this implementation, you're very reactive! I will try it today :)

ldallen commented 9 years ago

Tested with a js client, it works well! :) I even tried with Inbound/Outbound permitted options, it seems to work too! I will let you know if I face any bug or unexpected behavior.

ldallen commented 9 years ago

Hi it's me again ! I did face an issue when trying to declare more than one Inbound option, so I changed your code a bit to allow repeatable annotations for Inbound/Outbound. Do you want me to post the changes here ?

aesteve commented 9 years ago

I must have missed something obvious, it was intended to be possible.

Could you submit a Pull request please ?

ldallen commented 9 years ago

Pull request submitted ! :)

aesteve commented 9 years ago

Thanks a lot for the PR.

Address & AddressRegex + Multiple rules are tested automatically now.

Still need to test the authority.