Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ Microsoft Identity (Entra ID) with MSAL. App registration:
- Tenant: `<YOUR_ENTRA_TENANT_ID>`
- Client ID: `<YOUR_ENTRA_CLIENT_ID>`

The chat page's **Switch Agent** dialog changes only the agent name, environment ID and schema name. It reuses the signed-in user and the server-configured app registration; it does not switch authentication tenants or client credentials. The selected agent must be accessible through that existing sign-in.

Configure credentials on the server, not in the browser. Saved agent profiles contain only agent identifiers. Older saved profiles remain readable, but their tenant/client fields are ignored and omitted when profiles are saved again.

For local dev, add to `appsettings.Development.json` or user secrets:
```json
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,7 @@
@bind="editSchemaName" />
</div>

<div class="agent-form-separator"></div>

<div class="agent-form-field">
<label class="agent-field-label">Tenant ID</label>
<input class="agent-field-input" type="text"
placeholder="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
@bind="editTenantId" />
</div>
<div class="agent-form-field">
<label class="agent-field-label">Client ID</label>
<input class="agent-field-input" type="text"
placeholder="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
@bind="editClientId" />
</div>
<div class="agent-form-field">
<label class="agent-field-label">Client Secret</label>
<input class="agent-field-input" type="password"
placeholder="Enter client secret"
@bind="editClientSecret" />
<span class="agent-field-hint">Not saved to browser storage</span>
</div>
<span class="agent-field-hint">Uses your current sign-in and the server-configured app registration. Credentials cannot be changed here.</span>
</div>
</div>

Expand Down Expand Up @@ -170,9 +150,6 @@
private string editAgentName = "";
private string editEnvironmentId = "";
private string editSchemaName = "";
private string editTenantId = "";
private string editClientId = "";
private string editClientSecret = "";
private List<AgentProfile> savedAgentProfiles = new();

protected override void OnInitialized()
Expand All @@ -182,10 +159,7 @@

private bool IsAgentFormValid =>
!string.IsNullOrWhiteSpace(editEnvironmentId) &&
!string.IsNullOrWhiteSpace(editSchemaName) &&
!string.IsNullOrWhiteSpace(editTenantId) &&
!string.IsNullOrWhiteSpace(editClientId) &&
!string.IsNullOrWhiteSpace(editClientSecret);
!string.IsNullOrWhiteSpace(editSchemaName);

private void ToggleInformativeMessages()
{
Expand Down Expand Up @@ -231,11 +205,6 @@
savedAgentProfiles = new();
}

// Pre-fill Azure AD fields from current configuration
editTenantId = Configuration["AzureAd:TenantId"] ?? "";
editClientId = Configuration["AzureAd:ClientId"] ?? "";
editClientSecret = Configuration["AzureAd:ClientSecret"] ?? "";

showAgentSelector = true;
}

Expand All @@ -245,18 +214,13 @@
editAgentName = "";
editEnvironmentId = "";
editSchemaName = "";
editTenantId = "";
editClientId = "";
editClientSecret = "";
}

private void SelectAgentProfile(AgentProfile profile)
{
editAgentName = profile.Name;
editEnvironmentId = profile.EnvironmentId;
editSchemaName = profile.SchemaName;
editTenantId = profile.TenantId;
editClientId = profile.ClientId;
}

private async Task DeleteAgentProfile(AgentProfile profile)
Expand Down Expand Up @@ -286,12 +250,10 @@
{
Name = string.IsNullOrWhiteSpace(editAgentName) ? editSchemaName : editAgentName.Trim(),
EnvironmentId = editEnvironmentId.Trim(),
SchemaName = editSchemaName.Trim(),
TenantId = editTenantId.Trim(),
ClientId = editClientId.Trim()
SchemaName = editSchemaName.Trim()
};

// Save/update in profiles list (ClientSecret is NOT saved)
// Save only agent identifiers, never authentication configuration.
savedAgentProfiles.RemoveAll(p => p.Name == profile.Name);
savedAgentProfiles.Insert(0, profile);
await SaveAgentProfiles();
Expand All @@ -301,17 +263,14 @@
{
["CopilotStudio:EnvironmentId"] = profile.EnvironmentId,
["CopilotStudio:SchemaName"] = profile.SchemaName,
["AzureAd:TenantId"] = editTenantId.Trim(),
["AzureAd:ClientId"] = editClientId.Trim(),
["AzureAd:ClientSecret"] = editClientSecret.Trim(),
};
var memConfig = new ConfigurationBuilder()
.AddInMemoryCollection(configData)
.Build();

var newSettings = new CopilotStudioConnectionSettings(
memConfig.GetSection("CopilotStudio"),
memConfig.GetSection("AzureAd"));
Configuration.GetSection("AzureAd"));

var newScope = CopilotClient.ScopeFromSettings(newSettings);
var logger = LoggerFactory.CreateLogger<CopilotClient>();
Expand All @@ -334,9 +293,6 @@
editAgentName = "";
editEnvironmentId = "";
editSchemaName = "";
editTenantId = "";
editClientId = "";
editClientSecret = "";

await chatInput!.FocusAsync();
}
Expand Down Expand Up @@ -591,7 +547,5 @@
public string Name { get; set; } = "";
public string EnvironmentId { get; set; } = "";
public string SchemaName { get; set; } = "";
public string TenantId { get; set; } = "";
public string ClientId { get; set; } = "";
}
}
Loading