You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by redboy1972 <re...@live.com> on 2015/04/06 18:57:12 UTC

Is there a way to authorize dynamic destinations with Apache Apollo MQ?

I have a similar request to :
http://activemq.2283324.n4.nabble.com/Is-it-possible-to-use-Client-Certs-for-Authentication-Authorization-for-Apollo-tt4668985.html#a4669234

Is there a way to authorize dynamic destinations with Apache Apollo MQ?

What I would like is to make it so that 1) users may write only to a shared
topic but restrict read to an server/admin. This topic is to send messages
to a server. 2) Users may read from their own private topic but no one but
the server/admin may write to it.

For Example:

Topic                       User rights                                 
Server/Admin rights
/public                     Write only                                  
Read only
/user/foo                  ONLY the user foo may read          Write only
/user/bar                  ONLY the user bar may read          Write only
/user/<username>    ONLY the <username> may read    Write only

Now for the interesting part. This must work with dynamic topics. The user's
name is NOT known ahead of time.

I had this working with Apache ActiveMQ using a custom security_factory but
am not sure how to do with with Apollo.

Based on the above post is looks like I need to write some sort of plugin
but I only know Java not scala.
<broker xmlns="http://activemq.apache.org/schema/activemq/apollo"
security_factory="org.apache.activemq.apollo.stomp.test.UserOwnershipSecurityFactory">

Thanks for any help.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Is-there-a-way-to-authorize-dynamic-destinations-with-Apache-Apollo-MQ-tp4694359.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Is there a way to authorize dynamic destinations with Apache Apollo MQ?

Posted by Kevin Burton <bu...@spinn3r.com>.
probably post to the dev@activemq.apache.org or view the recent threads
there. either way I think it’s safe to say that activemq 6.0 will be the
focus.

On Wed, Apr 8, 2015 at 6:16 PM, redboy1972 <re...@live.com> wrote:

> What is the best way to find out if it is being phased out?
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Is-there-a-way-to-authorize-dynamic-destinations-with-Apache-Apollo-MQ-tp4694359p4694586.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 

Founder/CEO Spinn3r.com
Location: *San Francisco, CA*
blog: http://burtonator.wordpress.com
… or check out my Google+ profile
<https://plus.google.com/102718274791889610666/posts>
<http://spinn3r.com>

Re: Is there a way to authorize dynamic destinations with Apache Apollo MQ?

Posted by redboy1972 <re...@live.com>.
What is the best way to find out if it is being phased out?



--
View this message in context: http://activemq.2283324.n4.nabble.com/Is-there-a-way-to-authorize-dynamic-destinations-with-Apache-Apollo-MQ-tp4694359p4694586.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Is there a way to authorize dynamic destinations with Apache Apollo MQ?

Posted by Kevin Burton <bu...@spinn3r.com>.
Before you continue working with Apollo you might want to investigate
whether development will continue there. I *think* it’s being phased out in
favor of ActiveMQ 6.0 which is going to be a different codebase (with
ActiveMQ still maintained).  Don’t allow me to FUD you though so find out
for yourself.  I am not 100% certain but just wanted to give you a heads up.

Maybe check the dev list...

On Wed, Apr 8, 2015 at 5:37 PM, redboy1972 <re...@live.com> wrote:

