1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-15 15:53:41 +00:00

custom api endpoints via settings

This commit is contained in:
Kyle Spearrin
2017-05-12 14:04:56 -04:00
parent 44563451f2
commit fa0049df3c
3 changed files with 41 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ namespace Bit.Core.Models
{ "username", Email }, { "username", Email },
{ "password", MasterPasswordHash }, { "password", MasterPasswordHash },
{ "scope", "api offline_access" }, { "scope", "api offline_access" },
{ "client_id", "mobile" } { "client_id", "connector" }
}; };
if(Token != null && Provider.HasValue) if(Token != null && Provider.HasValue)

View File

@@ -16,10 +16,20 @@ namespace Bit.Core.Services
private ApiService() private ApiService()
{ {
ApiClient = new HttpClient(); ApiClient = new HttpClient();
ApiClient.BaseAddress = new Uri("https://api.bitwarden.com"); var apiUrl = "https://api.bitwarden.com";
if(!string.IsNullOrWhiteSpace(SettingsService.Instance.ApiBaseUrl))
{
apiUrl = SettingsService.Instance.ApiBaseUrl;
}
ApiClient.BaseAddress = new Uri(apiUrl);
IdentityClient = new HttpClient(); IdentityClient = new HttpClient();
IdentityClient.BaseAddress = new Uri("https://identity.bitwarden.com"); var identityUrl = "https://identity.bitwarden.com";
if(!string.IsNullOrWhiteSpace(SettingsService.Instance.IdentityBaseUrl))
{
identityUrl = SettingsService.Instance.IdentityBaseUrl;
}
IdentityClient.BaseAddress = new Uri(identityUrl);
} }
public static ApiService Instance public static ApiService Instance

View File

@@ -75,6 +75,32 @@ namespace Bit.Core.Services
} }
} }
public string ApiBaseUrl
{
get
{
return Settings.ApiBaseUrl;
}
set
{
Settings.ApiBaseUrl = value;
SaveSettings();
}
}
public string IdentityBaseUrl
{
get
{
return Settings.IdentityBaseUrl;
}
set
{
Settings.IdentityBaseUrl = value;
SaveSettings();
}
}
public EncryptedData AccessToken public EncryptedData AccessToken
{ {
get get
@@ -116,6 +142,8 @@ namespace Bit.Core.Services
public class SettingsModel public class SettingsModel
{ {
public string ApiBaseUrl { get; set; }
public string IdentityBaseUrl { get; set; }
public EncryptedData AccessToken { get; set; } public EncryptedData AccessToken { get; set; }
public EncryptedData RefreshToken { get; set; } public EncryptedData RefreshToken { get; set; }
public ServerConfiguration Server { get; set; } public ServerConfiguration Server { get; set; }