Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix required tenant in OpenId Validation settings UI #17266

Merged
merged 3 commits into from
Dec 24, 2024
Merged
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 @@ -64,19 +64,22 @@ public override async Task<IDisplayResult> UpdateAsync(OpenIdValidationSettings

await context.Updater.TryUpdateModelAsync(model, Prefix);

settings.Authority = !string.IsNullOrEmpty(model.Authority) ? new Uri(model.Authority, UriKind.Absolute) : null;
var hasAuthority = !string.IsNullOrEmpty(model.Authority);

settings.Authority = hasAuthority ? new Uri(model.Authority, UriKind.Absolute) : null;
settings.MetadataAddress = !string.IsNullOrEmpty(model.MetadataAddress) ? new Uri(model.MetadataAddress, UriKind.Absolute) : null;
settings.Audience = model.Audience?.Trim();
settings.DisableTokenTypeValidation = model.DisableTokenTypeValidation;
settings.Tenant = model.Tenant;

if (string.IsNullOrWhiteSpace(model.Tenant))
{
context.Updater.ModelState.AddModelError(Prefix, nameof(model.Tenant), S["tenant is a required value"]);
}
else if (!_shellHost.TryGetShellContext(model.Tenant, out var shellContext) || !shellContext.Settings.IsRunning())
if (!string.IsNullOrEmpty(model.Tenant) &&
(!_shellHost.TryGetShellContext(model.Tenant, out var shellContext) || !shellContext.Settings.IsRunning()))
{
context.Updater.ModelState.AddModelError(Prefix, nameof(model.Tenant), S["Invalid tenant value."]);
}
else if (!hasAuthority)
{
context.Updater.ModelState.AddModelError(Prefix, nameof(model.Authority), S["A tenant or authority value is required."]);
}

return await EditAsync(settings, context);
Expand Down
Loading