> After a lot of head scratching I figured it out.
>
> In apollo.xml:
>
>     <broker xmlns="http://activemq.apache.org/schema/activemq/apollo"
> security_factory="com.me.MyAuthorizationPlugin">
>
> In com.me.MyAuthorizationPlugin:
>
>     package com.me
>
>     import org.fusesource.hawtdispatch.DispatchQueue.QueueType
>
>     import org.apache.activemq.apollo.broker.security._
>     import org.apache.activemq.apollo.broker.{ Queue, Broker, VirtualHost }
>     import java.lang.Boolean
>
>     class MyAuthorizationPlugin extends SecurityFactory {
>
>         def install(broker: Broker) {
>                 DefaultSecurityFactory.install(broker)
>         }
>
>         def install(virtual_host: VirtualHost) {
>                 DefaultSecurityFactory.install(virtual_host)
>                 val default_authorizer = virtual_host.authorizer
>                 virtual_host.authorizer = new Authorizer() {
>                         def can(ctx: SecurityContext, action: String,
> resource:
> SecuredResource): Boolean = {
>
>                                 println("Resource: " + resource.id + "
> User: " + ctx.user)
>                                 resource.resource_kind match {
>                                         case SecuredResource.TopicKind =>
>                                                 val id = resource.id
>                                                 println("Topic Resource: "
> + id + " User: " + ctx.user)
>                                                 var result : Boolean =
> id.startsWith("user." + ctx.user) ||
> id.startsWith("MDN." + ctx.user + ".")
>                                                 println("Result: " +
> result)
>                                                 return result
>                                         case _ =>
>                                                 return
> default_authorizer.can(ctx, action, resource)
>                                 }
>                         }
>                 }
>         }
>     }
>
>
> The following URLs seemed VERY useful and indeed nearly a perfect match:
>
>  -
>
> https://github.com/apache/activemq-apollo/blob/trunk/apollo-stomp/src/test/resources/apollo-stomp-custom-security.xml#L18
>
>  -
>
> https://github.com/apache/activemq-apollo/blob/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/UserOwnershipSecurityFactory.scala#L29
>
> Now I only need to clean up my nasty scala and put it in Git.
>
> I am thinking of doing two tests:
>
>  1. Speed of EXACTLY what I need
>  2. A Regex pattern matcher with username / clientID replacements and
> +/*/?/etc  This pattern will be pulled from the config file.
>
> If they are nearly identical I may see about adding it to Apollo by
> contacting commiters.
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Is-there-a-way-to-authorize-dynamic-destinations-with-Apache-Apollo-MQ-tp4694359p4694578.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 

Founder/CEO Spinn3r.com
Location: *San Francisco, CA*
blog: http://burtonator.wordpress.com
… or check out my Google+ profile
<https://plus.google.com/102718274791889610666/posts>
<http://spinn3r.com>

Re: Is there a way to authorize dynamic destinations with Apache Apollo MQ?

Posted by redboy1972 <re...@live.com>.
After a lot of head scratching I figured it out.

In apollo.xml:

    <broker xmlns="http://activemq.apache.org/schema/activemq/apollo"
security_factory="com.me.MyAuthorizationPlugin">

In com.me.MyAuthorizationPlugin:

    package com.me
    
    import org.fusesource.hawtdispatch.DispatchQueue.QueueType
    
    import org.apache.activemq.apollo.broker.security._
    import org.apache.activemq.apollo.broker.{ Queue, Broker, VirtualHost }
    import java.lang.Boolean
    
    class MyAuthorizationPlugin extends SecurityFactory {
    
    	def install(broker: Broker) {
    		DefaultSecurityFactory.install(broker)
    	}
    
    	def install(virtual_host: VirtualHost) {
    		DefaultSecurityFactory.install(virtual_host)
    		val default_authorizer = virtual_host.authorizer
    		virtual_host.authorizer = new Authorizer() {
    			def can(ctx: SecurityContext, action: String, resource:
SecuredResource): Boolean = {
    				
    				println("Resource: " + resource.id + " User: " + ctx.user)
    				resource.resource_kind match {
    					case SecuredResource.TopicKind =>
    						val id = resource.id
    						println("Topic Resource: " + id + " User: " + ctx.user)
    						var result : Boolean = id.startsWith("user." + ctx.user) ||
id.startsWith("MDN." + ctx.user + ".")
    						println("Result: " + result)
    						return result
    					case _ =>
    						return default_authorizer.can(ctx, action, resource)
    				}
    			}
    		}
    	}
    }


The following URLs seemed VERY useful and indeed nearly a perfect match:

 -
https://github.com/apache/activemq-apollo/blob/trunk/apollo-stomp/src/test/resources/apollo-stomp-custom-security.xml#L18

 -
https://github.com/apache/activemq-apollo/blob/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/UserOwnershipSecurityFactory.scala#L29

Now I only need to clean up my nasty scala and put it in Git.

I am thinking of doing two tests:

 1. Speed of EXACTLY what I need
 2. A Regex pattern matcher with username / clientID replacements and
+/*/?/etc  This pattern will be pulled from the config file.

If they are nearly identical I may see about adding it to Apollo by
contacting commiters.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Is-there-a-way-to-authorize-dynamic-destinations-with-Apache-Apollo-MQ-tp4694359p4694578.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.