Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

DirectionClient ID (Who's calling)Client Secret (Who's calling)Audience (Who's being called)
ApiService → IntegrationApiService IDApiService secretIntegrationServiceAPI ID
Integration → ApiServiceIntegrationServiceAPI IDIntegrationServiceAPI secretApiService ID

Why Bidirectional?

ApiService calls IntegrationServiceAPI when:

  • Sending work order to external system
  • Sending completion notification
  • Sending cancellation notice

IntegrationServiceAPI calls ApiService when:

  • Receiving work order from external system
  • Receiving instruction from external system
  • Updating work order status

Each service authenticates itself when making the call, proving its identity to the other service.


...

Step-by-Step Authentication Process

...

  • ✅ Use environment variables (or in Key Vault)
  • ✅ Rotate periodically (every 6-12 months)
  • ❌ Never commit to git
  • ❌ Never hardcode in source files

...

Token Validation

How IntegrationServiceAPI validates tokens:

  1. Signature Validation

    • Uses Azure AD's public keys
    • Proves token was issued by Azure AD
    • Prevents forged tokens
  2. Issuer Validation

    • Checks token came from correct Azure AD tenant
    • Prevents tokens from other organizations
  3. Audience Validation

    • Ensures token is for IntegrationServiceAPI
    • Prevents token reuse across different APIs
  4. Expiration Validation

    • Checks token hasn't expired (1 hour)
    • Includes 5-minute clock skew tolerance
  5. Permission Validation

    • Checks ApiService has required permissions
    • Based on Azure AD app role assignments

...

Configuration

ApiService Configuration

What's needed:

SettingDescriptionExample Value
Client IDApiService's application ID4dad5d62-dc8c-4378-8bd0-ae736a4d73fe
Client SecretApiService's secret keyabc123~XYZ789-VerySecret
Tenant IDAzure AD tenant6073ce8b-73f3-4df4-9b80-5e40cdc6965f
ScopeIntegrationServiceAPI scopeapi://bd5100ee-af63-4880-8c60-47d4207d60c1/.default

Where configured:

  • Environment variables (recommended)
  • appsettings.json (development only, with secrets.json)

...

IntegrationServiceAPI Configuration

What's needed:

SettingDescriptionExample Value
Client IDIntegrationServiceAPI's IDbd5100ee-af63-4880-8c60-47d4207d60c1
Client SecretIntegrationServiceAPI's secret keyxyz789~ABC123-VerySecret
Tenant IDAzure AD tenant6073ce8b-73f3-4df4-9b80-5e40cdc6965f
ScopeApiService scopeapi://4dad5d62-dc8c-4378-8bd0-ae736a4d73fe/.default

Where configured:

  • Environment variables (recommended)
  • appsettings.json (development only, with secrets.json)

...

Quick Reference

ApiService

PropertyValue
Client ID4dad5d62-dc8c-4378-8bd0-ae736a4d73fe
Needs Client Secret✅ Yes (calls IntegrationServiceAPI and validates tokens)
Tenant ID6073ce8b-73f3-4df4-9b80-5e40cdc6965f

...

IntegrationServiceAPI

PropertyValue
Client IDbd5100ee-af63-4880-8c60-47d4207d60c1
Needs Client Secret✅ Yes (calls ApiService and validates tokens)
Tenant ID6073ce8b-73f3-4df4-9b80-5e40cdc6965f