Hi there,<div><br></div><div>I'm working on an application where untrusted clients connect to RabbitMQ as consumers in a pub/sub scheme. Clients can connect either as anonymous guests or as registered users via username/password.</div><div><br></div><div>I have a backend that acts as a producer. The producer publishes two types of messages:</div><div><br></div><div>1) Public messages with information that every client should be able to consume by binding their queues to the relevant topic exchange and routing key.</div><div><br></div><div>2) Private messages that are targeted at specific users (each message is targeted at one particular user). Clients should only be able to consume messages targeted at the user with which they connected.</div><div><br></div><div>My question now is, how to best enforce this authorization scheme. It doesn't seem like RabbitMQ supports authorization based on routing keys but only on vhosts, exchanges and queues.</div><div><br></div><div>They way I would solve this is by having the producer create a topic exchange per user and only give that particular user the right to bind its queues against it. Private messages would be published to the target user's topic exchange while public messages would be published to amq.topic.</div><div><br></div><div>Is this secure or am I missing something?</div><div><br></div><div>How light-weight are exchanges in RabbitMQ? What dose the memory and computational complexity look like if there are N exchanges? O(1) or worse?</div><div><br></div><div>We are not talking about a few hundred users but hundreds of thousands, if not millions, of users - and hence millions of exchanges.</div><div><br></div><div>-Jonas</div>