c# - How can I access the current request from my own authorization class? -


I need to access the request object from my own authorization class. There is no alternative and why is it here.

  • Users are
  • Users can have specific permissions for the object
  • Objects Can be made public (read / write too)

    Due to this system I have to write my authorization argument and this is not a problem, I was thinking something like this:

    pseudo code

      public class object controller: API controller {private readonly authorization service _auth = new The Authority Services (); [Root] Public Eschnic Tasks & lt; IHttpActionResult & gt; Get () {var obj = new object (); // This is the object that we are working with // Note: This is just for the demo, the real object will be like `item` if (obj.IsPublic || _auth.CurrentUser.CanRead (obj)) OK Obj); } Return unauthorized (); }}  

    How do I test the current user

    1. Check whether the header token
    2. check URL is the ultimate ? Token =
    3. Get user from token
    4. user or return zero

    problem

    now because I need to check the weather. This user has read this item (obj) AFAIK. I can not use the controller feature because I need to first get the actual object from the database. What are my options? Can I use an existing request object to extract the values ​​required in my authority service class?

    You can access


    Comments

    Popular posts from this blog

    import - Python ImportError: No module named wmi -

    Editing Python Class in Shell and SQLAlchemy -

    c# - MySQL Parameterized Select Query joining tables issue -