diff --git a/example/SignalCopy/Program.cs b/example/SignalCopy/Program.cs index f77c169..b831266 100644 --- a/example/SignalCopy/Program.cs +++ b/example/SignalCopy/Program.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using DocoptNet; using Seq.Api; -using System.Linq; using Seq.Api.Model.Signals; using System.Collections.Generic; diff --git a/example/SignalCopy/Properties/launchSettings.json b/example/SignalCopy/Properties/launchSettings.json index f57dda9..16428f3 100644 --- a/example/SignalCopy/Properties/launchSettings.json +++ b/example/SignalCopy/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "SignalCopy": { "commandName": "Project", - "commandLineArgs": "http://localhost:5341 http://localhost:5342 --srckey=fSCcBOyOfttZ0kiZFgq" + "commandLineArgs": "http://localhost:5341 http://localhost:5342" } } } \ No newline at end of file diff --git a/src/Seq.Api/Api/Client/SeqApiClient.cs b/src/Seq.Api/Api/Client/SeqApiClient.cs index 30df9b7..82654bb 100644 --- a/src/Seq.Api/Api/Client/SeqApiClient.cs +++ b/src/Seq.Api/Api/Client/SeqApiClient.cs @@ -45,7 +45,7 @@ public SeqApiClient(string serverUrl, string apiKey = null) if (!string.IsNullOrEmpty(apiKey)) _apiKey = apiKey; - var handler = new HttpClientHandler { CookieContainer = _cookies }; + var handler = new HttpClientHandler { CookieContainer = _cookies, UseDefaultCredentials = true }; var baseAddress = serverUrl; if (!baseAddress.EndsWith("/")) @@ -56,6 +56,8 @@ public SeqApiClient(string serverUrl, string apiKey = null) public string ServerUrl { get; } + public HttpClient HttpClient => _httpClient; + public Task GetRootAsync() { return HttpGetAsync("api"); diff --git a/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs b/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs index d01e712..5a3264b 100644 --- a/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs +++ b/src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Threading.Tasks; using Seq.Api.Model.Users; +using System.Linq; +using Seq.Api.Client; namespace Seq.Api.ResourceGroups { @@ -65,5 +67,16 @@ public async Task GetSearchHistoryAsync(UserEntity entity) { return await Client.GetAsync(entity, "SearchHistory").ConfigureAwait(false); } + + public async Task LoginWindowsIntegratedAsync() + { + var providers = await GroupGetAsync("AuthenticationProviders"); + var provider = providers.Providers.SingleOrDefault(p => p.Name == "Integrated Windows Authentication"); + if (provider == null) + throw new SeqApiException("The Integrated Windows Authentication provider is not available."); + var response = await Client.HttpClient.GetAsync(provider.Url); + response.EnsureSuccessStatusCode(); + return await FindCurrentAsync(); + } } }