New middleware registration method
Make permission checking more generic

Instead of testing each permission individually, pass the entire list to
each checker.
Handle null value for listener ID