StompServer offers events as a way to trigger custom behaviour when broker is processing a command. Unfortunately this does not give an event handler an opportunity to affect command processing flow, which makes it unsuitable mechanism to implement authentication/authorisation.
In this pull request I am proposing alternate solution for hooking up middle-ware functions for command handlers. You can register multiple middle-ware and they will be processed in order. Each middle-ware takes full responsibility of execution flow, and can decide to call next() middle-ware in chain, or respond with error. The mechanism of chaining middle-ware allows for having asynchronous code inside them.
StompServer offers events as a way to trigger custom behaviour when broker is processing a command. Unfortunately this does not give an event handler an opportunity to affect command processing flow, which makes it unsuitable mechanism to implement authentication/authorisation.
In this pull request I am proposing alternate solution for hooking up middle-ware functions for command handlers. You can register multiple middle-ware and they will be processed in order. Each middle-ware takes full responsibility of execution flow, and can decide to call
next()
middle-ware in chain, or respond with error. The mechanism of chaining middle-ware allows for having asynchronous code inside them.