Assign Role when using JSON Web Tokens in HiveMQ Cloud

We want to use JSON Web Tokens for security but assigning a Role to a client does not seem to be documented anywhere.

We want to have a default Role that allows nothing (deny all), and then have 2 Roles:

  • admin: basically the same as Allow All
  • customer: limited to subscribing to a certain topic

How do we assign the correct Role when creating the JWT for the client to use to connect? We have tried building the JWT with a “role” field, as well as using the “scope” and “sub” fields. None of those seem to work correctly.

Hello @nicknick

Welcome to the HiveMQ Community! Could you clarify what JWKS endpoint solution you’re using, or are you implementing a custom build?

Kind regards,
Diego from HiveMQ Team

After talking via email with support, it sounds like this isn’t possible in the Cloud product, and we need to use the Enterprise version instead. That supports the “role defined in JWT” (or something similar).