diff --git a/src/ServiceManagement/Services/Commands.Utilities/Properties/Resources.Designer.cs b/src/ServiceManagement/Services/Commands.Utilities/Properties/Resources.Designer.cs
index 95d14b36cc62..d2c6a3cc7b53 100644
--- a/src/ServiceManagement/Services/Commands.Utilities/Properties/Resources.Designer.cs
+++ b/src/ServiceManagement/Services/Commands.Utilities/Properties/Resources.Designer.cs
@@ -3459,6 +3459,24 @@ public static string SchedulerExistingJobCollection {
}
}
+ ///
+ /// Looks up a localized string similar to A valid value for Tenant, Secret, Audience and Clientid parameters are required for Http scheduler jobs with ActiveDirectoryOAuth authentication type..
+ ///
+ public static string SchedulerInvalidAADOAuthRequest {
+ get {
+ return ResourceManager.GetString("SchedulerInvalidAADOAuthRequest", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to A valid value for Username and Password parameters are required for Http scheduler jobs with Basic authentication type..
+ ///
+ public static string SchedulerInvalidBasicAuthRequest {
+ get {
+ return ResourceManager.GetString("SchedulerInvalidBasicAuthRequest", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to A valid value for ClientCertificatePfx and ClientCertificatePassword parameters are required for Http scheduler jobs with ClientCertificate authentication type..
///
@@ -3478,7 +3496,7 @@ public static string SchedulerInvalidLocation {
}
///
- /// Looks up a localized string similar to For None authentication type, both ClientCertificatePfx and ClientCertificatePassword parameters should be null.
+ /// Looks up a localized string similar to For None authentication type, all authentication related parameters should be null.
///
public static string SchedulerInvalidNoneAuthRequest {
get {
diff --git a/src/ServiceManagement/Services/Commands.Utilities/Properties/Resources.resx b/src/ServiceManagement/Services/Commands.Utilities/Properties/Resources.resx
index 39a13875d20d..3cea1ec63e68 100644
--- a/src/ServiceManagement/Services/Commands.Utilities/Properties/Resources.resx
+++ b/src/ServiceManagement/Services/Commands.Utilities/Properties/Resources.resx
@@ -1602,6 +1602,12 @@ use and privacy statement at <url> and (c) agree to sharing my contact inf
A valid value for ClientCertificatePfx and ClientCertificatePassword parameters are required for Http scheduler jobs with ClientCertificate authentication type.
- For None authentication type, both ClientCertificatePfx and ClientCertificatePassword parameters should be null
+ For None authentication type, all authentication related parameters should be null
+
+
+ A valid value for Tenant, Secret, Audience and Clientid parameters are required for Http scheduler jobs with ActiveDirectoryOAuth authentication type.
+
+
+ A valid value for Username and Password parameters are required for Http scheduler jobs with Basic authentication type.
\ No newline at end of file
diff --git a/src/ServiceManagement/Services/Commands.Utilities/Scheduler/Model/PSCreateJobParams.cs b/src/ServiceManagement/Services/Commands.Utilities/Scheduler/Model/PSCreateJobParams.cs
index 71e9cf75daa3..b9641b6253e6 100644
--- a/src/ServiceManagement/Services/Commands.Utilities/Scheduler/Model/PSCreateJobParams.cs
+++ b/src/ServiceManagement/Services/Commands.Utilities/Scheduler/Model/PSCreateJobParams.cs
@@ -74,5 +74,17 @@ public class PSCreateJobParams
public string ClientCertPfx { get; set; }
public string ClientCertPassword { get; set; }
+
+ public string Secret { get; set; }
+
+ public string Tenant { get; set; }
+
+ public string Audience { get; set; }
+
+ public string ClientId { get; set; }
+
+ public string Username { get; set; }
+
+ public string Password { get; set; }
}
}
diff --git a/src/ServiceManagement/Services/Commands.Utilities/Scheduler/SchedulerMgmntClient.CreateJobs.cs b/src/ServiceManagement/Services/Commands.Utilities/Scheduler/SchedulerMgmntClient.CreateJobs.cs
index 9fc671dac66a..99d104d97491 100644
--- a/src/ServiceManagement/Services/Commands.Utilities/Scheduler/SchedulerMgmntClient.CreateJobs.cs
+++ b/src/ServiceManagement/Services/Commands.Utilities/Scheduler/SchedulerMgmntClient.CreateJobs.cs
@@ -315,29 +315,19 @@ private JobCreateOrUpdateParameters PopulateExistingJobParams(Job job, PSCreateJ
//Job has existing authentication
if (job.Action.Request.Authentication != null)
{
- if (jobRequest.HttpAuthType.Equals("ClientCertificate", StringComparison.OrdinalIgnoreCase))
+ if (!string.IsNullOrEmpty(jobRequest.HttpAuthType))
{
- jobUpdateParams.Action.Request.Authentication = SetClientCertAuthentication(jobRequest, jobUpdateParams);
- }
- else if (jobRequest.HttpAuthType.Equals("None", StringComparison.OrdinalIgnoreCase))
- {
- if (!string.IsNullOrEmpty(jobRequest.ClientCertPfx) || !string.IsNullOrEmpty(jobRequest.ClientCertPassword))
- {
- throw new InvalidOperationException(Resources.SchedulerInvalidNoneAuthRequest);
- }
- else
- {
- jobUpdateParams.Action.Request.Authentication = null;
- }
+ jobUpdateParams.Action.Request.Authentication = SetHttpAuthentication(jobRequest, jobUpdateParams);
}
+ //the new request doesn't have any changes to auth, so preserve it
else
{
jobUpdateParams.Action.Request.Authentication = job.Action.Request.Authentication;
}
}
- else if (job.Action.Request.Authentication == null && jobRequest.HttpAuthType.Equals("ClientCertificate", StringComparison.OrdinalIgnoreCase))
+ else if (job.Action.Request.Authentication == null)
{
- jobUpdateParams.Action.Request.Authentication = SetClientCertAuthentication(jobRequest, jobUpdateParams);
+ jobUpdateParams.Action.Request.Authentication = SetHttpAuthentication(jobRequest, jobUpdateParams);
}
}
else if (job.Action.Request == null)
@@ -346,10 +336,7 @@ private JobCreateOrUpdateParameters PopulateExistingJobParams(Job job, PSCreateJ
jobUpdateParams.Action.Request.Method = jobRequest.Method;
jobUpdateParams.Action.Request.Headers = jobRequest.Headers.ToDictionary();
jobUpdateParams.Action.Request.Body = jobRequest.Body;
- if (jobRequest.HttpAuthType.Equals("ClientCertificate", StringComparison.OrdinalIgnoreCase))
- {
- jobUpdateParams.Action.Request.Authentication = SetClientCertAuthentication(jobRequest, jobUpdateParams);
- }
+ jobUpdateParams.Action.Request.Authentication = SetHttpAuthentication(jobRequest, jobUpdateParams);
}
}
else
@@ -358,10 +345,7 @@ private JobCreateOrUpdateParameters PopulateExistingJobParams(Job job, PSCreateJ
jobUpdateParams.Action.Request.Method = jobRequest.Method;
jobUpdateParams.Action.Request.Headers = jobRequest.Headers.ToDictionary();
jobUpdateParams.Action.Request.Body = jobRequest.Body;
- if (jobRequest.HttpAuthType.Equals("ClientCertificate", StringComparison.OrdinalIgnoreCase))
- {
- jobUpdateParams.Action.Request.Authentication = SetClientCertAuthentication(jobRequest, jobUpdateParams);
- }
+ jobUpdateParams.Action.Request.Authentication = SetHttpAuthentication(jobRequest, jobUpdateParams);
}
}
else
@@ -460,21 +444,74 @@ private JobCreateOrUpdateParameters PopulateExistingJobParams(Job job, PSCreateJ
return jobUpdateParams;
}
- private HttpAuthentication SetClientCertAuthentication(PSCreateJobParams jobRequest, JobCreateOrUpdateParameters jobUpdateParams)
+ private HttpAuthentication SetHttpAuthentication(PSCreateJobParams jobRequest, JobCreateOrUpdateParameters jobUpdateParams)
{
- if (jobRequest.ClientCertPfx != null && jobRequest.ClientCertPassword != null)
+ HttpAuthentication httpAuthentication = null;
+ if (!string.IsNullOrEmpty(jobRequest.HttpAuthType))
{
- return new ClientCertAuthentication
+ switch (jobRequest.HttpAuthType.ToLower())
{
- Type = HttpAuthenticationType.ClientCertificate,
- Password = jobRequest.ClientCertPassword,
- Pfx = jobRequest.ClientCertPfx
- };
- }
- else
- {
- throw new InvalidOperationException(Resources.SchedulerInvalidClientCertAuthRequest);
+ case "clientcertificate":
+ if (jobRequest.ClientCertPfx != null && jobRequest.ClientCertPassword != null)
+ {
+ httpAuthentication = new ClientCertAuthentication
+ {
+ Type = HttpAuthenticationType.ClientCertificate,
+ Password = jobRequest.ClientCertPassword,
+ Pfx = jobRequest.ClientCertPfx
+ };
+ }
+ else
+ {
+ throw new InvalidOperationException(Resources.SchedulerInvalidClientCertAuthRequest);
+ }
+ break;
+
+ case "activedirectoryoauth":
+ if (jobRequest.Tenant != null && jobRequest.Audience != null && jobRequest.ClientId != null && jobRequest.Secret != null)
+ {
+ httpAuthentication = new AADOAuthAuthentication
+ {
+ Type = HttpAuthenticationType.ActiveDirectoryOAuth,
+ Tenant = jobRequest.Tenant,
+ Audience = jobRequest.Audience,
+ ClientId = jobRequest.ClientId,
+ Secret = jobRequest.Secret
+ };
+ }
+ else
+ {
+ throw new InvalidOperationException(Resources.SchedulerInvalidAADOAuthRequest);
+ }
+ break;
+
+ case "basic":
+ if (jobRequest.Username != null && jobRequest.Password != null)
+ {
+ httpAuthentication = new BasicAuthentication
+ {
+ Type = HttpAuthenticationType.Basic,
+ Username = jobRequest.Username,
+ Password = jobRequest.Password
+ };
+ }
+ else
+ {
+ throw new InvalidOperationException(Resources.SchedulerInvalidBasicAuthRequest);
+ }
+ break;
+
+ case "none":
+ if (!string.IsNullOrEmpty(jobRequest.ClientCertPfx) || !string.IsNullOrEmpty(jobRequest.ClientCertPassword) ||
+ !string.IsNullOrEmpty(jobRequest.Tenant) || !string.IsNullOrEmpty(jobRequest.Secret) || !string.IsNullOrEmpty(jobRequest.ClientId) || !string.IsNullOrEmpty(jobRequest.Audience) ||
+ !string.IsNullOrEmpty(jobRequest.Username) || !string.IsNullOrEmpty(jobRequest.Password))
+ {
+ throw new InvalidOperationException(Resources.SchedulerInvalidNoneAuthRequest);
+ }
+ break;
+ }
}
+ return httpAuthentication;
}
///
diff --git a/src/ServiceManagement/Services/Commands/Scheduler/NewSchedulerHttpJobCommand.cs b/src/ServiceManagement/Services/Commands/Scheduler/NewSchedulerHttpJobCommand.cs
index f785941fdcaa..702d80d3b72a 100644
--- a/src/ServiceManagement/Services/Commands/Scheduler/NewSchedulerHttpJobCommand.cs
+++ b/src/ServiceManagement/Services/Commands/Scheduler/NewSchedulerHttpJobCommand.cs
@@ -120,7 +120,7 @@ public class NewSchedulerHttpJobCommand : SchedulerBaseCmdlet
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = false, ParameterSetName = AuthParamSet, HelpMessage = "The Http Authentication type (None or ClientCertificate).")]
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = false, ParameterSetName = RequiredParamSet, HelpMessage = "The Http Authentication type (None or ClientCertificate).")]
- [ValidateSet("None", "ClientCertificate", IgnoreCase = true)]
+ [ValidateSet("None", "ClientCertificate", "ActiveDirectoryOAuth", "Basic", IgnoreCase = true)]
public string HttpAuthenticationType { get; set; }
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = false, ParameterSetName = AuthParamSet, HelpMessage = "The pfx of client certificate.")]
diff --git a/src/ServiceManagement/Services/Commands/Scheduler/SetSchedulerHttpJobCommand.cs b/src/ServiceManagement/Services/Commands/Scheduler/SetSchedulerHttpJobCommand.cs
index 2fca2bb05dfd..8cc7de51e717 100644
--- a/src/ServiceManagement/Services/Commands/Scheduler/SetSchedulerHttpJobCommand.cs
+++ b/src/ServiceManagement/Services/Commands/Scheduler/SetSchedulerHttpJobCommand.cs
@@ -119,7 +119,7 @@ public class SetSchedulerHttpJobCommand : SchedulerBaseCmdlet
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = false, ParameterSetName = AuthParamSet, HelpMessage = "The Http Authentication type (None or ClientCertificate).")]
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = false, ParameterSetName = RequiredParamSet, HelpMessage = "The Http Authentication type (None or ClientCertificate).")]
- [ValidateSet("None", "ClientCertificate", IgnoreCase = true)]
+ [ValidateSet("None", "ClientCertificate", "ActiveDirectoryOAuth", "Basic", IgnoreCase = true)]
public string HttpAuthenticationType { get; set; }
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = false, ParameterSetName = AuthParamSet, HelpMessage = "The pfx of client certificate.")]