mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
internal identity authorization
This commit is contained in:
@ -311,12 +311,9 @@ namespace Bit.Core.Utilities
|
||||
|
||||
public static bool SettingHasValue(string setting)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(setting) || setting.Equals("SECRET") || setting.Equals("REPLACE"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
var normalizedSetting = setting?.ToLowerInvariant();
|
||||
return !string.IsNullOrWhiteSpace(normalizedSetting) && !normalizedSetting.Equals("secret") &&
|
||||
!normalizedSetting.Equals("replace");
|
||||
}
|
||||
|
||||
public static string Base64UrlEncode(byte[] input)
|
||||
|
@ -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(
|
||||
|
Reference in New Issue
Block a user