filip
filip

Reputation: 1513

MVC4 - claims based authorization with standard authorization attribute

I have an MVC4 app configured to use Claims Based authentication using the Identity and Access VS extension, which creates system.identityModel and system.identityModel.services section in the web.config.

For authorization I'm using standard attributes e.g.

[Authorize(Roles = "Admin")]

The role should be taken from the Role claim (http://schemas.microsoft.com/ws/2008/06/identity/claims/role) and not from the membership database.

This solution actually worked fine at the beginning. However, when I copied it to other machine I'm getting SQL connection error when the Authorize attribute is hit.

My understanding is that it tries to connect first to the local membership db to check the role. Can I tell MVC to check the role first in the claim?

Upvotes: 2

Views: 2009

Answers (1)

filip
filip

Reputation: 1513

Since there were no answers I decided to implement my solution as described here: http://fczaja.blogspot.com/2013/12/claims-based-authorization-in-mvc4.html

Upvotes: 3

Related Questions