0

How can I do something like this:

        [OfficeAuthorize(HttpContext.Request.etc)]

I'm guessing it's some sort of DependencyInjection, but I'm not sure where I would do that.

2
  • 1
    codeproject.com/Articles/390422/… Commented Feb 13, 2020 at 0:54
  • My Api has the officeId in the Url /api/{officeId}/etc I want to check if the user is in that office with my own custom authorization attribute. Commented Feb 13, 2020 at 0:58

1 Answer 1

3

the context was available via the AuthorizationFilterContext in the OnAuthorizing function

    public void OnAuthorization(AuthorizationFilterContext context)
    {
        var body = context.HttpContext.Request.Body;
        //custom validation rule
    }
Sign up to request clarification or add additional context in comments.

3 Comments

Note that AuthorizationFilterContext also has a property ActionDescriptor, which in turn has a RouteValues property. This should contain officeId.
@John do you have an example of using ActionDescriptor in this scenario?
I do not, but you could set a breakpoint and inspect its values at runtime to get an idea of how the data is structured.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.