Skip to content

Commit

Permalink
Add LoginWindowsIntegratedAsync() to the Users resource
Browse files Browse the repository at this point in the history
  • Loading branch information
nblumhardt committed Jan 23, 2017
1 parent edfaf98 commit ac35557
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 0 additions & 1 deletion example/SignalCopy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion example/SignalCopy/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"SignalCopy": {
"commandName": "Project",
"commandLineArgs": "http://localhost:5341 http://localhost:5342 --srckey=fSCcBOyOfttZ0kiZFgq"
"commandLineArgs": "http://localhost:5341 http://localhost:5342"
}
}
}
4 changes: 3 additions & 1 deletion src/Seq.Api/Api/Client/SeqApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("/"))
Expand All @@ -56,6 +56,8 @@ public SeqApiClient(string serverUrl, string apiKey = null)

public string ServerUrl { get; }

public HttpClient HttpClient => _httpClient;

public Task<RootEntity> GetRootAsync()
{
return HttpGetAsync<RootEntity>("api");
Expand Down
13 changes: 13 additions & 0 deletions src/Seq.Api/Api/ResourceGroups/UsersResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -65,5 +67,16 @@ public async Task<SearchHistoryEntity> GetSearchHistoryAsync(UserEntity entity)
{
return await Client.GetAsync<SearchHistoryEntity>(entity, "SearchHistory").ConfigureAwait(false);
}

public async Task<UserEntity> LoginWindowsIntegratedAsync()
{
var providers = await GroupGetAsync<AuthProvidersPart>("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();
}
}
}

0 comments on commit ac35557

Please sign in to comment.