Skip to content

Commit

Permalink
Merge pull request #2446 from sbwalker/dev
Browse files Browse the repository at this point in the history
add upgrade logic for sites using remapped identifier and email claim…
  • Loading branch information
sbwalker authored Sep 30, 2022
2 parents 172faec + a04c722 commit e40bf08
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
4 changes: 0 additions & 4 deletions Oqtane.Client/Modules/Admin/Users/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -602,14 +602,10 @@ else
if (_providertype == AuthenticationProviderTypes.OpenIDConnect)
{
_scopes = "openid,profile,email";
_identifierclaimtype = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier";
_emailclaimtype = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress";
}
else
{
_scopes = "";
_identifierclaimtype = "sub";
_emailclaimtype = "email";
}
}
_redirecturl = PageState.Uri.Scheme + "://" + PageState.Alias.Name + "/signin-" + _providertype;
Expand Down
39 changes: 39 additions & 0 deletions Oqtane.Server/Infrastructure/UpgradeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public void Upgrade(Tenant tenant, string version)
case "3.2.0":
Upgrade_3_2_0(tenant, scope);
break;
case "3.2.1":
Upgrade_3_2_1(tenant, scope);
break;
}
}
}
Expand Down Expand Up @@ -264,5 +267,41 @@ private void Upgrade_3_2_0(Tenant tenant, IServiceScope scope)
}
}

private void Upgrade_3_2_1(Tenant tenant, IServiceScope scope)
{
try
{
// convert Identifier Claim Type and Email Claim Type
var settingRepository = scope.ServiceProvider.GetRequiredService<ISettingRepository>();
var siteRepository = scope.ServiceProvider.GetRequiredService<ISiteRepository>();
foreach (Site site in siteRepository.GetSites().ToList())
{
var settings = settingRepository.GetSettings(EntityNames.Site, site.SiteId).ToList();
var setting = settings.FirstOrDefault(item => item.SettingName == "ExternalLogin:IdentifierClaimType");
if (setting != null)
{
if (setting.SettingValue == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier")
{
setting.SettingValue = "sub";
settingRepository.UpdateSetting(setting);
}
}
setting = settings.FirstOrDefault(item => item.SettingName == "ExternalLogin:EmailClaimType");
if (setting != null)
{
if (setting.SettingValue == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress")
{
setting.SettingValue = "email";
settingRepository.UpdateSetting(setting);
}
}
}
}
catch (Exception ex)
{
Debug.WriteLine($"Oqtane Error: Error In 3.2.1 Upgrade Logic - {ex}");
}
}

}
}

0 comments on commit e40bf08

Please sign in to comment.