1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-23 22:01:28 +01:00

[SM-82] Add HttpController Attribute to protect secrets manager controllers during development (#2117)

* Adding development only attribute for sm API

* dotnet format changes

* Swapping attribute name to SecretsManager
This commit is contained in:
Thomas Avery 2022-07-18 09:05:26 -05:00 committed by GitHub
parent be146a8f62
commit 8c0996efec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Bit.Api.Utilities
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class SecretsManagerAttribute : Attribute, IResourceFilter
{
public void OnResourceExecuting(ResourceExecutingContext context)
{
var env = context.HttpContext.RequestServices.GetService<IHostEnvironment>();
if (!env.IsDevelopment())
{
context.Result = new NotFoundResult();
}
}
public void OnResourceExecuted(ResourceExecutedContext context) { }
}
}