Skip to content

Commit a398cfc

Browse files
Revert "feat: add web consent redirect URIs to BYO Entra apps (#450)" (#455)
This reverts commit 091d51d. Co-authored-by: Bhaarath Raguru <bhraguru@microsoft.com>
1 parent bc1f7cf commit a398cfc

4 files changed

Lines changed: 19 additions & 233 deletions

File tree

src/Microsoft.Agents.A365.DevTools.Cli/Commands/PublishCommandExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ private void DisplayPublishSummary(ResolvedInput input)
319319
var provisioner = new EntraAppProvisioner(_logger, _graphApiService!, _retryHelper);
320320

321321
var publicClients = await provisioner.CreatePublicClientsAppAsync(
322-
input.ServerName, tenantId, serviceTreeId: null, warnings, ct: ct);
322+
input.ServerName, tenantId, serviceTreeId: null, warnings, ct);
323323

324324
return new EntraAppSet(
325325
PublicClientsClientId: publicClients.ClientId,

src/Microsoft.Agents.A365.DevTools.Cli/Commands/RegisterCommandExecutor.cs

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -705,25 +705,20 @@ private async Task ConfigureEntraAppsAsync(
705705
}
706706
else
707707
{
708-
var msg = "A365 Proxy redirect URI was not returned by the server. Setting consent redirect URIs only.";
708+
var msg = "A365 Proxy redirect URI was not returned by the server. Redirect URI configuration skipped.";
709709
_logger.LogWarning(msg);
710710
concurrentWarnings.Add(msg);
711-
tasks.Add(SetConsentOnlyRedirectUrisAsync(tenantId, apps.A365AppObjectId, apps.A365AppName, concurrentWarnings, ct));
712711
}
713712

714713
if (input.IsEntra && !string.IsNullOrWhiteSpace(remoteRedirectUri) && apps.RemoteProxyObjectId != null)
715714
{
716715
tasks.Add(UpdateRemoteProxyRedirectUrisAsync(tenantId, apps, remoteRedirectUri, concurrentWarnings, ct));
717716
}
718-
else if (input.IsEntra && apps.RemoteProxyObjectId != null)
717+
else if (input.IsEntra && string.IsNullOrWhiteSpace(remoteRedirectUri))
719718
{
720-
if (string.IsNullOrWhiteSpace(remoteRedirectUri))
721-
{
722-
var msg = "Remote MCP Proxy redirect URI was not returned by the server. Setting consent redirect URIs only.";
723-
_logger.LogWarning(msg);
724-
concurrentWarnings.Add(msg);
725-
}
726-
tasks.Add(SetConsentOnlyRedirectUrisAsync(tenantId, apps.RemoteProxyObjectId, apps.RemoteProxyAppName, concurrentWarnings, ct));
719+
var msg = "Remote MCP Proxy redirect URI was not returned by the server. Redirect URI configuration skipped.";
720+
_logger.LogWarning(msg);
721+
concurrentWarnings.Add(msg);
727722
}
728723
else if (input.IsEntra && apps.RemoteProxyObjectId == null)
729724
{
@@ -790,10 +785,7 @@ private async Task UpdateA365RedirectUrisAsync(
790785
{
791786
var a365TcUri = DevelopMcpCommand.AddTcPrefix(a365RedirectUri);
792787
var a365NonTcUri = DevelopMcpCommand.RemoveTcPrefix(a365RedirectUri);
793-
var a365Uris = DevelopMcpCommand.BuildRedirectUriList(a365RedirectUri, a365TcUri, a365NonTcUri)
794-
.Concat(EntraAppProvisioner.GetConsentRedirectUris())
795-
.Distinct(StringComparer.Ordinal)
796-
.ToArray();
788+
var a365Uris = DevelopMcpCommand.BuildRedirectUriList(a365RedirectUri, a365TcUri, a365NonTcUri);
797789
_logger.LogDebug("Updating redirect URIs on '{AppName}' ({ObjectId})", apps.A365AppName, apps.A365AppObjectId);
798790
var success = await _retryHelper.ExecuteWithRetryAsync(
799791
async retryCt => await _graphApiService!.UpdateAppRedirectUrisAsync(tenantId, apps.A365AppObjectId, a365Uris, retryCt),
@@ -827,10 +819,7 @@ private async Task UpdateRemoteProxyRedirectUrisAsync(
827819
{
828820
var remoteTcUri = DevelopMcpCommand.AddTcPrefix(remoteRedirectUri);
829821
var remoteNonTcUri = DevelopMcpCommand.RemoveTcPrefix(remoteRedirectUri);
830-
var remoteUris = DevelopMcpCommand.BuildRedirectUriList(remoteRedirectUri, remoteTcUri, remoteNonTcUri)
831-
.Concat(EntraAppProvisioner.GetConsentRedirectUris())
832-
.Distinct(StringComparer.Ordinal)
833-
.ToArray();
822+
var remoteUris = DevelopMcpCommand.BuildRedirectUriList(remoteRedirectUri, remoteTcUri, remoteNonTcUri);
834823
_logger.LogDebug("Updating redirect URIs on '{AppName}' ({ObjectId})", apps.RemoteProxyAppName, apps.RemoteProxyObjectId);
835824
var success = await _retryHelper.ExecuteWithRetryAsync(
836825
async retryCt => await _graphApiService!.UpdateAppRedirectUrisAsync(tenantId, apps.RemoteProxyObjectId!, remoteUris, retryCt),
@@ -855,37 +844,6 @@ private async Task UpdateRemoteProxyRedirectUrisAsync(
855844
}
856845
}
857846

858-
private async Task SetConsentOnlyRedirectUrisAsync(
859-
string tenantId, string objectId, string appName,
860-
System.Collections.Concurrent.ConcurrentBag<string> concurrentWarnings,
861-
CancellationToken ct = default)
862-
{
863-
try
864-
{
865-
var consentUris = EntraAppProvisioner.GetConsentRedirectUris();
866-
var success = await _retryHelper.ExecuteWithRetryAsync(
867-
async retryCt => await _graphApiService!.UpdateAppRedirectUrisAsync(tenantId, objectId, consentUris, retryCt),
868-
result => !result,
869-
cancellationToken: ct);
870-
if (!success)
871-
{
872-
var msg = $"Failed to set web redirect URIs on '{appName}' after retries.";
873-
_logger.LogError(msg);
874-
concurrentWarnings.Add(msg);
875-
}
876-
else
877-
{
878-
_logger.LogDebug("Set {Count} web redirect URIs on '{AppName}'", consentUris.Length, appName);
879-
}
880-
}
881-
catch (Exception ex)
882-
{
883-
var msg = $"Failed to set web redirect URIs on '{appName}': {ex.Message}";
884-
_logger.LogError(msg);
885-
concurrentWarnings.Add(msg);
886-
}
887-
}
888-
889847
private async Task AddRemoteProxyScopePermissionAsync(
890848
string tenantId, ResolvedInput input, EntraAppSet apps,
891849
System.Collections.Concurrent.ConcurrentBag<string> concurrentWarnings,

src/Microsoft.Agents.A365.DevTools.Cli/Services/EntraAppProvisioner.cs

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,6 @@ internal class EntraAppProvisioner
2222
"http://localhost",
2323
];
2424

25-
private static readonly string[] ProdConsentRedirectUris =
26-
[
27-
"https://admin.cloud.microsoft/?ref=tools/consent",
28-
];
29-
30-
internal static string[] GetConsentRedirectUris(string? environment = null)
31-
{
32-
var trimmed = environment?.Trim();
33-
var resolved = string.IsNullOrEmpty(trimmed)
34-
? Environment.GetEnvironmentVariable("A365_ENVIRONMENT")?.Trim() ?? "prod"
35-
: trimmed;
36-
var envKey = resolved.ToUpperInvariant();
37-
var customUris = Environment.GetEnvironmentVariable($"A365_CONSENT_REDIRECT_URIS_{envKey}");
38-
if (!string.IsNullOrWhiteSpace(customUris))
39-
{
40-
return customUris.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
41-
}
42-
43-
return [.. ProdConsentRedirectUris];
44-
}
45-
4625
private readonly ILogger _logger;
4726
private readonly GraphApiService _graphApiService;
4827
private readonly RetryHelper _retryHelper;
@@ -116,30 +95,6 @@ internal sealed record PublicClientsAppResult(string? ClientId, string? ObjectId
11695
return new ProxyAppResult(app.Value.ClientId, secret, app.Value.ObjectId, appName);
11796
}
11897

119-
private async Task SetWebConsentRedirectUrisAsync(
120-
string tenantId, string objectId, string appName, string roleDisplay,
121-
string? environment, CancellationToken ct, List<string>? warnings = null)
122-
{
123-
var consentUris = GetConsentRedirectUris(environment);
124-
125-
var success = await _retryHelper.ExecuteWithRetryAsync(
126-
async retryCt => await _graphApiService.UpdateAppRedirectUrisAsync(tenantId, objectId, consentUris, retryCt),
127-
result => !result,
128-
cancellationToken: ct);
129-
if (success)
130-
{
131-
_logger.LogDebug(
132-
"Set {RedirectUriCount} web redirect URIs on '{AppName}' ({ObjectId}): {RedirectUris}",
133-
consentUris.Length, appName, objectId, string.Join(", ", consentUris));
134-
}
135-
else
136-
{
137-
var msg = $"Failed to set web redirect URIs on {roleDisplay} app '{appName}' after retries.";
138-
_logger.LogWarning(msg);
139-
warnings?.Add(msg);
140-
}
141-
}
142-
14398
/// <summary>
14499
/// Best-effort compensating delete for an Entra app that was successfully created but failed
145100
/// a follow-up step (secret creation, post-create validation). Without this, partial failures
@@ -192,7 +147,6 @@ internal virtual async Task<PublicClientsAppResult> CreatePublicClientsAppAsync(
192147
string tenantId,
193148
string? serviceTreeId,
194149
List<string> warnings,
195-
string? environment = null,
196150
CancellationToken ct = default)
197151
{
198152
var appName = $"{serverName}-PublicClients";
@@ -222,21 +176,19 @@ internal virtual async Task<PublicClientsAppResult> CreatePublicClientsAppAsync(
222176
cancellationToken: ct);
223177
if (!success)
224178
{
225-
var msg = $"Failed to set publicClient redirect URIs on Public Clients app '{appName}' after retries.";
179+
var msg = $"Failed to set redirect URIs on Public Clients app '{appName}' after retries.";
226180
_logger.LogError(msg);
227181
warnings.Add(msg);
228182
}
229183
else
230184
{
231185
_logger.LogDebug(
232-
"Set {RedirectUriCount} publicClient redirect URIs on '{AppName}' ({ObjectId}): {RedirectUris}",
186+
"Set {RedirectUriCount} redirect URIs on '{AppName}' ({ObjectId}): {RedirectUris}",
233187
publicClientUris.Length,
234188
appName,
235189
objectId,
236190
string.Join(", ", publicClientUris));
237191
}
238-
239-
await SetWebConsentRedirectUrisAsync(tenantId, objectId, appName, "Public Clients", environment, ct, warnings);
240192
}
241193
catch (Exception ex)
242194
{

0 commit comments

Comments
 (0)