mirror of
https://github.com/bitwarden/server.git
synced 2025-04-07 22:18:17 -05:00
adjust fido content type with middleware
This commit is contained in:
parent
ca979e0c40
commit
c069fad4e7
@ -136,7 +136,7 @@ namespace Bit.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("~/app-id.json")]
|
[HttpGet("~/app-id.json")]
|
||||||
//[Produces("application/fido.trusted-apps+json")]
|
[Produces("application/fido.trusted-apps+json")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public string GetU2fAppId()
|
public string GetU2fAppId()
|
||||||
{
|
{
|
||||||
@ -149,7 +149,7 @@ namespace Bit.Api.Controllers
|
|||||||
version = new
|
version = new
|
||||||
{
|
{
|
||||||
major = 1,
|
major = 1,
|
||||||
minor = 1
|
minor = 0
|
||||||
},
|
},
|
||||||
ids = new string[]
|
ids = new string[]
|
||||||
{
|
{
|
||||||
|
38
src/Api/Middleware/AdjustHeadersMiddleware.cs
Normal file
38
src/Api/Middleware/AdjustHeadersMiddleware.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using Bit.Core;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Bit.Api.Middleware
|
||||||
|
{
|
||||||
|
public class AdjustHeadersMiddleware
|
||||||
|
{
|
||||||
|
private readonly RequestDelegate _next;
|
||||||
|
|
||||||
|
public AdjustHeadersMiddleware(RequestDelegate next)
|
||||||
|
{
|
||||||
|
_next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Invoke(HttpContext httpContext, CurrentContext currentContext)
|
||||||
|
{
|
||||||
|
httpContext.Response.OnStarting((state) =>
|
||||||
|
{
|
||||||
|
if(httpContext.Response.Headers.Count > 0 && httpContext.Response.Headers.ContainsKey("Content-Type"))
|
||||||
|
{
|
||||||
|
var contentType = httpContext.Response.Headers["Content-Type"].ToString();
|
||||||
|
if(contentType.StartsWith("application/fido.trusted-apps+json"))
|
||||||
|
{
|
||||||
|
httpContext.Response.Headers.Remove("Content-Type");
|
||||||
|
httpContext.Response.Headers.Append("Content-Type", "application/fido.trusted-apps+json");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.FromResult(0);
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
|
||||||
|
await _next.Invoke(httpContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -141,6 +141,8 @@ namespace Bit.Api
|
|||||||
})
|
})
|
||||||
.AddDebug();
|
.AddDebug();
|
||||||
|
|
||||||
|
app.UseMiddleware<AdjustHeadersMiddleware>();
|
||||||
|
|
||||||
// Rate limiting
|
// Rate limiting
|
||||||
app.UseMiddleware<CustomIpRateLimitMiddleware>();
|
app.UseMiddleware<CustomIpRateLimitMiddleware>();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user