Azure Data API builder (DAB) - Advanced Configurations

October 21, 2024

Once we have the basic configuration set up, we might want to customize it further to meet specific requirements.

Today, we will discuss some advanced options in DAB.

Custom Policies:

We can specify permissions in the configuration file to manage - who can access certain entities and what actions they can perform.

execute the following command

dab update ProductCategory --permissions "authenticated:create"
dab update ProductCategory --permissions "authenticated:read"
dab update ProductCategory --permissions "anonymous:read"

basically , we are setting the config so that anyone can read the data but only authenticated users can write to the database.

"permissions": [
        {
          "role": "authenticated",
          "actions": [
            {
              "action": "read"
            },
            { 
              "action": "create" 
            }
          ]
        },
         {
          "role": "anonymous",
          "actions": [
            {
              "action": "read"
            }
          ]
        }
      ]

This policy restricts POST actions on the ProductCategory entity to authenticated users only,enhancing security.

If we try to do a post anonymously , we get an HTTP 403 response

{
  "error": {
    "code": "AuthorizationCheckFailed",
    "message": "Authorization Failure: Access Not Allowed.",
    "status": 403
  }
}

Authentication Integration:

DAB provides us with multiple authentication methods , we can use Azure StaticWebApps based authentication or JWT based authentication using Microsoft Entra ID(formerly known as AzureAD)

We will look into local authentication as we are running DAB locally, for the sake of simplicity, we can use Simulator as an authentication provider. This allows us to simulate an authenticated request without integrating with an authentication provider.

Just mention the authentication provider as simulator in the config to simulate the authenticated requests.

"authentication": {
        "provider": "Simulator"
      }

Summary:

The advanced configuration options in Azure DAB provide developers with powerful tools to customize REST APIs effectively. Developers can ensure that the APIs are not only functional but also secure and efficient in handling data operations

Thanks for reading, Goodbye until next week!


Profile picture

Written by Thillai Madhavan Stay updated by following him on LinkedIn.

All the information on this website - OrganicDevops.com - is published in good faith and for general information purposes only. OrganicDevops.com does not make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this website (OrganicDevops.com), is strictly at your own risk. OrganicDevops.com will not be liable for any losses and/or damages in connection with the use of our website. From our website, you can visit other websites by following hyperlinks to such external sites. While we strive to provide only quality links to useful and ethical websites, we have no control over the content and nature of these sites. These links to other websites do not imply a recommendation for all the content found on these sites. Site owners and content may change without notice and may occur before we have the opportunity to remove a link that may have gone 'bad'. Please be also aware that when you leave our website, other sites may have different privacy policies and terms which are beyond our control. Please be sure to check the Privacy Policies of these sites as well as their "Terms of Service" before engaging in any business or uploading any information. By using our website, you hereby consent to our disclaimer and agree to its terms. Should we update, amend or make any changes to this document, those changes will be prominently posted here
© 2024, OrganicDevOps