Azure Function authentication using Azure Active Directory

后端 未结 2 1184
生来不讨喜
生来不讨喜 2020-12-03 16:34

I wanted to enable authentication on Azure Functions. So, I decided to go with EasyAuth (Authentication/Authorization link under platform features) and was successfully able

2条回答
  •  旧时难觅i
    2020-12-03 16:47

    We could use the accesstoken to access the you azure function api directly, if your azure function authentication level is anonymous or function key is also required.

    I get the access token with your mentioned way. According to the Azure Resources portal(https://resources.azure.com/), the default allowedAudiences is

      "https://{functionAppName}.azurewebsites.net/.auth/login/aad/callback"
    

    So I add the https://{functionAppName}.azurewebsites.net/ as allowed aduiences

    Then I can use the access token directly. I test it with postman.

    We also could use the following way to get easy auth token. The access token is the token that you got.

    Post https://xxx.azurewebsites.net/.auth/login/aad
    Content-Type:application/json
    {
        "access_token":"eyJ0eXAiOix...rtf2H7lyUL-g34HVw"
    }
    

    After that we could use the get token to access the azure function api

    Note: Header is x-zumo-auth: token

提交回复
热议问题