mirror of
https://github.com/bitwarden/server.git
synced 2025-01-23 22:01:28 +01:00
config updates for identity startup
This commit is contained in:
parent
a9b0748d07
commit
d87441c9fe
@ -275,18 +275,7 @@ namespace Bit.Api
|
|||||||
|
|
||||||
// Add IdentityServer to the request pipeline.
|
// Add IdentityServer to the request pipeline.
|
||||||
app.UseIdentityServer();
|
app.UseIdentityServer();
|
||||||
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
|
app.UseIdentityServerAuthentication(GetIdentityOptions(env));
|
||||||
{
|
|
||||||
AllowedScopes = new string[] { "api" },
|
|
||||||
Authority = env.IsProduction() ? "https://api.bitwarden.com" : env.IsEnvironment("Preview") ?
|
|
||||||
"https://preview-api.bitwarden.com" : "http://localhost:4000",
|
|
||||||
RequireHttpsMetadata = env.IsProduction(),
|
|
||||||
ApiName = "api",
|
|
||||||
NameClaimType = ClaimTypes.Email,
|
|
||||||
// Version "2" until we retire the old jwt scheme and replace it with this one.
|
|
||||||
AuthenticationScheme = "Bearer2",
|
|
||||||
TokenRetriever = TokenRetrieval.FromAuthorizationHeaderOrQueryString("Bearer2", "access_token2")
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add Jwt authentication to the request pipeline.
|
// Add Jwt authentication to the request pipeline.
|
||||||
app.UseJwtBearerIdentity();
|
app.UseJwtBearerIdentity();
|
||||||
@ -297,5 +286,35 @@ namespace Bit.Api
|
|||||||
// Add MVC to the request pipeline.
|
// Add MVC to the request pipeline.
|
||||||
app.UseMvc();
|
app.UseMvc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IdentityServerAuthenticationOptions GetIdentityOptions(IHostingEnvironment env)
|
||||||
|
{
|
||||||
|
var options = new IdentityServerAuthenticationOptions
|
||||||
|
{
|
||||||
|
AllowedScopes = new string[] { "api" },
|
||||||
|
RequireHttpsMetadata = env.IsProduction(),
|
||||||
|
ApiName = "api",
|
||||||
|
NameClaimType = ClaimTypes.Email,
|
||||||
|
// Version "2" until we retire the old jwt scheme and replace it with this one.
|
||||||
|
AuthenticationScheme = "Bearer2",
|
||||||
|
TokenRetriever = TokenRetrieval.FromAuthorizationHeaderOrQueryString("Bearer2", "access_token2")
|
||||||
|
};
|
||||||
|
|
||||||
|
if(env.IsProduction())
|
||||||
|
{
|
||||||
|
options.Authority = "https://api.bitwarden.com";
|
||||||
|
}
|
||||||
|
else if(env.IsEnvironment("Preview"))
|
||||||
|
{
|
||||||
|
options.Authority = "https://preview-api.bitwarden.com";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options.Authority = "http://localhost:4000";
|
||||||
|
//options.Authority = "http://169.254.80.80:4000"; // for VS Android Emulator
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user