Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
louisfischer committed Dec 6, 2017
2 parents d346ab8 + f8b08f2 commit 7a8f2f4
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 13 deletions.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,28 @@ This Addin only contains the functionality needed to upload the most common obje
SsrsCreateFolder("AdventureWorks", "/", new SsrsConnectionSettings
{
ServiceEndpoint = "http://localhost/reportserver/ReportService2010.asmx",
UseDefaultCredentials = true
UseDefaultCredentials = true,
ProxyCredentialType = ProxyCredentialType.Ntlm,
ImperonsationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation,
SecurityMode = SecurityMode.TransportCredentialOnly
});
```

### Upload a Report

```csharp
SsrsUploadReport("./path/to/report.rdl", "/AdventureWorks",
new Dictionary<string, string>
new Dictionary<string, string>
{
["Description"] = "Description for the Report"
},
new SsrsConnectionSettings
{
ServiceEndpoint = "http://localhost/reportserver/ReportService2010.asmx",
UseDefaultCredentials = true
UseDefaultCredentials = true,
ProxyCredentialType = ProxyCredentialType.Ntlm,
ImperonsationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation,
SecurityMode = SecurityMode.TransportCredentialOnly
});
```

Expand All @@ -71,7 +77,11 @@ SsrsUploadReport("./path/to/dataset.rsd", "/AdventureWorks",
new SsrsConnectionSettings
{
ServiceEndpoint = "http://localhost/reportserver/ReportService2010.asmx",
UseDefaultCredentials = true
UseDefaultCredentials = true,
ProxyCredentialType = ProxyCredentialType.Ntlm,
ImperonsationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation,
SecurityMode = SecurityMode.TransportCredentialOnly

});
```

