apereo / dotnet-cas-client

Apereo .NET CAS Client
Apache License 2.0
234 stars 172 forks source link

Attributes are not available when using AssertionRoleProvider #111

Closed DustinLuck closed 4 years ago

DustinLuck commented 4 years ago

When I add support for roles in the web.config of my app, I can no longer get attributes for the logged-in user.

<roleManager enabled="true" defaultProvider="AssertionRoleProvider">
      <providers>
          <add
              name="AssertionRoleProvider"
              type="DotNetCasClient.Security.AssertionRoleProvider"
              roleAttributeName="role" />
      </providers>
</roleManager>

I would normally be able to find the attributes in the Assertion object under Controller.User, but that doesn't exist when using the AssertionRoleProvider.

My app is using C# MVC and the protocol is Saml11. The role-based authorization works fine.

DustinLuck commented 4 years ago

I was able to figure out how to get the attributes.

Rather than getting the principal using this line:

ICasPrincipal p = User as ICasPrincipal;

I used this line:

ICasPrincipal p = CasAuthentication.CurrentPrincipal;