I have successfully been able to use the [Authorize] attribute against Group Names which contain spaces and my own testing has revealed that spaces are indeed allowed in group names within the [Authorize(Roles = "group name"] attribute.
If your claims are originating from Active Directory and your code is attempting to authorize a request based on group membership in a specific Active Directory Group, and if the request is being denied, it is possible that the Group/Role Name you are specifying in fact does not match the claim value contained in the request Identity, and the request will be blocked.
A possible solution:
- Use Active Directory Users and Computers to locate the Active Directory Group that you wish to authorize.
- Right-click the group name and choose Properties.
- Click on the General tab.
- Locate the field 'Group name (pre-Windows 2000):'
- Inspect the group name in this field and compare it to what you are using in the [Authorize] attribute in your code.
It is possible that your Active Directory Group Name is different from the pre-Windows 2000 Group Name.
TLDR:
In my case, I discovered that I intended to authorize against the AD Group Name but the [Authorize] process was authorizing against the pre-Windows 2000 Group Name, which caused authorization to fail; the AD Group Name was not the same as the pre-Windows 2000 Group Name.
I may not have arrived at this solution without creating a View to show each claim name and associated claim value. Indeed, it became clear that the claim value contained in the request Identity was not what I expected, and this pointed me back to the Active Directory.
How to install ADUC: Active Directory Users and Computers