We are trying to authenticate a MQTT client with Azure Event Grid MQTT Broker using custom JWT authentication from our own OIDC Identity Provider hosted in app service.
However, we keep encountering authentication errors related to audience validation and issuer mismatch.
We have followed the Event Grid JWT authentication guide: 🔗 Authenticate with namespaces using JSON web tokens.
We have set up a simple console app for testing, similar to this sample: https://github.com/Azure-Samples/MqttApplicationSamples/blob/main/scenarios/jwt_authentication/README.md)
topicSpacesConfiguration looks something like this:
"topicSpacesConfiguration": {
"state": "Enabled",
"hostname": "<my-event-grid-mqtt-hostname>",
"clientAuthentication": {
"customJwtAuthentication": {
"tokenIssuer": "<my-openid-server>",
"issuerCertificates": [
{
"certificateUrl": "<keyvault-url>",
"identity": {
"type": "SystemAssigned"
}
}
]
}
},
"maximumSessionExpiryInHours": 1,
"maximumClientSessionsPerAuthenticationName": 1
}
The token used by the client looks like this:
{
"iss": "https://<my-identity-provider>/",
"sub": "test-client",
"aud": "https://<my-eventgrid-mqtt-hostname>",
"exp": 1700000000,
"iat": 1699990000
}
Based on the documentation, we expected the aud
claim to be set to the Event Grid MQTT hostname, <my-eventgrid-namespace>.<region>.ts.eventgrid.azure.net. But if we do, we get an authentication error with a message saying that only "https://eventgrid.azure.net" is a valid audience:
"Message: IDX10214: Audience validation failed. Audiences: 'https://<my-eventgrid-mqtt-hostname>'. Did not match: validationParameters.ValidAudience: 'null' or validationParameters.ValidAudiences: 'https://eventgrid.azure.net, 823c0a78-5de0-4445-a7f5-c2f42d7dc89b, https://eventgrid.azure.net"
If we change the aud
claim to "https://eventgrid.azure.net", we instead receive a different error:
IDX40001: Issuer: 'https://<my-identity-provider>', does not match any of the valid issuers provided for this application.
- Have we missunderstood what the correct value for the
aud
claim should be?
- If it is supposed to be
https://eventgrid.azure.net
, how can I ensure that Event Grid recognizes my custom OIDC issuer (iss
claim)?
Any guidance would be greatly appreciated!