Only one claim of type 'role' is returned to the hub
See original GitHub issueDescribe the bug
I am using Azure SignalR via server-side blazor, and am running into an issue where all but one of my ‘role’ claims are being dropped.
I understand that, as per this issue, claims will be duplicated under an alias if they are present in the default JWT claim type mapping. The issue only seems to occur when there are multiple claims of a type which will be aliased. For example:
HttpContext Claims
sub = userid
email = user@example.com
role = Role1
role = Role2
role = Role3
role = Role4
Hub Claims
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier = userid
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress = user@example.com
http://schemas.microsoft.com/ws/2008/06/identity/claims/role = Role1
http://schemas.microsoft.com/ws/2008/06/identity/claims/role = Role2
http://schemas.microsoft.com/ws/2008/06/identity/claims/role = Role3
http://schemas.microsoft.com/ws/2008/06/identity/claims/role = Role4
sub = userid
email = user@example.com
role = Role1
Here, all roles are present in there aliased form, but only the first has been un-aliased
To Reproduce
Have a HttpContext
user as follows:
var user = new ClaimsPrincipal(new ClaimsIdentity(new[] {
new Claim("sub", "userId"),
new Claim("email", "user@example.com"),
new Claim("role", "Role1"),
new Claim("role", "Role2"),
new Claim("role", "Role3"),
new Claim("role", "Role4"),
}, authenticationType: "Any", nameType: "name" roleType: "role");
Further technical details
- Your Azure SignalR SDK version: 1.5.1
- Your Server ASPNETCORE version or Assembly version of
Microsoft.AspNetCore.SignalR
: 3.1 - Your SignalR Client SDK version: 3.1 (unsure, using this via blazor server on AspNetCore 3.1)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Authentication and authorization in ASP.NET Core SignalR
SignalR can be used with ASP.NET Core authentication to associate a user with each connection. In a hub, authentication data can be accessed ......
Read more >Authentication and Authorization for SignalR Hubs
SignalR provides the Authorize attribute to specify which users or roles have access to a hub or method. This attribute is located in...
Read more >API (GraphQL) - Authorization rules - Amplify Docs
Use the @auth directive to configure authorization rules for public, sign-in user, per user, and per user group data access.
Read more >Troubleshooting access denied error messages
If multiple policy types deny an authorization request, AWS includes only one of those policy types in the error message.
Read more >Claim users to your organization ("convert" users)
If you have the domain claimed, you can temporarily release the domain, retract the user, and then claim the domain again.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, that makes sense. For now we are just modifying the list of role claims to a single role claim, which contains a pipe-delimited list of roles (e.g. “admin|superadmin|reportsconsumer”). Then our authenticating filter for SignalR parses the string back into a list of individual roles to check against allowed permissions.
Thanks for pointing out the issue. We indeed only handle the first one, this involves service side change and we will fix it in the next deployment cycle which is scheduled to be one month later.