1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-29 18:07:36 +01:00

deprec. api identity, set base uris from settings

This commit is contained in:
Kyle Spearrin 2017-08-02 16:57:32 -04:00
parent a71f2198e9
commit 897c354577
12 changed files with 27 additions and 29 deletions

View File

@ -66,9 +66,6 @@ namespace Bit.Api
services.AddSingleton<IIpPolicyStore, MemoryCacheIpPolicyStore>();
services.AddSingleton<IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>();
// IdentityServer
services.AddCustomIdentityServerServices(Environment, globalSettings);
// Identity
services.AddCustomIdentityServices(globalSettings);
@ -166,11 +163,8 @@ namespace Bit.Api
app.UseCors("All");
// Add IdentityServer to the request pipeline.
app.UseIdentityServer();
app.UseIdentityServerAuthentication(
GetIdentityOptions(env, IdentityServerAuthority(env, "identity", "33656"), "3"));
app.UseIdentityServerAuthentication(
GetIdentityOptions(env, IdentityServerAuthority(env, "api", "4000"), "2"));
app.UseIdentityServerAuthentication(GetIdentityOptions(env, globalSettings, string.Empty));
app.UseIdentityServerAuthentication(GetIdentityOptions(env, globalSettings, "3"));
// Add current context
app.UseMiddleware<CurrentContextMiddleware>();
@ -180,39 +174,21 @@ namespace Bit.Api
}
private IdentityServerAuthenticationOptions GetIdentityOptions(IHostingEnvironment env,
string authority, string suffix)
GlobalSettings globalSettings, string suffix)
{
var options = new IdentityServerAuthenticationOptions
{
Authority = authority,
Authority = globalSettings.BaseIdentityUri,
AllowedScopes = new string[] { "api" },
RequireHttpsMetadata = !env.IsDevelopment(),
ApiName = "api",
NameClaimType = ClaimTypes.Email,
// Suffix until we retire the old jwt schemes.
AuthenticationScheme = $"Bearer{suffix}",
TokenRetriever = TokenRetrieval.FromAuthorizationHeaderOrQueryString(
$"Bearer{suffix}", $"access_token{suffix}")
TokenRetriever = TokenRetrieval.FromAuthorizationHeaderOrQueryString($"Bearer{suffix}", $"access_token{suffix}")
};
return options;
}
private string IdentityServerAuthority(IHostingEnvironment env, string subdomain, string port)
{
if(env.IsProduction())
{
return $"https://{subdomain}.bitwarden.com";
}
else if(env.IsEnvironment("Preview"))
{
return $"https://preview-{subdomain}.bitwarden.com";
}
else
{
return $"http://localhost:{port}";
//return $"http://192.168.1.3:{port}"; // Desktop external
}
}
}
}

View File

@ -1,6 +1,8 @@
{
"globalSettings": {
"baseVaultUri": "https://preview-vault.bitwarden.com/#",
"baseApiUri": "https://preview-api.bitwarden.com",
"baseIdentityUri": "https://preview-identity.bitwarden.com",
"u2f": {
"appId": "https://preview-vault.bitwarden.com/app-id.json"
}

View File

@ -1,6 +1,8 @@
{
"globalSettings": {
"baseVaultUri": "https://vault.bitwarden.com/#",
"baseApiUri": "https://api.bitwarden.com",
"baseIdentityUri": "https://identity.bitwarden.com",
"u2f": {
"appId": "https://vault.bitwarden.com/app-id.json"
},

View File

@ -1,6 +1,8 @@
{
"globalSettings": {
"baseVaultUri": "https://vault.bitwarden.com/#",
"baseApiUri": "https://api.bitwarden.com",
"baseIdentityUri": "https://identity.bitwarden.com",
"u2f": {
"appId": "https://vault.bitwarden.com/app-id.json"
}

View File

@ -2,6 +2,8 @@
"globalSettings": {
"siteName": "bitwarden",
"baseVaultUri": "http://localhost:4001/#",
"baseApiUri": "http://localhost:4000",
"baseIdentityUri": "http://localhost:33656",
"stripeApiKey": "SECRET",
"sqlServer": {
"connectionString": "SECRET"

View File

@ -1,6 +1,8 @@
{
"globalSettings": {
"baseVaultUri": "https://vault.bitwarden.com/#",
"baseApiUri": "https://api.bitwarden.com",
"baseIdentityUri": "https://identity.bitwarden.com",
"braintree": {
"production": true
}

View File

@ -2,6 +2,8 @@
"globalSettings": {
"siteName": "bitwarden",
"baseVaultUri": "http://localhost:4001/#",
"baseApiUri": "http://localhost:4000",
"baseIdentityUri": "http://localhost:33656",
"stripeApiKey": "SECRET",
"sqlServer": {
"connectionString": "SECRET"

View File

@ -4,6 +4,8 @@
{
public virtual string SiteName { get; set; }
public virtual string BaseVaultUri { get; set; }
public virtual string BaseApiUri { get; set; }
public virtual string BaseIdentityUri { get; set; }
public virtual string StripeApiKey { get; set; }
public virtual SqlServerSettings SqlServer { get; set; } = new SqlServerSettings();
public virtual MailSettings Mail { get; set; } = new MailSettings();

View File

@ -1,6 +1,8 @@
{
"globalSettings": {
"baseVaultUri": "https://preview-vault.bitwarden.com/#",
"baseApiUri": "https://preview-api.bitwarden.com",
"baseIdentityUri": "https://preview-identity.bitwarden.com",
"u2f": {
"appId": "https://preview-vault.bitwarden.com/app-id.json"
}

View File

@ -1,6 +1,8 @@
{
"globalSettings": {
"baseVaultUri": "https://vault.bitwarden.com/#",
"baseApiUri": "https://api.bitwarden.com",
"baseIdentityUri": "https://identity.bitwarden.com",
"u2f": {
"appId": "https://vault.bitwarden.com/app-id.json"
},

View File

@ -1,6 +1,8 @@
{
"globalSettings": {
"baseVaultUri": "https://vault.bitwarden.com/#",
"baseApiUri": "https://api.bitwarden.com",
"baseIdentityUri": "https://identity.bitwarden.com",
"u2f": {
"appId": "https://vault.bitwarden.com/app-id.json"
}

View File

@ -2,6 +2,8 @@
"globalSettings": {
"siteName": "bitwarden",
"baseVaultUri": "http://localhost:4001/#",
"baseApiUri": "http://localhost:4000",
"baseIdentityUri": "http://localhost:33656",
"stripeApiKey": "SECRET",
"sqlServer": {
"connectionString": "SECRET"