Expand All @@ -86,7 +96,10 @@ SsrsUploadDataSource("./path/to/datasource.rds", "/AdventureWorks",
new SsrsConnectionSettings
{
ServiceEndpoint = "http://localhost/reportserver/ReportService2010.asmx",
UseDefaultCredentials = true
UseDefaultCredentials = true,
ProxyCredentialType = ProxyCredentialType.Ntlm,
ImperonsationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation,
SecurityMode = SecurityMode.TransportCredentialOnly
});
```

Expand All @@ -103,6 +116,9 @@ var catalogItem = SsrsFindItem (
new SsrsConnectionSettings
{
ServiceEndpoint = "http://localhost/reportserver/ReportService2010.asmx",
UseDefaultCredentials = true
UseDefaultCredentials = true,
ProxyCredentialType = ProxyCredentialType.Ntlm,
ImperonsationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation,
SecurityMode = SecurityMode.TransportCredentialOnly
});
```
29 changes: 25 additions & 4 deletions src/Cake.SSRS/Aliases/SsrsAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ private static ReportingService GetReportingService(ICakeContext context, SsrsCo
var url = new Uri(settings.ServiceEndpoint);

var clientAuthType = GetClientCredential(settings.ClientCredentialType);
var proxyClientType = GetProxyCredentialType(settings.ProxyCredentialType);

HttpBindingBase binding = null;

Expand All @@ -968,6 +969,7 @@ private static ReportingService GetReportingService(ICakeContext context, SsrsCo

httpBinding.Security.Mode = basicSecurityMode;
httpBinding.Security.Transport.ClientCredentialType = clientAuthType;
httpBinding.Security.Transport.ProxyCredentialType = proxyClientType;

binding = httpBinding;
}
Expand All @@ -989,6 +991,7 @@ private static ReportingService GetReportingService(ICakeContext context, SsrsCo

httpsBinding.Security.Mode = BasicHttpsSecurityMode.Transport;
httpsBinding.Security.Transport.ClientCredentialType = clientAuthType;
httpsBinding.Security.Transport.ProxyCredentialType = proxyClientType;

binding = httpsBinding;
}
Expand All @@ -998,11 +1001,12 @@ private static ReportingService GetReportingService(ICakeContext context, SsrsCo
switch (clientAuthType)
{
case HttpClientCredentialType.Basic:
client.ClientCredentials.UserName.UserName = settings.Username;
client.ClientCredentials.UserName.UserName = !string.IsNullOrWhiteSpace(settings.Domain) ? $@"{settings.Domain}\{settings.Username}" : settings.Username;
client.ClientCredentials.UserName.Password = settings.Password;
break;
case HttpClientCredentialType.Ntlm:
case HttpClientCredentialType.Windows:
client.ClientCredentials.Windows.AllowedImpersonationLevel = settings.ImperonsationLevel;
client.ClientCredentials.Windows.ClientCredential = settings.UseDefaultCredentials ?
client.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials
: new System.Net.NetworkCredential(settings.Username, settings.Password, settings.Password);
Expand All @@ -1022,12 +1026,11 @@ private static void VerifyParameters(ICakeContext context, SsrsConnectionSetting
}

private static HttpClientCredentialType GetClientCredential(ClientCredentialType clientCredentialType)
{
{
switch (clientCredentialType)
{
case ClientCredentialType.Basic:
return HttpClientCredentialType.Basic;
break;
case ClientCredentialType.Ntlm:
return HttpClientCredentialType.Ntlm;
case ClientCredentialType.Windows:
Expand All @@ -1041,13 +1044,31 @@ private static BasicHttpSecurityMode GetHttpSecurityMode(SecurityMode securityMo
{
switch (securityMode)
{
case SecurityMode.Tranport:
case SecurityMode.Transport:
return BasicHttpSecurityMode.Transport;
case SecurityMode.TransportCredentialOnly:
return BasicHttpSecurityMode.TransportCredentialOnly;
case SecurityMode.TransportWithMessageCredential:
return BasicHttpSecurityMode.TransportWithMessageCredential;
default:
return BasicHttpSecurityMode.None;
}
}

private static HttpProxyCredentialType GetProxyCredentialType(ProxyCredentialType proxyCredentialType)
{
switch (proxyCredentialType)
{
case ProxyCredentialType.Basic:
return HttpProxyCredentialType.Basic;
case ProxyCredentialType.Ntlm:
return HttpProxyCredentialType.Ntlm;
case ProxyCredentialType.Windows:
return HttpProxyCredentialType.Windows;
case ProxyCredentialType.None:
default:
return HttpProxyCredentialType.None;
}
}
}
}
15 changes: 15 additions & 0 deletions src/Cake.SSRS/Runner/ProxyCredentialType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Cake.SSRS
{
public enum ProxyCredentialType
{
None = 0,
Basic = 1,
Digest = 2,
Ntlm = 3,
Windows = 4
}
}
9 changes: 6 additions & 3 deletions src/Cake.SSRS/Runner/SecurityMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ public enum SecurityMode
/// <summary>
/// SSL Certicate Htpp Authenication
/// </summary>
Tranport,
Transport,
/// <summary>
/// Provider only HTTP Authentication
/// </summary>
TransportCredentialOnly

TransportCredentialOnly,
/// <summary>
///
/// </summary>
TransportWithMessageCredential
}
}
10 changes: 10 additions & 0 deletions src/Cake.SSRS/Runner/SsrsConnectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,15 @@ public class SsrsConnectionSettings
/// Security Mode. Used only for Http only security.
/// </summary>
public SecurityMode SecurityMode { get; set; }

/// <summary>
/// Defines security impersonation levels. Security impersonation levels govern the degree to which a server process can act on behalf of a client process.
/// </summary>
public System.Security.Principal.TokenImpersonationLevel ImperonsationLevel { get; set; }

/// <summary>
/// Proxy Client Type
/// </summary>
public ProxyCredentialType ProxyCredentialType { get; set; }
}
}

0 comments on commit 7a8f2f4

Please sign in to comment.