Skip to content

Commit 67babb2

Browse files
authored
Accept both client ID and application ID URI as valid audiences (#249)
1 parent e6c8660 commit 67babb2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mcpserver/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
var tenantId = Environment.GetEnvironmentVariable("TW_ENTRA_TENANT_ID") ?? "";
1010
var audience = Environment.GetEnvironmentVariable("TW_ENTRA_AUDIENCE") ?? "";
11+
var clientId = Environment.GetEnvironmentVariable("TW_ENTRA_CLIENT_ID") ?? "";
1112
var mcpResource = Environment.GetEnvironmentVariable("TW_MCP_RESOURCE") ?? "";
1213

1314
if (string.IsNullOrWhiteSpace(tenantId))
@@ -16,6 +17,9 @@
1617
if (string.IsNullOrWhiteSpace(audience))
1718
throw new InvalidOperationException("TW_ENTRA_AUDIENCE must be set to a valid Entra audience.");
1819

20+
if (string.IsNullOrWhiteSpace(clientId))
21+
throw new InvalidOperationException("TW_ENTRA_CLIENT_ID must be set to the Entra app registration's client ID.");
22+
1923
if (string.IsNullOrWhiteSpace(mcpResource))
2024
throw new InvalidOperationException("TW_MCP_RESOURCE must be set to the canonical URL of this MCP server (e.g. https://mcp.example.com).");
2125

@@ -46,7 +50,7 @@
4650
ValidateAudience = true,
4751
ValidateLifetime = true,
4852
ValidateIssuerSigningKey = true,
49-
ValidAudience = audience,
53+
ValidAudiences = new[] { audience, clientId },
5054
ValidIssuer = authority,
5155
};
5256
})

0 commit comments

Comments
 (0)