data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

[Enhancement]: Simulate Claims in Development

Open JerryNixon opened this issue 1 year ago • 0 comments

What is it?

  • Simulate custom token claims for development and testing scenarios.
  • Allow testing of authentication and role-based policies without a live Azure Entra ID tenant.
  • Provide simulator-claims under the Simulator provider for flexible role/claim injection during development.

Currently, using Simulator grants the default role authenticated, but doesn't allow injecting claims for policy testing. This enhancement introduces simulator-claims, letting developers test claims-based logic locally.

Configuration Example

{
  "authentication": {
    "provider": "Simulator",
    "simulator-claims": {
      "roles": ["admin"],
      "groups": ["dev-team"],
      "custom_claims": {
        "region": "US",
        "accessLevel": "developer"
      }
    }
  }
}

This lets developers test scenarios based on simulated roles and claims without needing Azure Entra ID.

Environment-Specific Config

To prevent accidental deployment of simulated claims to production, use environment-specific configuration files (e.g., appsettings.Development.json). This allows developers to safely use simulator-claims during development while keeping production configuration clean.

Benefits

  • Test role-based access and claims scenarios without external dependencies.
  • Ensure policies behave as expected in local environments.
  • Use environment-specific config files to avoid deploying simulation settings to production.

Related Issues to Close

  • #842
  • #865
  • #2115
  • #1113

JerryNixon avatar Sep 06 '24 18:09 JerryNixon