mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
added installations, push scoped tokens, push api
This commit is contained in:
26
src/Api/Controllers/PushController.cs
Normal file
26
src/Api/Controllers/PushController.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Bit.Core.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Bit.Api.Controllers
|
||||
{
|
||||
[Route("push")]
|
||||
[Authorize("Push")]
|
||||
public class PushController : Controller
|
||||
{
|
||||
private readonly IPushRegistrationService _pushRegistrationService;
|
||||
|
||||
public PushController(
|
||||
IPushRegistrationService pushRegistrationService)
|
||||
{
|
||||
_pushRegistrationService = pushRegistrationService;
|
||||
}
|
||||
|
||||
[HttpGet("register")]
|
||||
public Object Register()
|
||||
{
|
||||
return new { Foo = "bar" };
|
||||
}
|
||||
}
|
||||
}
|
@ -86,6 +86,11 @@ namespace Bit.Api
|
||||
policy.RequireClaim(JwtClaimTypes.Scope, "api");
|
||||
policy.RequireClaim(JwtClaimTypes.ClientId, "web");
|
||||
});
|
||||
config.AddPolicy("Push", policy =>
|
||||
{
|
||||
policy.RequireAuthenticatedUser();
|
||||
policy.RequireClaim(JwtClaimTypes.Scope, "api.push");
|
||||
});
|
||||
});
|
||||
|
||||
services.AddScoped<AuthenticatorTokenProvider>();
|
||||
@ -179,9 +184,8 @@ namespace Bit.Api
|
||||
var options = new IdentityServerAuthenticationOptions
|
||||
{
|
||||
Authority = globalSettings.BaseServiceUri.InternalIdentity,
|
||||
AllowedScopes = new string[] { "api" },
|
||||
AllowedScopes = new string[] { "api", "api.push" },
|
||||
RequireHttpsMetadata = !env.IsDevelopment() && globalSettings.BaseServiceUri.InternalIdentity.StartsWith("https"),
|
||||
ApiName = "api",
|
||||
NameClaimType = ClaimTypes.Email,
|
||||
// Suffix until we retire the old jwt schemes.
|
||||
AuthenticationScheme = $"Bearer{suffix}",
|
||||
|
Reference in New Issue
Block a user