Closed tstone84 closed 7 years ago
FWIW I cannot reproduce, Tried with the usual accesstoken authentication setup and this controller code:
[Authorize]
[RoutePrefix("")]
public class DefaultController : ApiController
{
[HttpGet]
[Route("")]
public IHttpActionResult Index()
{
var ctx = Request.GetOwinContext();
return Ok(ctx.Authentication.User.Identity.Name);
}
}
No error.
@CrescentFresh You would need to be using Thinktecture.IdentityModel ResourceAuthorization package. I ended up just implementing my own custom Authorize attribute and got it working by simply pulling the Principal off of the request context.
Your issue description is off-base then.
As it's stated, "I am using this package... When I add an Authorize attribute to my controller ... the Request.GetOwinContext() return null". This is false as my example shows.
If there is a problem with Thinktecture.IdentityModel.ResourceAuthorize you should open a ticket in that package's issue tracker.
@CrescentFresh It has been a while since I placed this issue here and I'm fairly certain it is not off-base because at the time I was having that issue. Just because you can get a controller working and pasting that code here doesn't mean a lot. You may have different nuget packages installed, different config, etc. Again, it's been so long since I placed this issue here that I've moved past this which my own solution.
Relax, I said your issue description is off-base. I'm sure you have real code that is broken.
I was just clarifying for others that the description in the original ticket does not match your follow-up comment describing the problem as it lies in ResourceAuthorization.
Sorry, not sure, but since you have a workaround we'll close.
I am using this package in conjunction with IdentityServer3. When I add an Authorize attribute to my controller I can successfully get the User through the User on the controller, however, the Request.GetOwinContext() return null. This normally wouldn't be a major issue, however, it causes issues when working with other packages for ResourceAuthorization (Thinktecture.IdentityModel), which uses Request.GetOwinContext() within many of it's methods.
Am I missing some configuration or is this just a bug?