1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 09:02:48 -05:00

internal identity authorization

This commit is contained in:
Kyle Spearrin
2018-08-15 18:43:26 -04:00
parent 25899fd326
commit ff01ce5ca7
11 changed files with 119 additions and 56 deletions

View File

@ -234,7 +234,7 @@ namespace Bit.Core.Utilities
public static void AddIdentityAuthenticationServices(
this IServiceCollection services, GlobalSettings globalSettings, IHostingEnvironment environment,
Action<AuthorizationOptions> addAuthorization = null)
Action<AuthorizationOptions> addAuthorization)
{
services
.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
@ -248,21 +248,13 @@ namespace Bit.Core.Utilities
options.SupportedTokens = SupportedTokens.Jwt;
});
services.AddAuthorization(config =>
if(addAuthorization != null)
{
if(addAuthorization != null)
services.AddAuthorization(config =>
{
addAuthorization?.Invoke(config);
}
else
{
config.AddPolicy("Application", policy =>
{
policy.RequireAuthenticatedUser();
policy.RequireClaim(JwtClaimTypes.AuthenticationMethod, "Application");
});
}
});
addAuthorization.Invoke(config);
});
}
}
public static IIdentityServerBuilder AddCustomIdentityServerServices(