How to call web API under specific user permission?

前端 未结 2 894
猫巷女王i
猫巷女王i 2021-01-27 21:20

I have a function that allows the end user to execute a Workflow (containing many APIs) or schedule it to run as a background job.

Example: User1

相关标签:
2条回答
  • 2021-01-27 22:02

    In the case of executing an API directly, how do I run it under a specific permission?

    You can override current session values and call your method inside the using block.

    I have put my code inside a using block, but all APIs were fired successfully

    Declare your API methods as public virtual as there are some restrictions for AbpAuthorize.

    0 讨论(0)
  • 2021-01-27 22:15

    You have two options.

    1- You can make those Application Services anonymously accessible. And if you want it to be secure, send an encrypted security token.

    2- You didn't mention if your project is MVC or Angular. I assume you have Angular version. You need a bearer token to make authenticated requests. First you have to authenticate user and get a token. Then add this bearer token to every request.

    You have to research for using bearer tokens in asp.net core...

    0 讨论(0)
提交回复
热议问题