mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 01:22:50 -05:00
adjust cors origin checks (#800)
* allow cors from bitwarden.com on cloud * allow file:// cors for safari extension * fix missing paren
This commit is contained in:
@ -595,5 +595,16 @@ namespace Bit.Core.Utilities
|
||||
|
||||
return httpContext.Connection?.RemoteIpAddress?.ToString();
|
||||
}
|
||||
|
||||
public static bool IsCorsOriginAllowed(string origin, GlobalSettings globalSettings)
|
||||
{
|
||||
return
|
||||
// Web vault
|
||||
origin == globalSettings.BaseServiceUri.Vault ||
|
||||
// Safari extension origin
|
||||
origin == "file://" ||
|
||||
// Product website
|
||||
(!globalSettings.SelfHosted && origin == "https://bitwarden.com");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ namespace Bit.Core.Utilities
|
||||
}
|
||||
|
||||
services.AddTransient<ClientStore>();
|
||||
services.AddTransient<ICorsPolicyService, VaultCorsPolicyService>();
|
||||
services.AddTransient<ICorsPolicyService, CustomCorsPolicyService>();
|
||||
services.AddScoped<IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
|
||||
services.AddScoped<IProfileService, ProfileService>();
|
||||
services.AddSingleton<IPersistedGrantStore, PersistedGrantStore>();
|
||||
|
Reference in New Issue
Block a user