forked from microsoft/SPID-and-Digital-Identity-Enabler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into Fix-microsoft#34-issue-with-Get-SPIDMetadata…
…s-PS-script
- Loading branch information
Showing
12 changed files
with
206 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
WebApps/Proxy/Microsoft.SPID.Proxy/Models/Extensions/WebApplicationBuilderExtesions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Azure.Identity; | ||
|
||
namespace Microsoft.SPID.Proxy.Models.Extensions | ||
{ | ||
public static class WebApplicationBuilderExtesions | ||
{ | ||
public static WebApplicationBuilder AddKeyVaultConfigurationProvider(this WebApplicationBuilder builder) | ||
{ | ||
if (!string.IsNullOrEmpty(builder.Configuration["KeyVaultName"])) | ||
{ | ||
builder.Configuration.AddAzureKeyVault( | ||
new Uri($"https://{builder.Configuration["KeyVaultName"]}.vault.azure.net/"), | ||
new DefaultAzureCredential()); | ||
} | ||
|
||
return builder; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
WebApps/Proxy/Microsoft.SPID.Proxy/Models/Options/ConfigureForwardedHeadersOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Microsoft.AspNetCore.HttpOverrides; | ||
using System.Net; | ||
|
||
namespace Microsoft.SPID.Proxy.Models.Options | ||
{ | ||
public class ConfigureForwardedHeadersOptions : IConfigureOptions<ForwardedHeadersOptions> | ||
{ | ||
private readonly IConfiguration _configuration; | ||
public ConfigureForwardedHeadersOptions(IConfiguration config) | ||
{ | ||
_configuration = config; | ||
} | ||
|
||
public void Configure(ForwardedHeadersOptions options) | ||
{ | ||
var section = _configuration.GetSection("ForwardedHeaders"); | ||
section.Bind(options); | ||
|
||
var knownProxies = section.GetValue<string>("KnownProxies")?.Split(','); | ||
var knownNetworks = section.GetValue<string>("KnownNetworks")?.Split(','); | ||
var allowedHosts = section.GetValue<string>("AllowedHosts")?.Split(','); | ||
|
||
if (knownProxies?.Length > 0) | ||
{ | ||
options.KnownProxies.Clear(); | ||
foreach (var ip in knownProxies) | ||
{ | ||
options.KnownProxies.Add(IPAddress.Parse(ip)); | ||
} | ||
} | ||
|
||
if (knownNetworks?.Length > 0) | ||
{ | ||
options.KnownNetworks.Clear(); | ||
foreach (var network in knownNetworks) | ||
{ | ||
var networkSplit = network.Split('/'); | ||
var prefix = networkSplit[0]; | ||
var prefixLength = int.Parse(networkSplit[1]); | ||
|
||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse(prefix), prefixLength)); | ||
} | ||
} | ||
|
||
if(allowedHosts?.Length > 0) | ||
{ | ||
options.AllowedHosts.Clear(); | ||
options.AllowedHosts = allowedHosts; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.