1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 17:12:49 -05:00

custom DiscoveryResponseGenerator and helpers

This commit is contained in:
Kyle Spearrin
2020-09-01 07:38:36 -04:00
parent 3ad1672f8a
commit ba84c59b5d
4 changed files with 130 additions and 42 deletions

View File

@ -646,5 +646,30 @@ namespace Bit.Core.Utilities
}
return null;
}
public static Dictionary<string, object> AdjustIdentityServerConfig(Dictionary<string, object> configDict,
string publicServiceUri, string internalServiceUri)
{
var dictReplace = new Dictionary<string, object>();
foreach (var item in configDict)
{
var change = item.Key.EndsWith("_endpoint") || item.Key.EndsWith("_iframe");
if (change && item.Value is string val)
{
var uri = new Uri(val);
dictReplace.Add(item.Key, string.Concat(publicServiceUri, uri.LocalPath));
}
else if (item.Key == "jwks_uri" && item.Value is string jwksVal)
{
var uri = new Uri(jwksVal);
dictReplace.Add(item.Key, string.Concat(internalServiceUri, uri.LocalPath));
}
}
foreach (var replace in dictReplace)
{
configDict[replace.Key] = replace.Value;
}
return configDict;
}
}
}