Skip to content

Commit 60a3689

Browse files
committed
cortex scenario
1 parent 3a3b8d5 commit 60a3689

File tree

5 files changed

+45
-14
lines changed

5 files changed

+45
-14
lines changed

src/Network/Network/Cortex/VpnServerConfiguration/NewAzureRmVpnServerConfigurationCommand.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,26 @@ public class NewAzureRmVpnServerConfigurationCommand : VpnServerConfigurationBas
8787
public string[] VpnClientRevokedCertificateFilesList { get; set; }
8888

8989
[Parameter(
90-
Mandatory = true,
90+
Mandatory = false,
9191
ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication,
9292
HelpMessage = "P2S External Radius server address.")]
9393
[ValidateNotNullOrEmpty]
9494
public string RadiusServerAddress { get; set; }
9595

9696
[Parameter(
97-
Mandatory = true,
97+
Mandatory = false,
9898
ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication,
9999
HelpMessage = "P2S External Radius server secret.")]
100100
[ValidateNotNullOrEmpty]
101101
public SecureString RadiusServerSecret { get; set; }
102102

103+
[Parameter(
104+
Mandatory = false,
105+
ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication,
106+
HelpMessage = "P2S External multiple radius servers.")]
107+
[ValidateNotNullOrEmpty]
108+
public PSRadiusServer[] RadiusServers { get; set; }
109+
103110
[Parameter(
104111
Mandatory = false,
105112
ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication,
@@ -172,6 +179,7 @@ public override void Execute()
172179
this.VpnClientRevokedCertificateFilesList,
173180
this.RadiusServerAddress,
174181
this.RadiusServerSecret,
182+
this.RadiusServers,
175183
this.RadiusServerRootCertificateFilesList,
176184
this.RadiusClientRootCertificateFilesList,
177185
this.AadTenant,

src/Network/Network/Cortex/VpnServerConfiguration/UpdateAzureRmVpnServerConfigurationCommand.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,21 @@ public class UpdateAzureRmVpnServerConfigurationCommand : VpnServerConfiguration
187187
[ValidateNotNullOrEmpty]
188188
public SecureString RadiusServerSecret { get; set; }
189189

190+
[Parameter(
191+
Mandatory = false,
192+
ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication,
193+
HelpMessage = "P2S External multiple radius servers.")]
194+
[Parameter(
195+
Mandatory = false,
196+
ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByRadiusAuthentication,
197+
HelpMessage = "P2S External multiple radius servers.")]
198+
[Parameter(
199+
Mandatory = false,
200+
ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByRadiusAuthentication,
201+
HelpMessage = "P2S External multiple radius servers.")]
202+
[ValidateNotNullOrEmpty]
203+
public PSRadiusServer[] RadiusServers { get; set; }
204+
190205
[Parameter(
191206
Mandatory = false,
192207
ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication,
@@ -374,10 +389,7 @@ public override void Execute()
374389
vpnServerConfigurationToUpdate.RadiusServerSecret = SecureStringExtensions.ConvertToString(this.RadiusServerSecret);
375390
}
376391

377-
if (vpnServerConfigurationToUpdate.RadiusServerAddress == null || vpnServerConfigurationToUpdate.RadiusServerSecret == null)
378-
{
379-
throw new ArgumentException("Both radius server address and secret must be specified if VpnAuthenticationType is being configured as Radius.");
380-
}
392+
vpnServerConfigurationToUpdate.RadiusServers = this.RadiusServers?.ToList();
381393

382394
// Read the RadiusServerRootCertificates if present
383395
if (this.RadiusServerRootCertificateFilesList != null)

src/Network/Network/Cortex/VpnServerConfiguration/VpnServerConfigurationBaseCmdlet.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public PSVpnServerConfiguration CreateVpnServerConfigurationObject(
104104
string[] vpnClientRevokedCertificateFilesList,
105105
string radiusServerAddress,
106106
SecureString radiusServerSecret,
107+
PSRadiusServer[] radiusServers,
107108
string[] radiusServerRootCertificateFilesList,
108109
string[] radiusClientRootCertificateFilesList,
109110
string aadTenant,
@@ -172,13 +173,17 @@ public PSVpnServerConfiguration CreateVpnServerConfigurationObject(
172173
// VpnAuthenticationType = Radius related validations.
173174
else if (vpnAuthenticationType.Contains(MNM.VpnAuthenticationType.Radius))
174175
{
175-
if (radiusServerAddress == null || radiusServerSecret == null)
176+
if (vpnServerConfiguration.RadiusServerAddress != null)
176177
{
177-
throw new ArgumentException("Both radius server address and secret must be specified if VpnAuthenticationType is being configured as Radius.");
178+
vpnServerConfiguration.RadiusServerAddress = radiusServerAddress;
178179
}
179180

180-
vpnServerConfiguration.RadiusServerAddress = radiusServerAddress;
181-
vpnServerConfiguration.RadiusServerSecret = SecureStringExtensions.ConvertToString(radiusServerSecret);
181+
if (vpnServerConfiguration.RadiusServerSecret != null)
182+
{
183+
vpnServerConfiguration.RadiusServerSecret = SecureStringExtensions.ConvertToString(radiusServerSecret);
184+
}
185+
186+
vpnServerConfiguration.RadiusServers = radiusServers?.ToList();
182187

183188
// Read the RadiusServerRootCertificates if present
184189
if (radiusServerRootCertificateFilesList != null)

src/Network/Network/Models/Cortex/PSVpnServerConfiguration.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class PSVpnServerConfiguration : PSTopLevelResource
4141

4242
public string RadiusServerSecret { get; set; }
4343

44+
public List<PSRadiusServer> RadiusServers { get; set; }
45+
4446
public PSAadAuthenticationParameters AadAuthenticationParameters { get; set; }
4547

4648
[Ps1Xml(Label = "P2SVpnGateway ids", Target = ViewControl.Table)]
@@ -61,6 +63,12 @@ public string VpnClientRevokedCertificatesText
6163
get { return JsonConvert.SerializeObject(VpnClientRevokedCertificates, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
6264
}
6365

66+
[JsonIgnore]
67+
public string RadiusServersText
68+
{
69+
get { return JsonConvert.SerializeObject(RadiusServers, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
70+
}
71+
6472
[JsonIgnore]
6573
public string RadiusServerRootCertificatesText
6674
{

src/Network/Network/VirtualNetworkGateway/UpdateAzureVirtualNetworkGatewayCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,11 @@ public override void Execute()
314314

315315
if (ParameterSetName.Contains(VirtualNetworkGatewayParameterSets.RadiusServerConfiguration))
316316
{
317-
if ((this.RadiusServerSecret == null || this.RadiusServerAddress == null) && (this.RadiusServers == null || !this.RadiusServers.Any()))
317+
if (this.RadiusServerAddress != null)
318318
{
319-
throw new ArgumentException("Both radius server address and secret must be specified if external radius is being configured");
319+
this.VirtualNetworkGateway.VpnClientConfiguration.RadiusServerAddress = this.RadiusServerAddress;
320320
}
321321

322-
this.VirtualNetworkGateway.VpnClientConfiguration.RadiusServerAddress = this.RadiusServerAddress;
323-
324322
if (this.RadiusServerSecret != null)
325323
{
326324
this.VirtualNetworkGateway.VpnClientConfiguration.RadiusServerSecret = SecureStringExtensions.ConvertToString(this.RadiusServerSecret);

0 commit comments

Comments
 (0)