mirror of
https://github.com/bitwarden/server
synced 2025-12-20 18:23:44 +00:00
[PM-20595] Add Policy for Send access (#6282)
* feat: add policy to API startup and Policies class to hold the static strings * test: add snapshot testing for constants to help with rust mappings * doc: add docs for send access
This commit is contained in:
@@ -33,6 +33,7 @@ using Bit.Core.Auth.Models.Api.Request;
|
||||
using Bit.Core.Dirt.Reports.ReportFeatures;
|
||||
using Bit.Core.Tools.SendFeatures;
|
||||
using Bit.Core.Auth.IdentityServer;
|
||||
using Bit.Core.Auth.Identity;
|
||||
|
||||
|
||||
#if !OSS
|
||||
@@ -145,6 +146,12 @@ public class Startup
|
||||
(c.Value.Contains(ApiScopes.Api) || c.Value.Contains(ApiScopes.ApiSecrets))
|
||||
));
|
||||
});
|
||||
config.AddPolicy(Policies.Send, configurePolicy: policy =>
|
||||
{
|
||||
policy.RequireAuthenticatedUser();
|
||||
policy.RequireClaim(JwtClaimTypes.Scope, ApiScopes.ApiSendAccess);
|
||||
policy.RequireClaim(Claims.SendAccessClaims.SendId);
|
||||
});
|
||||
});
|
||||
|
||||
services.AddScoped<AuthenticatorTokenProvider>();
|
||||
|
||||
Reference in New Issue
Block a user