AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

How to check custom permissions before odata query executing

Open P9avel opened this issue 2 years ago • 3 comments

Hi, i have query /odata/Clients$filter=containts And i am using JWT for authorization. I am want to get HttpContext.User before query executing and checking custom permissions (custom logic) and return

  1. In same cases Http401
  2. In same cases empty result without Http401 or exception
  3. In same cases my exception (my middleware processing my exception) How to do this?

P9avel avatar Sep 29 '23 21:09 P9avel

@P9avel please consider using the "Discussions" tab for asking questions.

Also, from what I understand, what you need to do has nothing to do with OData: you can use the same logic as a normal MVC controller to check permissions/perform authorization.

julealgon avatar Sep 29 '23 23:09 julealgon

@P9avel I think you can create a class derived from EnableQueryAttribute and override the 'OnActionExecuting', or 'OnActionExecuted' to add your check logic.

xuzhg avatar Oct 02 '23 20:10 xuzhg

Many thx for EnableQueryAttribute

P9avel avatar Oct 03 '23 08:10 P9avel