1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-04 12:40:22 -05:00

Run dotnet format (#1764)

This commit is contained in:
Oscar Hinton 2021-12-16 15:35:09 +01:00 committed by GitHub
parent 61dc65aa59
commit 23b0a1f9df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
531 changed files with 3024 additions and 3000 deletions

1
.gitattributes vendored
View File

@ -1,3 +1,4 @@
*.sh eol=lf *.sh eol=lf
*.cs eol=lf
.dockerignore eol=lf .dockerignore eol=lf
dockerfile eol=lf dockerfile eol=lf

View File

@ -72,9 +72,9 @@ jobs:
run: dotnet tool restore run: dotnet tool restore
shell: pwsh shell: pwsh
# - name: Verify Format - name: Verify Format
# run: dotnet tool run dotnet-format --check run: dotnet tool run dotnet-format --check
# shell: pwsh shell: pwsh
- name: Test OSS solution - name: Test OSS solution
run: dotnet test ./test --configuration Debug --no-build run: dotnet test ./test --configuration Debug --no-build

View File

@ -1,8 +1,18 @@
using Bit.Core; using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Models;
using Bit.Core.Models.Api;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Sso.Models; using Bit.Sso.Models;
using Bit.Sso.Utilities; using Bit.Sso.Utilities;
using IdentityModel; using IdentityModel;
@ -11,20 +21,10 @@ using IdentityServer4.Extensions;
using IdentityServer4.Services; using IdentityServer4.Services;
using IdentityServer4.Stores; using IdentityServer4.Stores;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Bit.Core.Models;
using Bit.Core.Models.Api;
using Bit.Core.Utilities;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
namespace Bit.Sso.Controllers namespace Bit.Sso.Controllers
{ {

View File

@ -1,11 +1,11 @@
using System; using System;
using Microsoft.AspNetCore.Mvc; using System.Diagnostics;
using Microsoft.AspNetCore.Authorization;
using IdentityServer4.Services;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Sso.Models; using Bit.Sso.Models;
using System.Diagnostics; using IdentityServer4.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Sso.Controllers namespace Bit.Sso.Controllers
{ {

View File

@ -1,6 +1,6 @@
using System; using System;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Sso.Controllers namespace Bit.Sso.Controllers
{ {

View File

@ -9,8 +9,8 @@ using Bit.Core.Enums;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using Bit.Core.Utilities;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Sso.Models; using Bit.Sso.Models;
using Bit.Sso.Utilities; using Bit.Sso.Utilities;
using IdentityModel; using IdentityModel;

View File

@ -1,6 +1,6 @@
using Microsoft.Extensions.Options; using System;
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using Microsoft.Extensions.Options;
namespace Bit.Sso.Utilities namespace Bit.Sso.Utilities
{ {

View File

@ -2,8 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using Bit.Core.Business.Sso; using Bit.Core.Business.Sso;
using Bit.Core.IdentityServer; using Bit.Core.IdentityServer;
using Bit.Core.Utilities;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Sso.Models; using Bit.Sso.Models;
using IdentityServer4.Models; using IdentityServer4.Models;
using IdentityServer4.ResponseHandling; using IdentityServer4.ResponseHandling;

View File

@ -2,8 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.CommCore.Test.AutoFixture.ProviderUserFixtures;
using Bit.CommCore.Services; using Bit.CommCore.Services;
using Bit.CommCore.Test.AutoFixture.ProviderUserFixtures;
using Bit.Core.Context;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Enums.Provider; using Bit.Core.Enums.Provider;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
@ -14,14 +15,13 @@ using Bit.Core.Models.Table.Provider;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using NSubstitute; using NSubstitute;
using NSubstitute.ReturnsExtensions; using NSubstitute.ReturnsExtensions;
using Xunit; using Xunit;
using ProviderUser = Bit.Core.Models.Table.Provider.ProviderUser; using ProviderUser = Bit.Core.Models.Table.Provider.ProviderUser;
using Bit.Core.Context;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
namespace Bit.CommCore.Test.Services namespace Bit.CommCore.Test.Services
{ {
@ -69,7 +69,7 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task CompleteSetupAsync_Success(User user, Provider provider, string key, public async Task CompleteSetupAsync_Success(User user, Provider provider, string key,
[ProviderUser(ProviderUserStatusType.Confirmed, ProviderUserType.ProviderAdmin)]ProviderUser providerUser, [ProviderUser(ProviderUserStatusType.Confirmed, ProviderUserType.ProviderAdmin)] ProviderUser providerUser,
SutProvider<ProviderService> sutProvider) SutProvider<ProviderService> sutProvider)
{ {
providerUser.ProviderId = provider.Id; providerUser.ProviderId = provider.Id;
@ -178,13 +178,13 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task ResendInvitesAsync_Errors(Provider provider, public async Task ResendInvitesAsync_Errors(Provider provider,
[ProviderUser(ProviderUserStatusType.Invited)]ProviderUser pu1, [ProviderUser(ProviderUserStatusType.Invited)] ProviderUser pu1,
[ProviderUser(ProviderUserStatusType.Accepted)]ProviderUser pu2, [ProviderUser(ProviderUserStatusType.Accepted)] ProviderUser pu2,
[ProviderUser(ProviderUserStatusType.Confirmed)]ProviderUser pu3, [ProviderUser(ProviderUserStatusType.Confirmed)] ProviderUser pu3,
[ProviderUser(ProviderUserStatusType.Invited)]ProviderUser pu4, [ProviderUser(ProviderUserStatusType.Invited)] ProviderUser pu4,
SutProvider<ProviderService> sutProvider) SutProvider<ProviderService> sutProvider)
{ {
var providerUsers = new[] {pu1, pu2, pu3, pu4}; var providerUsers = new[] { pu1, pu2, pu3, pu4 };
pu1.ProviderId = pu2.ProviderId = pu3.ProviderId = provider.Id; pu1.ProviderId = pu2.ProviderId = pu3.ProviderId = provider.Id;
var invite = new ProviderUserInvite<Guid> var invite = new ProviderUserInvite<Guid>
@ -243,7 +243,7 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task AcceptUserAsync_AlreadyAccepted_Throws( public async Task AcceptUserAsync_AlreadyAccepted_Throws(
[ProviderUser(ProviderUserStatusType.Accepted)]ProviderUser providerUser, User user, [ProviderUser(ProviderUserStatusType.Accepted)] ProviderUser providerUser, User user,
SutProvider<ProviderService> sutProvider) SutProvider<ProviderService> sutProvider)
{ {
var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>(); var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>();
@ -256,7 +256,7 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task AcceptUserAsync_TokenIsInvalid_Throws( public async Task AcceptUserAsync_TokenIsInvalid_Throws(
[ProviderUser(ProviderUserStatusType.Invited)]ProviderUser providerUser, User user, [ProviderUser(ProviderUserStatusType.Invited)] ProviderUser providerUser, User user,
SutProvider<ProviderService> sutProvider) SutProvider<ProviderService> sutProvider)
{ {
var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>(); var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>();
@ -269,7 +269,7 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task AcceptUserAsync_WrongEmail_Throws( public async Task AcceptUserAsync_WrongEmail_Throws(
[ProviderUser(ProviderUserStatusType.Invited)]ProviderUser providerUser, User user, [ProviderUser(ProviderUserStatusType.Invited)] ProviderUser providerUser, User user,
SutProvider<ProviderService> sutProvider) SutProvider<ProviderService> sutProvider)
{ {
var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>(); var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>();
@ -290,7 +290,7 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task AcceptUserAsync_Success( public async Task AcceptUserAsync_Success(
[ProviderUser(ProviderUserStatusType.Invited)]ProviderUser providerUser, User user, [ProviderUser(ProviderUserStatusType.Invited)] ProviderUser providerUser, User user,
SutProvider<ProviderService> sutProvider) SutProvider<ProviderService> sutProvider)
{ {
var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>(); var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>();
@ -313,13 +313,13 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task ConfirmUsersAsync_NoValid( public async Task ConfirmUsersAsync_NoValid(
[ProviderUser(ProviderUserStatusType.Invited)]ProviderUser pu1, [ProviderUser(ProviderUserStatusType.Invited)] ProviderUser pu1,
[ProviderUser(ProviderUserStatusType.Accepted)]ProviderUser pu2, [ProviderUser(ProviderUserStatusType.Accepted)] ProviderUser pu2,
[ProviderUser(ProviderUserStatusType.Confirmed)]ProviderUser pu3, [ProviderUser(ProviderUserStatusType.Confirmed)] ProviderUser pu3,
SutProvider<ProviderService> sutProvider) SutProvider<ProviderService> sutProvider)
{ {
pu1.ProviderId = pu3.ProviderId; pu1.ProviderId = pu3.ProviderId;
var providerUsers = new[] {pu1, pu2, pu3}; var providerUsers = new[] { pu1, pu2, pu3 };
var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>(); var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>();
providerUserRepository.GetManyAsync(default).ReturnsForAnyArgs(providerUsers); providerUserRepository.GetManyAsync(default).ReturnsForAnyArgs(providerUsers);
@ -331,23 +331,23 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task ConfirmUsersAsync_Success( public async Task ConfirmUsersAsync_Success(
[ProviderUser(ProviderUserStatusType.Invited)]ProviderUser pu1, User u1, [ProviderUser(ProviderUserStatusType.Invited)] ProviderUser pu1, User u1,
[ProviderUser(ProviderUserStatusType.Accepted)]ProviderUser pu2, User u2, [ProviderUser(ProviderUserStatusType.Accepted)] ProviderUser pu2, User u2,
[ProviderUser(ProviderUserStatusType.Confirmed)]ProviderUser pu3, User u3, [ProviderUser(ProviderUserStatusType.Confirmed)] ProviderUser pu3, User u3,
Provider provider, User user, SutProvider<ProviderService> sutProvider) Provider provider, User user, SutProvider<ProviderService> sutProvider)
{ {
pu1.ProviderId = pu2.ProviderId = pu3.ProviderId = provider.Id; pu1.ProviderId = pu2.ProviderId = pu3.ProviderId = provider.Id;
pu1.UserId = u1.Id; pu1.UserId = u1.Id;
pu2.UserId = u2.Id; pu2.UserId = u2.Id;
pu3.UserId = u3.Id; pu3.UserId = u3.Id;
var providerUsers = new[] {pu1, pu2, pu3}; var providerUsers = new[] { pu1, pu2, pu3 };
var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>(); var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>();
providerUserRepository.GetManyAsync(default).ReturnsForAnyArgs(providerUsers); providerUserRepository.GetManyAsync(default).ReturnsForAnyArgs(providerUsers);
var providerRepository = sutProvider.GetDependency<IProviderRepository>(); var providerRepository = sutProvider.GetDependency<IProviderRepository>();
providerRepository.GetByIdAsync(provider.Id).Returns(provider); providerRepository.GetByIdAsync(provider.Id).Returns(provider);
var userRepository = sutProvider.GetDependency<IUserRepository>(); var userRepository = sutProvider.GetDependency<IUserRepository>();
userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] {u1, u2, u3}); userRepository.GetManyAsync(default).ReturnsForAnyArgs(new[] { u1, u2, u3 });
var dict = providerUsers.ToDictionary(pu => pu.Id, _ => "key"); var dict = providerUsers.ToDictionary(pu => pu.Id, _ => "key");
var result = await sutProvider.Sut.ConfirmUsersAsync(pu1.ProviderId, dict, user.Id); var result = await sutProvider.Sut.ConfirmUsersAsync(pu1.ProviderId, dict, user.Id);
@ -369,7 +369,7 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task SaveUserAsync_Success( public async Task SaveUserAsync_Success(
[ProviderUser(type: ProviderUserType.ProviderAdmin)]ProviderUser providerUser, User savingUser, [ProviderUser(type: ProviderUserType.ProviderAdmin)] ProviderUser providerUser, User savingUser,
SutProvider<ProviderService> sutProvider) SutProvider<ProviderService> sutProvider)
{ {
var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>(); var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>();
@ -397,7 +397,7 @@ namespace Bit.CommCore.Test.Services
sutProvider.GetDependency<IProviderRepository>().GetByIdAsync(provider.Id).Returns(provider); sutProvider.GetDependency<IProviderRepository>().GetByIdAsync(provider.Id).Returns(provider);
var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>(); var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>();
providerUserRepository.GetManyAsync(default).ReturnsForAnyArgs(providerUsers); providerUserRepository.GetManyAsync(default).ReturnsForAnyArgs(providerUsers);
providerUserRepository.GetManyByProviderAsync(default, default).ReturnsForAnyArgs(new ProviderUser[] {}); providerUserRepository.GetManyByProviderAsync(default, default).ReturnsForAnyArgs(new ProviderUser[] { });
var exception = await Assert.ThrowsAsync<BadRequestException>( var exception = await Assert.ThrowsAsync<BadRequestException>(
() => sutProvider.Sut.DeleteUsersAsync(provider.Id, userIds, deletingUser.Id)); () => sutProvider.Sut.DeleteUsersAsync(provider.Id, userIds, deletingUser.Id));
@ -406,7 +406,7 @@ namespace Bit.CommCore.Test.Services
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task DeleteUsersAsync_Success(Provider provider, User deletingUser, ICollection<ProviderUser> providerUsers, public async Task DeleteUsersAsync_Success(Provider provider, User deletingUser, ICollection<ProviderUser> providerUsers,
[ProviderUser(ProviderUserStatusType.Confirmed, ProviderUserType.ProviderAdmin)]ProviderUser remainingOwner, [ProviderUser(ProviderUserStatusType.Confirmed, ProviderUserType.ProviderAdmin)] ProviderUser remainingOwner,
SutProvider<ProviderService> sutProvider) SutProvider<ProviderService> sutProvider)
{ {
var userIds = providerUsers.Select(pu => pu.Id); var userIds = providerUsers.Select(pu => pu.Id);
@ -421,7 +421,7 @@ namespace Bit.CommCore.Test.Services
sutProvider.GetDependency<IProviderRepository>().GetByIdAsync(provider.Id).Returns(provider); sutProvider.GetDependency<IProviderRepository>().GetByIdAsync(provider.Id).Returns(provider);
var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>(); var providerUserRepository = sutProvider.GetDependency<IProviderUserRepository>();
providerUserRepository.GetManyAsync(default).ReturnsForAnyArgs(providerUsers); providerUserRepository.GetManyAsync(default).ReturnsForAnyArgs(providerUsers);
providerUserRepository.GetManyByProviderAsync(default, default).ReturnsForAnyArgs(new[] {remainingOwner}); providerUserRepository.GetManyByProviderAsync(default, default).ReturnsForAnyArgs(new[] { remainingOwner });
var result = await sutProvider.Sut.DeleteUsersAsync(provider.Id, userIds, deletingUser.Id); var result = await sutProvider.Sut.DeleteUsersAsync(provider.Id, userIds, deletingUser.Id);

View File

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace Bit.Admin.Controllers namespace Bit.Admin.Controllers

View File

@ -1,10 +1,10 @@
using System.Diagnostics; using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Bit.Admin.Models;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Settings;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Admin.Models;
using Bit.Core.Settings;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace Bit.Admin.Controllers namespace Bit.Admin.Controllers

View File

@ -1,6 +1,6 @@
using System; using System;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Admin.Controllers namespace Bit.Admin.Controllers
{ {

View File

@ -1,16 +1,16 @@
using System; using System;
using Microsoft.AspNetCore.Mvc; using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Repositories;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Admin.Models; using Bit.Admin.Models;
using System.Collections.Generic; using Bit.Core.Enums;
using Bit.Core.Models.Business;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Bit.Core.Utilities; using Bit.Core.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Models.Business; using Bit.Core.Utilities;
using Bit.Core.Enums; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Admin.Controllers namespace Bit.Admin.Controllers
{ {
@ -143,7 +143,8 @@ namespace Bit.Admin.Controllers
model.ToOrganization(organization); model.ToOrganization(organization);
await _organizationRepository.ReplaceAsync(organization); await _organizationRepository.ReplaceAsync(organization);
await _applicationCacheService.UpsertOrganizationAbilityAsync(organization); await _applicationCacheService.UpsertOrganizationAbilityAsync(organization);
await _referenceEventService.RaiseEventAsync(new ReferenceEvent(ReferenceEventType.OrganizationEditedByAdmin, organization) { await _referenceEventService.RaiseEventAsync(new ReferenceEvent(ReferenceEventType.OrganizationEditedByAdmin, organization)
{
EventRaisedByUser = _userService.GetUserName(User), EventRaisedByUser = _userService.GetUserName(User),
SalesAssistedTrialStarted = model.SalesAssistedTrialStarted, SalesAssistedTrialStarted = model.SalesAssistedTrialStarted,
}); });

View File

@ -1,14 +1,14 @@
using System; using System;
using Microsoft.AspNetCore.Mvc; using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Repositories;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Admin.Models; using Bit.Admin.Models;
using System.Collections.Generic;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Bit.Core.Utilities; using Bit.Core.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Admin.Controllers namespace Bit.Admin.Controllers
{ {

View File

@ -2,10 +2,10 @@
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Azure.Storage.Queues;
using Bit.Core.Settings; using Bit.Core.Settings;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Azure.Storage.Queues;
namespace Bit.Admin.HostedServices namespace Bit.Admin.HostedServices
{ {

View File

@ -1,18 +1,18 @@
using System; using System;
using Microsoft.Extensions.Hosting;
using Azure.Storage.Queues;
using Microsoft.Extensions.Logging;
using Bit.Core.Settings;
using System.Threading.Tasks;
using System.Threading;
using Bit.Core.Services;
using Newtonsoft.Json;
using Bit.Core.Models.Mail;
using Azure.Storage.Queues.Models;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Linq; using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Azure.Storage.Queues;
using Azure.Storage.Queues.Models;
using Bit.Core.Models.Mail;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Bit.Admin.HostedServices namespace Bit.Admin.HostedServices
{ {

View File

@ -1,6 +1,6 @@
using System; using System;
using System.Threading.Tasks;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Bit.Core; using Bit.Core;
using Bit.Core.Context; using Bit.Core.Context;
using Bit.Core.Jobs; using Bit.Core.Jobs;

View File

@ -5,8 +5,8 @@ using Bit.Core.Enums;
using Bit.Core.Models.Business; using Bit.Core.Models.Business;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Bit.Core.Utilities;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
namespace Bit.Admin.Models namespace Bit.Admin.Models
{ {
@ -92,7 +92,7 @@ namespace Bit.Admin.Models
[Display(Name = "2FA")] [Display(Name = "2FA")]
public bool Use2fa { get; set; } public bool Use2fa { get; set; }
[Display(Name = "API")] [Display(Name = "API")]
public bool UseApi{ get; set; } public bool UseApi { get; set; }
[Display(Name = "Reset Password")] [Display(Name = "Reset Password")]
public bool UseResetPassword { get; set; } public bool UseResetPassword { get; set; }
[Display(Name = "Self Host")] [Display(Name = "Self Host")]

View File

@ -1,4 +1,4 @@
namespace Bit.Admin.Models namespace Bit.Admin.Models
{ {
public class TaxRateAddEditModel public class TaxRateAddEditModel
{ {

View File

@ -1,8 +1,8 @@
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
namespace Bit.Admin.Models namespace Bit.Admin.Models
{ {
public class TaxRatesModel: PagedModel<TaxRate> public class TaxRatesModel : PagedModel<TaxRate>
{ {
public string Message { get; set; } public string Message { get; set; }
} }

View File

@ -3,8 +3,8 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Bit.Core.Models.Business; using Bit.Core.Models.Business;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Bit.Core.Utilities;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
namespace Bit.Admin.Models namespace Bit.Admin.Models
{ {

View File

@ -71,11 +71,11 @@ namespace Bit.Admin
services.AddBaseServices(); services.AddBaseServices();
services.AddDefaultServices(globalSettings); services.AddDefaultServices(globalSettings);
#if OSS #if OSS
services.AddOosServices(); services.AddOosServices();
#else #else
services.AddCommCoreServices(); services.AddCommCoreServices();
#endif #endif
// Mvc // Mvc
services.AddMvc(config => services.AddMvc(config =>

View File

@ -1,6 +1,14 @@
using Bit.Api.Utilities; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Bit.Api.Models.Request;
using Bit.Api.Models.Request.Accounts;
using Bit.Api.Models.Response;
using Bit.Api.Utilities;
using Bit.Core; using Bit.Core;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Enums.Provider;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Bit.Core.Models.Business; using Bit.Core.Models.Business;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
@ -11,14 +19,6 @@ using Bit.Core.Settings;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Bit.Api.Models.Request;
using Bit.Api.Models.Request.Accounts;
using Bit.Api.Models.Response;
using Bit.Core.Enums.Provider;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -66,7 +66,7 @@ namespace Bit.Api.Controllers
[HttpPost("prelogin")] [HttpPost("prelogin")]
[AllowAnonymous] [AllowAnonymous]
public async Task<PreloginResponseModel> PostPrelogin([FromBody]PreloginRequestModel model) public async Task<PreloginResponseModel> PostPrelogin([FromBody] PreloginRequestModel model)
{ {
var kdfInformation = await _userRepository.GetKdfInformationByEmailAsync(model.Email); var kdfInformation = await _userRepository.GetKdfInformationByEmailAsync(model.Email);
if (kdfInformation == null) if (kdfInformation == null)
@ -83,7 +83,7 @@ namespace Bit.Api.Controllers
[HttpPost("register")] [HttpPost("register")]
[AllowAnonymous] [AllowAnonymous]
[CaptchaProtected] [CaptchaProtected]
public async Task PostRegister([FromBody]RegisterRequestModel model) public async Task PostRegister([FromBody] RegisterRequestModel model)
{ {
var result = await _userService.RegisterUserAsync(model.ToUser(), model.MasterPasswordHash, var result = await _userService.RegisterUserAsync(model.ToUser(), model.MasterPasswordHash,
model.Token, model.OrganizationUserId); model.Token, model.OrganizationUserId);
@ -103,13 +103,13 @@ namespace Bit.Api.Controllers
[HttpPost("password-hint")] [HttpPost("password-hint")]
[AllowAnonymous] [AllowAnonymous]
public async Task PostPasswordHint([FromBody]PasswordHintRequestModel model) public async Task PostPasswordHint([FromBody] PasswordHintRequestModel model)
{ {
await _userService.SendMasterPasswordHintAsync(model.Email); await _userService.SendMasterPasswordHintAsync(model.Email);
} }
[HttpPost("email-token")] [HttpPost("email-token")]
public async Task PostEmailToken([FromBody]EmailTokenRequestModel model) public async Task PostEmailToken([FromBody] EmailTokenRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -132,7 +132,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("email")] [HttpPost("email")]
public async Task PostEmail([FromBody]EmailRequestModel model) public async Task PostEmail([FromBody] EmailRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -175,7 +175,7 @@ namespace Bit.Api.Controllers
[HttpPost("verify-email-token")] [HttpPost("verify-email-token")]
[AllowAnonymous] [AllowAnonymous]
public async Task PostVerifyEmailToken([FromBody]VerifyEmailRequestModel model) public async Task PostVerifyEmailToken([FromBody] VerifyEmailRequestModel model)
{ {
var user = await _userService.GetUserByIdAsync(new Guid(model.UserId)); var user = await _userService.GetUserByIdAsync(new Guid(model.UserId));
if (user == null) if (user == null)
@ -198,7 +198,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("password")] [HttpPost("password")]
public async Task PostPassword([FromBody]PasswordRequestModel model) public async Task PostPassword([FromBody] PasswordRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -223,7 +223,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("set-password")] [HttpPost("set-password")]
public async Task PostSetPasswordAsync([FromBody]SetPasswordRequestModel model) public async Task PostSetPasswordAsync([FromBody] SetPasswordRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -247,7 +247,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("verify-password")] [HttpPost("verify-password")]
public async Task PostVerifyPassword([FromBody]SecretVerificationRequestModel model) public async Task PostVerifyPassword([FromBody] SecretVerificationRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -266,7 +266,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("set-key-connector-key")] [HttpPost("set-key-connector-key")]
public async Task PostSetKeyConnectorKeyAsync([FromBody]SetKeyConnectorKeyRequestModel model) public async Task PostSetKeyConnectorKeyAsync([FromBody] SetKeyConnectorKeyRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -312,7 +312,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("kdf")] [HttpPost("kdf")]
public async Task PostKdf([FromBody]KdfRequestModel model) public async Task PostKdf([FromBody] KdfRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -337,7 +337,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("key")] [HttpPost("key")]
public async Task PostKey([FromBody]UpdateKeyRequestModel model) public async Task PostKey([FromBody] UpdateKeyRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -393,7 +393,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("security-stamp")] [HttpPost("security-stamp")]
public async Task PostSecurityStamp([FromBody]SecretVerificationRequestModel model) public async Task PostSecurityStamp([FromBody] SecretVerificationRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -449,7 +449,7 @@ namespace Bit.Api.Controllers
[HttpPut("profile")] [HttpPut("profile")]
[HttpPost("profile")] [HttpPost("profile")]
public async Task<ProfileResponseModel> PutProfile([FromBody]UpdateProfileRequestModel model) public async Task<ProfileResponseModel> PutProfile([FromBody] UpdateProfileRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -477,7 +477,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("keys")] [HttpPost("keys")]
public async Task<KeysResponseModel> PostKeys([FromBody]KeysRequestModel model) public async Task<KeysResponseModel> PostKeys([FromBody] KeysRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -503,7 +503,7 @@ namespace Bit.Api.Controllers
[HttpDelete] [HttpDelete]
[HttpPost("delete")] [HttpPost("delete")]
public async Task Delete([FromBody]SecretVerificationRequestModel model) public async Task Delete([FromBody] SecretVerificationRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -535,14 +535,14 @@ namespace Bit.Api.Controllers
[AllowAnonymous] [AllowAnonymous]
[HttpPost("delete-recover")] [HttpPost("delete-recover")]
public async Task PostDeleteRecover([FromBody]DeleteRecoverRequestModel model) public async Task PostDeleteRecover([FromBody] DeleteRecoverRequestModel model)
{ {
await _userService.SendDeleteConfirmationAsync(model.Email); await _userService.SendDeleteConfirmationAsync(model.Email);
} }
[HttpPost("delete-recover-token")] [HttpPost("delete-recover-token")]
[AllowAnonymous] [AllowAnonymous]
public async Task PostDeleteRecoverToken([FromBody]VerifyDeleteRecoverRequestModel model) public async Task PostDeleteRecoverToken([FromBody] VerifyDeleteRecoverRequestModel model)
{ {
var user = await _userService.GetUserByIdAsync(new Guid(model.UserId)); var user = await _userService.GetUserByIdAsync(new Guid(model.UserId));
if (user == null) if (user == null)
@ -566,7 +566,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("iap-check")] [HttpPost("iap-check")]
public async Task PostIapCheck([FromBody]IapCheckRequestModel model) public async Task PostIapCheck([FromBody] IapCheckRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -660,7 +660,7 @@ namespace Bit.Api.Controllers
[HttpPost("payment")] [HttpPost("payment")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PostPayment([FromBody]PaymentRequestModel model) public async Task PostPayment([FromBody] PaymentRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -678,7 +678,7 @@ namespace Bit.Api.Controllers
[HttpPost("storage")] [HttpPost("storage")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task<PaymentResponseModel> PostStorage([FromBody]StorageRequestModel model) public async Task<PaymentResponseModel> PostStorage([FromBody] StorageRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -755,7 +755,7 @@ namespace Bit.Api.Controllers
[HttpPut("tax")] [HttpPut("tax")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutTaxInfo([FromBody]TaxInfoUpdateRequestModel model) public async Task PutTaxInfo([FromBody] TaxInfoUpdateRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -793,7 +793,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("api-key")] [HttpPost("api-key")]
public async Task<ApiKeyResponseModel> ApiKey([FromBody]SecretVerificationRequestModel model) public async Task<ApiKeyResponseModel> ApiKey([FromBody] SecretVerificationRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -811,7 +811,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("rotate-api-key")] [HttpPost("rotate-api-key")]
public async Task<ApiKeyResponseModel> RotateApiKey([FromBody]SecretVerificationRequestModel model) public async Task<ApiKeyResponseModel> RotateApiKey([FromBody] SecretVerificationRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -831,7 +831,7 @@ namespace Bit.Api.Controllers
} }
[HttpPut("update-temp-password")] [HttpPut("update-temp-password")]
public async Task PutUpdateTempPasswordAsync([FromBody]UpdateTempPasswordRequestModel model) public async Task PutUpdateTempPasswordAsync([FromBody] UpdateTempPasswordRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -866,7 +866,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("verify-otp")] [HttpPost("verify-otp")]
public async Task VerifyOTP([FromBody]VerifyOTPRequestModel model) public async Task VerifyOTP([FromBody] VerifyOTPRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user is not { UsesKeyConnector: true }) if (user is not { UsesKeyConnector: true })

View File

@ -1,27 +1,27 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Context;
using Bit.Core.Utilities;
using Bit.Api.Utilities;
using System.Collections.Generic;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using Core.Models.Data;
using Azure.Messaging.EventGrid; using Azure.Messaging.EventGrid;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Request.Accounts; using Bit.Api.Models.Request.Accounts;
using Bit.Api.Models.Request.Organizations; using Bit.Api.Models.Request.Organizations;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Bit.Api.Utilities;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Exceptions;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Core.Models.Data;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Bit.Core;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -123,7 +123,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("")] [HttpPost("")]
public async Task<CipherResponseModel> Post([FromBody]CipherRequestModel model) public async Task<CipherResponseModel> Post([FromBody] CipherRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var cipher = model.ToCipherDetails(userId); var cipher = model.ToCipherDetails(userId);
@ -138,7 +138,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("create")] [HttpPost("create")]
public async Task<CipherResponseModel> PostCreate([FromBody]CipherCreateRequestModel model) public async Task<CipherResponseModel> PostCreate([FromBody] CipherCreateRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var cipher = model.Cipher.ToCipherDetails(userId); var cipher = model.Cipher.ToCipherDetails(userId);
@ -153,7 +153,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("admin")] [HttpPost("admin")]
public async Task<CipherMiniResponseModel> PostAdmin([FromBody]CipherCreateRequestModel model) public async Task<CipherMiniResponseModel> PostAdmin([FromBody] CipherCreateRequestModel model)
{ {
var cipher = model.Cipher.ToOrganizationCipher(); var cipher = model.Cipher.ToOrganizationCipher();
if (!await _currentContext.EditAnyCollection(cipher.OrganizationId.Value)) if (!await _currentContext.EditAnyCollection(cipher.OrganizationId.Value))
@ -170,7 +170,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")] [HttpPost("{id}")]
public async Task<CipherResponseModel> Put(string id, [FromBody]CipherRequestModel model) public async Task<CipherResponseModel> Put(string id, [FromBody] CipherRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId); var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId);
@ -195,7 +195,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}/admin")] [HttpPut("{id}/admin")]
[HttpPost("{id}/admin")] [HttpPost("{id}/admin")]
public async Task<CipherMiniResponseModel> PutAdmin(string id, [FromBody]CipherRequestModel model) public async Task<CipherMiniResponseModel> PutAdmin(string id, [FromBody] CipherRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetOrganizationDetailsByIdAsync(new Guid(id)); var cipher = await _cipherRepository.GetOrganizationDetailsByIdAsync(new Guid(id));
@ -241,7 +241,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("import")] [HttpPost("import")]
public async Task PostImport([FromBody]ImportCiphersRequestModel model) public async Task PostImport([FromBody] ImportCiphersRequestModel model)
{ {
if (!_globalSettings.SelfHosted && if (!_globalSettings.SelfHosted &&
(model.Ciphers.Count() > 6000 || model.FolderRelationships.Count() > 6000 || (model.Ciphers.Count() > 6000 || model.FolderRelationships.Count() > 6000 ||
@ -257,8 +257,8 @@ namespace Bit.Api.Controllers
} }
[HttpPost("import-organization")] [HttpPost("import-organization")]
public async Task PostImport([FromQuery]string organizationId, public async Task PostImport([FromQuery] string organizationId,
[FromBody]ImportOrganizationCiphersRequestModel model) [FromBody] ImportOrganizationCiphersRequestModel model)
{ {
if (!_globalSettings.SelfHosted && if (!_globalSettings.SelfHosted &&
(model.Ciphers.Count() > 6000 || model.CollectionRelationships.Count() > 12000 || (model.Ciphers.Count() > 6000 || model.CollectionRelationships.Count() > 12000 ||
@ -281,7 +281,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}/partial")] [HttpPut("{id}/partial")]
[HttpPost("{id}/partial")] [HttpPost("{id}/partial")]
public async Task PutPartial(string id, [FromBody]CipherPartialRequestModel model) public async Task PutPartial(string id, [FromBody] CipherPartialRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var folderId = string.IsNullOrWhiteSpace(model.FolderId) ? null : (Guid?)new Guid(model.FolderId); var folderId = string.IsNullOrWhiteSpace(model.FolderId) ? null : (Guid?)new Guid(model.FolderId);
@ -290,7 +290,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}/share")] [HttpPut("{id}/share")]
[HttpPost("{id}/share")] [HttpPost("{id}/share")]
public async Task<CipherResponseModel> PutShare(string id, [FromBody]CipherShareRequestModel model) public async Task<CipherResponseModel> PutShare(string id, [FromBody] CipherShareRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var cipherId = new Guid(id); var cipherId = new Guid(id);
@ -312,7 +312,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}/collections")] [HttpPut("{id}/collections")]
[HttpPost("{id}/collections")] [HttpPost("{id}/collections")]
public async Task PutCollections(string id, [FromBody]CipherCollectionsRequestModel model) public async Task PutCollections(string id, [FromBody] CipherCollectionsRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId); var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId);
@ -328,7 +328,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}/collections-admin")] [HttpPut("{id}/collections-admin")]
[HttpPost("{id}/collections-admin")] [HttpPost("{id}/collections-admin")]
public async Task PutCollectionsAdmin(string id, [FromBody]CipherCollectionsRequestModel model) public async Task PutCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id)); var cipher = await _cipherRepository.GetByIdAsync(new Guid(id));
@ -373,7 +373,7 @@ namespace Bit.Api.Controllers
[HttpDelete("")] [HttpDelete("")]
[HttpPost("delete")] [HttpPost("delete")]
public async Task DeleteMany([FromBody]CipherBulkDeleteRequestModel model) public async Task DeleteMany([FromBody] CipherBulkDeleteRequestModel model)
{ {
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
{ {
@ -387,7 +387,7 @@ namespace Bit.Api.Controllers
[HttpDelete("admin")] [HttpDelete("admin")]
[HttpPost("delete-admin")] [HttpPost("delete-admin")]
public async Task DeleteManyAdmin([FromBody]CipherBulkDeleteRequestModel model) public async Task DeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
{ {
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
{ {
@ -432,7 +432,7 @@ namespace Bit.Api.Controllers
} }
[HttpPut("delete")] [HttpPut("delete")]
public async Task PutDeleteMany([FromBody]CipherBulkDeleteRequestModel model) public async Task PutDeleteMany([FromBody] CipherBulkDeleteRequestModel model)
{ {
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
{ {
@ -444,7 +444,7 @@ namespace Bit.Api.Controllers
} }
[HttpPut("delete-admin")] [HttpPut("delete-admin")]
public async Task PutDeleteManyAdmin([FromBody]CipherBulkDeleteRequestModel model) public async Task PutDeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
{ {
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
{ {
@ -511,7 +511,7 @@ namespace Bit.Api.Controllers
[HttpPut("move")] [HttpPut("move")]
[HttpPost("move")] [HttpPost("move")]
public async Task MoveMany([FromBody]CipherBulkMoveRequestModel model) public async Task MoveMany([FromBody] CipherBulkMoveRequestModel model)
{ {
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
{ {
@ -525,7 +525,7 @@ namespace Bit.Api.Controllers
[HttpPut("share")] [HttpPut("share")]
[HttpPost("share")] [HttpPost("share")]
public async Task PutShareMany([FromBody]CipherBulkShareRequestModel model) public async Task PutShareMany([FromBody] CipherBulkShareRequestModel model)
{ {
var organizationId = new Guid(model.Ciphers.First().OrganizationId); var organizationId = new Guid(model.Ciphers.First().OrganizationId);
if (!await _currentContext.OrganizationUser(organizationId)) if (!await _currentContext.OrganizationUser(organizationId))
@ -553,7 +553,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("purge")] [HttpPost("purge")]
public async Task PostPurge([FromBody]SecretVerificationRequestModel model, string organizationId = null) public async Task PostPurge([FromBody] SecretVerificationRequestModel model, string organizationId = null)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)

View File

@ -1,16 +1,16 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Context;
using Bit.Core.Models.Table;
using System.Collections.Generic;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Bit.Core.Context;
using Bit.Core.Exceptions;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -111,7 +111,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("")] [HttpPost("")]
public async Task<CollectionResponseModel> Post(string orgId, [FromBody]CollectionRequestModel model) public async Task<CollectionResponseModel> Post(string orgId, [FromBody] CollectionRequestModel model)
{ {
var orgIdGuid = new Guid(orgId); var orgIdGuid = new Guid(orgId);
var collection = model.ToCollection(orgIdGuid); var collection = model.ToCollection(orgIdGuid);
@ -132,7 +132,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")] [HttpPost("{id}")]
public async Task<CollectionResponseModel> Put(string orgId, string id, [FromBody]CollectionRequestModel model) public async Task<CollectionResponseModel> Put(string orgId, string id, [FromBody] CollectionRequestModel model)
{ {
if (!await CanEditCollectionAsync(orgId, id)) if (!await CanEditCollectionAsync(orgId, id))
{ {
@ -146,7 +146,7 @@ namespace Bit.Api.Controllers
} }
[HttpPut("{id}/users")] [HttpPut("{id}/users")]
public async Task PutUsers(string orgId, string id, [FromBody]IEnumerable<SelectionReadOnlyRequestModel> model) public async Task PutUsers(string orgId, string id, [FromBody] IEnumerable<SelectionReadOnlyRequestModel> model)
{ {
var collection = await GetCollectionAsync(new Guid(id), new Guid(orgId)); var collection = await GetCollectionAsync(new Guid(id), new Guid(orgId));
await _collectionRepository.UpdateUsersAsync(collection.Id, model?.Select(g => g.ToSelectionReadOnly())); await _collectionRepository.UpdateUsersAsync(collection.Id, model?.Select(g => g.ToSelectionReadOnly()));

View File

@ -4,12 +4,12 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -66,7 +66,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("")] [HttpPost("")]
public async Task<DeviceResponseModel> Post([FromBody]DeviceRequestModel model) public async Task<DeviceResponseModel> Post([FromBody] DeviceRequestModel model)
{ {
var device = model.ToDevice(_userService.GetProperUserId(User)); var device = model.ToDevice(_userService.GetProperUserId(User));
await _deviceService.SaveAsync(device); await _deviceService.SaveAsync(device);
@ -77,7 +77,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")] [HttpPost("{id}")]
public async Task<DeviceResponseModel> Put(string id, [FromBody]DeviceRequestModel model) public async Task<DeviceResponseModel> Put(string id, [FromBody] DeviceRequestModel model)
{ {
var device = await _deviceRepository.GetByIdAsync(new Guid(id), _userService.GetProperUserId(User).Value); var device = await _deviceRepository.GetByIdAsync(new Guid(id), _userService.GetProperUserId(User).Value);
if (device == null) if (device == null)
@ -93,7 +93,7 @@ namespace Bit.Api.Controllers
[HttpPut("identifier/{identifier}/token")] [HttpPut("identifier/{identifier}/token")]
[HttpPost("identifier/{identifier}/token")] [HttpPost("identifier/{identifier}/token")]
public async Task PutToken(string identifier, [FromBody]DeviceTokenRequestModel model) public async Task PutToken(string identifier, [FromBody] DeviceTokenRequestModel model)
{ {
var device = await _deviceRepository.GetByIdentifierAsync(identifier, _userService.GetProperUserId(User).Value); var device = await _deviceRepository.GetByIdentifierAsync(identifier, _userService.GetProperUserId(User).Value);
if (device == null) if (device == null)

View File

@ -77,7 +77,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")] [HttpPost("{id}")]
public async Task Put(string id, [FromBody]EmergencyAccessUpdateRequestModel model) public async Task Put(string id, [FromBody] EmergencyAccessUpdateRequestModel model)
{ {
var emergencyAccess = await _emergencyAccessRepository.GetByIdAsync(new Guid(id)); var emergencyAccess = await _emergencyAccessRepository.GetByIdAsync(new Guid(id));
if (emergencyAccess == null) if (emergencyAccess == null)

View File

@ -2,13 +2,13 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Context; using Bit.Core.Context;
using Bit.Core.Exceptions;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -41,7 +41,7 @@ namespace Bit.Api.Controllers
[HttpGet("")] [HttpGet("")]
public async Task<ListResponseModel<EventResponseModel>> GetUser( public async Task<ListResponseModel<EventResponseModel>> GetUser(
[FromQuery]DateTime? start = null, [FromQuery]DateTime? end = null, [FromQuery]string continuationToken = null) [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, [FromQuery] string continuationToken = null)
{ {
var dateRange = GetDateRange(start, end); var dateRange = GetDateRange(start, end);
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
@ -53,7 +53,7 @@ namespace Bit.Api.Controllers
[HttpGet("~/ciphers/{id}/events")] [HttpGet("~/ciphers/{id}/events")]
public async Task<ListResponseModel<EventResponseModel>> GetCipher(string id, public async Task<ListResponseModel<EventResponseModel>> GetCipher(string id,
[FromQuery]DateTime? start = null, [FromQuery]DateTime? end = null, [FromQuery]string continuationToken = null) [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, [FromQuery] string continuationToken = null)
{ {
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id)); var cipher = await _cipherRepository.GetByIdAsync(new Guid(id));
if (cipher == null) if (cipher == null)
@ -86,7 +86,7 @@ namespace Bit.Api.Controllers
[HttpGet("~/organizations/{id}/events")] [HttpGet("~/organizations/{id}/events")]
public async Task<ListResponseModel<EventResponseModel>> GetOrganization(string id, public async Task<ListResponseModel<EventResponseModel>> GetOrganization(string id,
[FromQuery]DateTime? start = null, [FromQuery]DateTime? end = null, [FromQuery]string continuationToken = null) [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, [FromQuery] string continuationToken = null)
{ {
var orgId = new Guid(id); var orgId = new Guid(id);
if (!await _currentContext.AccessEventLogs(orgId)) if (!await _currentContext.AccessEventLogs(orgId))
@ -103,7 +103,7 @@ namespace Bit.Api.Controllers
[HttpGet("~/organizations/{orgId}/users/{id}/events")] [HttpGet("~/organizations/{orgId}/users/{id}/events")]
public async Task<ListResponseModel<EventResponseModel>> GetOrganizationUser(string orgId, string id, public async Task<ListResponseModel<EventResponseModel>> GetOrganizationUser(string orgId, string id,
[FromQuery]DateTime? start = null, [FromQuery]DateTime? end = null, [FromQuery]string continuationToken = null) [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, [FromQuery] string continuationToken = null)
{ {
var organizationUser = await _organizationUserRepository.GetByIdAsync(new Guid(id)); var organizationUser = await _organizationUserRepository.GetByIdAsync(new Guid(id));
if (organizationUser == null || !organizationUser.UserId.HasValue || if (organizationUser == null || !organizationUser.UserId.HasValue ||
@ -122,7 +122,7 @@ namespace Bit.Api.Controllers
[HttpGet("~/providers/{providerId:guid}/events")] [HttpGet("~/providers/{providerId:guid}/events")]
public async Task<ListResponseModel<EventResponseModel>> GetProvider(Guid providerId, public async Task<ListResponseModel<EventResponseModel>> GetProvider(Guid providerId,
[FromQuery]DateTime? start = null, [FromQuery]DateTime? end = null, [FromQuery]string continuationToken = null) [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, [FromQuery] string continuationToken = null)
{ {
if (!_currentContext.ProviderAccessEventLogs(providerId)) if (!_currentContext.ProviderAccessEventLogs(providerId))
{ {
@ -138,7 +138,7 @@ namespace Bit.Api.Controllers
[HttpGet("~/providers/{providerId:guid}/users/{id:guid}/events")] [HttpGet("~/providers/{providerId:guid}/users/{id:guid}/events")]
public async Task<ListResponseModel<EventResponseModel>> GetProviderUser(Guid providerId, Guid id, public async Task<ListResponseModel<EventResponseModel>> GetProviderUser(Guid providerId, Guid id,
[FromQuery]DateTime? start = null, [FromQuery]DateTime? end = null, [FromQuery]string continuationToken = null) [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, [FromQuery] string continuationToken = null)
{ {
var providerUser = await _providerUserRepository.GetByIdAsync(id); var providerUser = await _providerUserRepository.GetByIdAsync(id);
if (providerUser == null || !providerUser.UserId.HasValue || if (providerUser == null || !providerUser.UserId.HasValue ||

View File

@ -3,11 +3,11 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -52,7 +52,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("")] [HttpPost("")]
public async Task<FolderResponseModel> Post([FromBody]FolderRequestModel model) public async Task<FolderResponseModel> Post([FromBody] FolderRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var folder = model.ToFolder(_userService.GetProperUserId(User).Value); var folder = model.ToFolder(_userService.GetProperUserId(User).Value);
@ -62,7 +62,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")] [HttpPost("{id}")]
public async Task<FolderResponseModel> Put(string id, [FromBody]FolderRequestModel model) public async Task<FolderResponseModel> Put(string id, [FromBody] FolderRequestModel model)
{ {
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var folder = await _folderRepository.GetByIdAsync(new Guid(id), userId); var folder = await _folderRepository.GetByIdAsync(new Guid(id), userId);

View File

@ -1,15 +1,15 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Context;
using System.Collections.Generic;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Bit.Core.Context;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -89,7 +89,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("")] [HttpPost("")]
public async Task<GroupResponseModel> Post(string orgId, [FromBody]GroupRequestModel model) public async Task<GroupResponseModel> Post(string orgId, [FromBody] GroupRequestModel model)
{ {
var orgIdGuid = new Guid(orgId); var orgIdGuid = new Guid(orgId);
if (!await _currentContext.ManageGroups(orgIdGuid)) if (!await _currentContext.ManageGroups(orgIdGuid))
@ -104,7 +104,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")] [HttpPost("{id}")]
public async Task<GroupResponseModel> Put(string orgId, string id, [FromBody]GroupRequestModel model) public async Task<GroupResponseModel> Put(string orgId, string id, [FromBody] GroupRequestModel model)
{ {
var group = await _groupRepository.GetByIdAsync(new Guid(id)); var group = await _groupRepository.GetByIdAsync(new Guid(id));
if (group == null || !await _currentContext.ManageGroups(group.OrganizationId)) if (group == null || !await _currentContext.ManageGroups(group.OrganizationId))
@ -117,7 +117,7 @@ namespace Bit.Api.Controllers
} }
[HttpPut("{id}/users")] [HttpPut("{id}/users")]
public async Task PutUsers(string orgId, string id, [FromBody]IEnumerable<Guid> model) public async Task PutUsers(string orgId, string id, [FromBody] IEnumerable<Guid> model)
{ {
var group = await _groupRepository.GetByIdAsync(new Guid(id)); var group = await _groupRepository.GetByIdAsync(new Guid(id));
if (group == null || !await _currentContext.ManageGroups(group.OrganizationId)) if (group == null || !await _currentContext.ManageGroups(group.OrganizationId))

View File

@ -1,16 +1,16 @@
using System; using System;
using System.Threading.Tasks; using System.Linq;
using Microsoft.AspNetCore.Mvc; using System.Net;
using Microsoft.AspNetCore.Authorization;
using System.Net.Http; using System.Net.Http;
using System.Security.Cryptography; using System.Security.Cryptography;
using Bit.Core.Services; using System.Threading.Tasks;
using Bit.Core.Context; using Bit.Core.Context;
using System.Net;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using System.Linq; using Bit.Core.Services;
using Bit.Core.Utilities;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {

View File

@ -1,8 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {

View File

@ -2,11 +2,11 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {

View File

@ -1,13 +1,13 @@
using Microsoft.AspNetCore.Mvc; using System;
using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Context;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Core.Models.Business; using Bit.Core.Context;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Bit.Core.Models.Business;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using System; using Bit.Core.Services;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -40,7 +40,7 @@ namespace Bit.Api.Controllers
} }
[HttpGet("user/{id}")] [HttpGet("user/{id}")]
public async Task<UserLicense> GetUser(string id, [FromQuery]string key) public async Task<UserLicense> GetUser(string id, [FromQuery] string key)
{ {
var user = await _userRepository.GetByIdAsync(new Guid(id)); var user = await _userRepository.GetByIdAsync(new Guid(id));
if (user == null) if (user == null)
@ -58,7 +58,7 @@ namespace Bit.Api.Controllers
} }
[HttpGet("organization/{id}")] [HttpGet("organization/{id}")]
public async Task<OrganizationLicense> GetOrganization(string id, [FromQuery]string key) public async Task<OrganizationLicense> GetOrganization(string id, [FromQuery] string key)
{ {
var org = await _organizationRepository.GetByIdAsync(new Guid(id)); var org = await _organizationRepository.GetByIdAsync(new Guid(id));
if (org == null) if (org == null)

View File

@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks;
using System.Threading.Tasks;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Core.Settings;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Bit.Core.Settings; using Microsoft.AspNetCore.Mvc;
using Stripe; using Stripe;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
@ -24,7 +24,7 @@ namespace Bit.Api.Controllers
[Authorize("Application")] [Authorize("Application")]
[HttpPost("~/bitpay-invoice")] [HttpPost("~/bitpay-invoice")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task<string> PostBitPayInvoice([FromBody]BitPayInvoiceRequestModel model) public async Task<string> PostBitPayInvoice([FromBody] BitPayInvoiceRequestModel model)
{ {
var invoice = await _bitPayClient.CreateInvoiceAsync(model.ToBitpayInvoice(_globalSettings)); var invoice = await _bitPayClient.CreateInvoiceAsync(model.ToBitpayInvoice(_globalSettings));
return invoice.Url; return invoice.Url;

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Request.Organizations; using Bit.Api.Models.Request.Organizations;
using Bit.Core.Context; using Bit.Core.Context;

View File

@ -1,18 +1,18 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Context;
using System.Collections.Generic;
using Bit.Api.Models.Request.Organizations; using Bit.Api.Models.Request.Organizations;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Bit.Core.Context;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Models.Business; using Bit.Core.Models.Business;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -127,7 +127,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("invite")] [HttpPost("invite")]
public async Task Invite(string orgId, [FromBody]OrganizationUserInviteRequestModel model) public async Task Invite(string orgId, [FromBody] OrganizationUserInviteRequestModel model)
{ {
var orgGuidId = new Guid(orgId); var orgGuidId = new Guid(orgId);
if (!await _currentContext.ManageUsers(orgGuidId)) if (!await _currentContext.ManageUsers(orgGuidId))
@ -141,7 +141,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("reinvite")] [HttpPost("reinvite")]
public async Task<ListResponseModel<OrganizationUserBulkResponseModel>> BulkReinvite(string orgId, [FromBody]OrganizationUserBulkRequestModel model) public async Task<ListResponseModel<OrganizationUserBulkResponseModel>> BulkReinvite(string orgId, [FromBody] OrganizationUserBulkRequestModel model)
{ {
var orgGuidId = new Guid(orgId); var orgGuidId = new Guid(orgId);
if (!await _currentContext.ManageUsers(orgGuidId)) if (!await _currentContext.ManageUsers(orgGuidId))
@ -169,7 +169,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("{id}/accept")] [HttpPost("{id}/accept")]
public async Task Accept(string orgId, string id, [FromBody]OrganizationUserAcceptRequestModel model) public async Task Accept(string orgId, string id, [FromBody] OrganizationUserAcceptRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -181,7 +181,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("{id}/confirm")] [HttpPost("{id}/confirm")]
public async Task Confirm(string orgId, string id, [FromBody]OrganizationUserConfirmRequestModel model) public async Task Confirm(string orgId, string id, [FromBody] OrganizationUserConfirmRequestModel model)
{ {
var orgGuidId = new Guid(orgId); var orgGuidId = new Guid(orgId);
if (!await _currentContext.ManageUsers(orgGuidId)) if (!await _currentContext.ManageUsers(orgGuidId))
@ -196,7 +196,7 @@ namespace Bit.Api.Controllers
[HttpPost("confirm")] [HttpPost("confirm")]
public async Task<ListResponseModel<OrganizationUserBulkResponseModel>> BulkConfirm(string orgId, public async Task<ListResponseModel<OrganizationUserBulkResponseModel>> BulkConfirm(string orgId,
[FromBody]OrganizationUserBulkConfirmRequestModel model) [FromBody] OrganizationUserBulkConfirmRequestModel model)
{ {
var orgGuidId = new Guid(orgId); var orgGuidId = new Guid(orgId);
if (!await _currentContext.ManageUsers(orgGuidId)) if (!await _currentContext.ManageUsers(orgGuidId))
@ -213,7 +213,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("public-keys")] [HttpPost("public-keys")]
public async Task<ListResponseModel<OrganizationUserPublicKeyResponseModel>> UserPublicKeys(string orgId, [FromBody]OrganizationUserBulkRequestModel model) public async Task<ListResponseModel<OrganizationUserPublicKeyResponseModel>> UserPublicKeys(string orgId, [FromBody] OrganizationUserBulkRequestModel model)
{ {
var orgGuidId = new Guid(orgId); var orgGuidId = new Guid(orgId);
if (!await _currentContext.ManageUsers(orgGuidId)) if (!await _currentContext.ManageUsers(orgGuidId))
@ -228,7 +228,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")] [HttpPost("{id}")]
public async Task Put(string orgId, string id, [FromBody]OrganizationUserUpdateRequestModel model) public async Task Put(string orgId, string id, [FromBody] OrganizationUserUpdateRequestModel model)
{ {
var orgGuidId = new Guid(orgId); var orgGuidId = new Guid(orgId);
if (!await _currentContext.ManageUsers(orgGuidId)) if (!await _currentContext.ManageUsers(orgGuidId))
@ -249,7 +249,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}/groups")] [HttpPut("{id}/groups")]
[HttpPost("{id}/groups")] [HttpPost("{id}/groups")]
public async Task PutGroups(string orgId, string id, [FromBody]OrganizationUserUpdateGroupsRequestModel model) public async Task PutGroups(string orgId, string id, [FromBody] OrganizationUserUpdateGroupsRequestModel model)
{ {
var orgGuidId = new Guid(orgId); var orgGuidId = new Guid(orgId);
if (!await _currentContext.ManageUsers(orgGuidId)) if (!await _currentContext.ManageUsers(orgGuidId))
@ -268,14 +268,14 @@ namespace Bit.Api.Controllers
} }
[HttpPut("{userId}/reset-password-enrollment")] [HttpPut("{userId}/reset-password-enrollment")]
public async Task PutResetPasswordEnrollment(string orgId, string userId, [FromBody]OrganizationUserResetPasswordEnrollmentRequestModel model) public async Task PutResetPasswordEnrollment(string orgId, string userId, [FromBody] OrganizationUserResetPasswordEnrollmentRequestModel model)
{ {
var callingUserId = _userService.GetProperUserId(User); var callingUserId = _userService.GetProperUserId(User);
await _organizationService.UpdateUserResetPasswordEnrollmentAsync(new Guid(orgId), new Guid(userId), model.ResetPasswordKey, callingUserId); await _organizationService.UpdateUserResetPasswordEnrollmentAsync(new Guid(orgId), new Guid(userId), model.ResetPasswordKey, callingUserId);
} }
[HttpPut("{id}/reset-password")] [HttpPut("{id}/reset-password")]
public async Task PutResetPassword(string orgId, string id, [FromBody]OrganizationUserResetPasswordRequestModel model) public async Task PutResetPassword(string orgId, string id, [FromBody] OrganizationUserResetPasswordRequestModel model)
{ {
var orgGuidId = new Guid(orgId); var orgGuidId = new Guid(orgId);
@ -326,7 +326,7 @@ namespace Bit.Api.Controllers
[HttpDelete("")] [HttpDelete("")]
[HttpPost("delete")] [HttpPost("delete")]
public async Task<ListResponseModel<OrganizationUserBulkResponseModel>> BulkDelete(string orgId, [FromBody]OrganizationUserBulkRequestModel model) public async Task<ListResponseModel<OrganizationUserBulkResponseModel>> BulkDelete(string orgId, [FromBody] OrganizationUserBulkRequestModel model)
{ {
var orgGuidId = new Guid(orgId); var orgGuidId = new Guid(orgId);
if (!await _currentContext.ManageUsers(orgGuidId)) if (!await _currentContext.ManageUsers(orgGuidId))

View File

@ -5,18 +5,18 @@ using Bit.Api.Models.Request;
using Bit.Api.Models.Request.Accounts; using Bit.Api.Models.Request.Accounts;
using Bit.Api.Models.Request.Organizations; using Bit.Api.Models.Request.Organizations;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Microsoft.AspNetCore.Mvc; using Bit.Api.Utilities;
using Bit.Core.Repositories; using Bit.Core.Context;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Context;
using Bit.Api.Utilities;
using Bit.Core.Models.Business; using Bit.Core.Models.Business;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Utilities; using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
@ -130,7 +130,7 @@ namespace Bit.Api.Controllers
[HttpGet("{id}/license")] [HttpGet("{id}/license")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task<OrganizationLicense> GetLicense(string id, [FromQuery]Guid installationId) public async Task<OrganizationLicense> GetLicense(string id, [FromQuery] Guid installationId)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -191,7 +191,7 @@ namespace Bit.Api.Controllers
[HttpPost("")] [HttpPost("")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task<OrganizationResponseModel> Post([FromBody]OrganizationCreateRequestModel model) public async Task<OrganizationResponseModel> Post([FromBody] OrganizationCreateRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -227,7 +227,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}")] [HttpPut("{id}")]
[HttpPost("{id}")] [HttpPost("{id}")]
public async Task<OrganizationResponseModel> Put(string id, [FromBody]OrganizationUpdateRequestModel model) public async Task<OrganizationResponseModel> Put(string id, [FromBody] OrganizationUpdateRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -250,7 +250,7 @@ namespace Bit.Api.Controllers
[HttpPost("{id}/payment")] [HttpPost("{id}/payment")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PostPayment(string id, [FromBody]PaymentRequestModel model) public async Task PostPayment(string id, [FromBody] PaymentRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -273,7 +273,7 @@ namespace Bit.Api.Controllers
[HttpPost("{id}/upgrade")] [HttpPost("{id}/upgrade")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task<PaymentResponseModel> PostUpgrade(string id, [FromBody]OrganizationUpgradeRequestModel model) public async Task<PaymentResponseModel> PostUpgrade(string id, [FromBody] OrganizationUpgradeRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -304,7 +304,7 @@ namespace Bit.Api.Controllers
[HttpPost("{id}/seat")] [HttpPost("{id}/seat")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task<PaymentResponseModel> PostSeat(string id, [FromBody]OrganizationSeatRequestModel model) public async Task<PaymentResponseModel> PostSeat(string id, [FromBody] OrganizationSeatRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -322,7 +322,7 @@ namespace Bit.Api.Controllers
[HttpPost("{id}/storage")] [HttpPost("{id}/storage")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task<PaymentResponseModel> PostStorage(string id, [FromBody]StorageRequestModel model) public async Task<PaymentResponseModel> PostStorage(string id, [FromBody] StorageRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -340,7 +340,7 @@ namespace Bit.Api.Controllers
[HttpPost("{id}/verify-bank")] [HttpPost("{id}/verify-bank")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PostVerifyBank(string id, [FromBody]OrganizationVerifyBankRequestModel model) public async Task PostVerifyBank(string id, [FromBody] OrganizationVerifyBankRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -401,7 +401,7 @@ namespace Bit.Api.Controllers
[HttpDelete("{id}")] [HttpDelete("{id}")]
[HttpPost("{id}/delete")] [HttpPost("{id}/delete")]
public async Task Delete(string id, [FromBody]SecretVerificationRequestModel model) public async Task Delete(string id, [FromBody] SecretVerificationRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -452,7 +452,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("{id}/import")] [HttpPost("{id}/import")]
public async Task Import(string id, [FromBody]ImportOrganizationUsersRequestModel model) public async Task Import(string id, [FromBody] ImportOrganizationUsersRequestModel model)
{ {
if (!_globalSettings.SelfHosted && !model.LargeImport && if (!_globalSettings.SelfHosted && !model.LargeImport &&
(model.Groups.Count() > 2000 || model.Users.Count(u => !u.Deleted) > 2000)) (model.Groups.Count() > 2000 || model.Users.Count(u => !u.Deleted) > 2000))
@ -477,7 +477,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("{id}/api-key")] [HttpPost("{id}/api-key")]
public async Task<ApiKeyResponseModel> ApiKey(string id, [FromBody]SecretVerificationRequestModel model) public async Task<ApiKeyResponseModel> ApiKey(string id, [FromBody] SecretVerificationRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -510,7 +510,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("{id}/rotate-api-key")] [HttpPost("{id}/rotate-api-key")]
public async Task<ApiKeyResponseModel> RotateApiKey(string id, [FromBody]SecretVerificationRequestModel model) public async Task<ApiKeyResponseModel> RotateApiKey(string id, [FromBody] SecretVerificationRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -565,7 +565,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id}/tax")] [HttpPut("{id}/tax")]
[SelfHosted(NotSelfHostedOnly = true)] [SelfHosted(NotSelfHostedOnly = true)]
public async Task PutTaxInfo(string id, [FromBody]OrganizationTaxInfoUpdateRequestModel model) public async Task PutTaxInfo(string id, [FromBody] OrganizationTaxInfoUpdateRequestModel model)
{ {
var orgIdGuid = new Guid(id); var orgIdGuid = new Guid(id);
if (!await _currentContext.OrganizationOwner(orgIdGuid)) if (!await _currentContext.OrganizationOwner(orgIdGuid))
@ -605,7 +605,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("{id}/keys")] [HttpPost("{id}/keys")]
public async Task<OrganizationKeysResponseModel> PostKeys(string id, [FromBody]OrganizationKeysRequestModel model) public async Task<OrganizationKeysResponseModel> PostKeys(string id, [FromBody] OrganizationKeysRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -637,7 +637,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("{id:guid}/sso")] [HttpPost("{id:guid}/sso")]
public async Task<OrganizationSsoResponseModel> PostSso(Guid id, [FromBody]OrganizationSsoRequestModel model) public async Task<OrganizationSsoResponseModel> PostSso(Guid id, [FromBody] OrganizationSsoRequestModel model)
{ {
if (!await _currentContext.ManageSso(id)) if (!await _currentContext.ManageSso(id))
{ {

View File

@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Authorization; using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Utilities;
using System.Linq;
using Bit.Core.Repositories;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Bit.Core.Repositories;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {

View File

@ -3,16 +3,16 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Context; using Bit.Core.Context;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Utilities; using Bit.Core.Exceptions;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -83,8 +83,8 @@ namespace Bit.Api.Controllers
[AllowAnonymous] [AllowAnonymous]
[HttpGet("token")] [HttpGet("token")]
public async Task<ListResponseModel<PolicyResponseModel>> GetByToken(string orgId, [FromQuery]string email, public async Task<ListResponseModel<PolicyResponseModel>> GetByToken(string orgId, [FromQuery] string email,
[FromQuery]string token, [FromQuery]string organizationUserId) [FromQuery] string token, [FromQuery] string organizationUserId)
{ {
var orgUserId = new Guid(organizationUserId); var orgUserId = new Guid(organizationUserId);
var tokenValid = CoreHelpers.UserInviteTokenIsValid(_organizationServiceDataProtector, token, var tokenValid = CoreHelpers.UserInviteTokenIsValid(_organizationServiceDataProtector, token,
@ -107,7 +107,7 @@ namespace Bit.Api.Controllers
} }
[HttpPut("{type}")] [HttpPut("{type}")]
public async Task<PolicyResponseModel> Put(string orgId, int type, [FromBody]PolicyRequestModel model) public async Task<PolicyResponseModel> Put(string orgId, int type, [FromBody] PolicyRequestModel model)
{ {
var orgIdGuid = new Guid(orgId); var orgIdGuid = new Guid(orgId);
if (!await _currentContext.ManagePolicies(orgIdGuid)) if (!await _currentContext.ManagePolicies(orgIdGuid))

View File

@ -50,7 +50,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("add")] [HttpPost("add")]
public async Task Add(Guid providerId, [FromBody]ProviderOrganizationAddRequestModel model) public async Task Add(Guid providerId, [FromBody] ProviderOrganizationAddRequestModel model)
{ {
if (!_currentContext.ManageProviderOrganizations(providerId)) if (!_currentContext.ManageProviderOrganizations(providerId))
{ {

View File

@ -5,13 +5,13 @@ using System.Threading.Tasks;
using Bit.Api.Models.Request.Providers; using Bit.Api.Models.Request.Providers;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Bit.Api.Models.Response.Providers; using Bit.Api.Models.Response.Providers;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Context; using Bit.Core.Context;
using Bit.Core.Exceptions;
using Bit.Core.Models.Business.Provider; using Bit.Core.Models.Business.Provider;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -62,7 +62,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("invite")] [HttpPost("invite")]
public async Task Invite(Guid providerId, [FromBody]ProviderUserInviteRequestModel model) public async Task Invite(Guid providerId, [FromBody] ProviderUserInviteRequestModel model)
{ {
if (!_currentContext.ProviderManageUsers(providerId)) if (!_currentContext.ProviderManageUsers(providerId))
{ {
@ -75,7 +75,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("reinvite")] [HttpPost("reinvite")]
public async Task<ListResponseModel<ProviderUserBulkResponseModel>> BulkReinvite(Guid providerId, [FromBody]ProviderUserBulkRequestModel model) public async Task<ListResponseModel<ProviderUserBulkResponseModel>> BulkReinvite(Guid providerId, [FromBody] ProviderUserBulkRequestModel model)
{ {
if (!_currentContext.ProviderManageUsers(providerId)) if (!_currentContext.ProviderManageUsers(providerId))
{ {
@ -96,13 +96,13 @@ namespace Bit.Api.Controllers
throw new NotFoundException(); throw new NotFoundException();
} }
var invite = ProviderUserInviteFactory.CreateReinvite(new [] { id }, var invite = ProviderUserInviteFactory.CreateReinvite(new[] { id },
_userService.GetProperUserId(User).Value, providerId); _userService.GetProperUserId(User).Value, providerId);
await _providerService.ResendInvitesAsync(invite); await _providerService.ResendInvitesAsync(invite);
} }
[HttpPost("{id:guid}/accept")] [HttpPost("{id:guid}/accept")]
public async Task Accept(Guid providerId, Guid id, [FromBody]ProviderUserAcceptRequestModel model) public async Task Accept(Guid providerId, Guid id, [FromBody] ProviderUserAcceptRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)
@ -114,7 +114,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("{id:guid}/confirm")] [HttpPost("{id:guid}/confirm")]
public async Task Confirm(Guid providerId, Guid id, [FromBody]ProviderUserConfirmRequestModel model) public async Task Confirm(Guid providerId, Guid id, [FromBody] ProviderUserConfirmRequestModel model)
{ {
if (!_currentContext.ProviderManageUsers(providerId)) if (!_currentContext.ProviderManageUsers(providerId))
{ {
@ -127,7 +127,7 @@ namespace Bit.Api.Controllers
[HttpPost("confirm")] [HttpPost("confirm")]
public async Task<ListResponseModel<ProviderUserBulkResponseModel>> BulkConfirm(Guid providerId, public async Task<ListResponseModel<ProviderUserBulkResponseModel>> BulkConfirm(Guid providerId,
[FromBody]ProviderUserBulkConfirmRequestModel model) [FromBody] ProviderUserBulkConfirmRequestModel model)
{ {
if (!_currentContext.ProviderManageUsers(providerId)) if (!_currentContext.ProviderManageUsers(providerId))
{ {
@ -142,7 +142,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("public-keys")] [HttpPost("public-keys")]
public async Task<ListResponseModel<ProviderUserPublicKeyResponseModel>> UserPublicKeys(Guid providerId, [FromBody]ProviderUserBulkRequestModel model) public async Task<ListResponseModel<ProviderUserPublicKeyResponseModel>> UserPublicKeys(Guid providerId, [FromBody] ProviderUserBulkRequestModel model)
{ {
if (!_currentContext.ProviderManageUsers(providerId)) if (!_currentContext.ProviderManageUsers(providerId))
{ {
@ -156,7 +156,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id:guid}")] [HttpPut("{id:guid}")]
[HttpPost("{id:guid}")] [HttpPost("{id:guid}")]
public async Task Put(Guid providerId, Guid id, [FromBody]ProviderUserUpdateRequestModel model) public async Task Put(Guid providerId, Guid id, [FromBody] ProviderUserUpdateRequestModel model)
{ {
if (!_currentContext.ProviderManageUsers(providerId)) if (!_currentContext.ProviderManageUsers(providerId))
{ {
@ -183,12 +183,12 @@ namespace Bit.Api.Controllers
} }
var userId = _userService.GetProperUserId(User); var userId = _userService.GetProperUserId(User);
await _providerService.DeleteUsersAsync(providerId, new [] { id }, userId.Value); await _providerService.DeleteUsersAsync(providerId, new[] { id }, userId.Value);
} }
[HttpDelete("")] [HttpDelete("")]
[HttpPost("delete")] [HttpPost("delete")]
public async Task<ListResponseModel<ProviderUserBulkResponseModel>> BulkDelete(Guid providerId, [FromBody]ProviderUserBulkRequestModel model) public async Task<ListResponseModel<ProviderUserBulkResponseModel>> BulkDelete(Guid providerId, [FromBody] ProviderUserBulkRequestModel model)
{ {
if (!_currentContext.ProviderManageUsers(providerId)) if (!_currentContext.ProviderManageUsers(providerId))
{ {

View File

@ -51,7 +51,7 @@ namespace Bit.Api.Controllers
[HttpPut("{id:guid}")] [HttpPut("{id:guid}")]
[HttpPost("{id:guid}")] [HttpPost("{id:guid}")]
public async Task<ProviderResponseModel> Put(Guid id, [FromBody]ProviderUpdateRequestModel model) public async Task<ProviderResponseModel> Put(Guid id, [FromBody] ProviderUpdateRequestModel model)
{ {
if (!_currentContext.ProviderProviderAdmin(id)) if (!_currentContext.ProviderProviderAdmin(id))
{ {
@ -69,7 +69,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("{id:guid}/setup")] [HttpPost("{id:guid}/setup")]
public async Task<ProviderResponseModel> Setup(Guid id, [FromBody]ProviderSetupRequestModel model) public async Task<ProviderResponseModel> Setup(Guid id, [FromBody] ProviderSetupRequestModel model)
{ {
if (!_currentContext.ProviderProviderAdmin(id)) if (!_currentContext.ProviderProviderAdmin(id))
{ {

View File

@ -1,14 +1,14 @@
using Microsoft.AspNetCore.Mvc; using System.Linq;
using Bit.Core.Services; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Context; using Bit.Core.Context;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.AspNetCore.Hosting;
using Bit.Core.Models.Api; using Bit.Core.Models.Api;
using Bit.Core.Utilities; using Bit.Core.Services;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
@ -39,7 +39,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("register")] [HttpPost("register")]
public async Task PostRegister([FromBody]PushRegistrationRequestModel model) public async Task PostRegister([FromBody] PushRegistrationRequestModel model)
{ {
CheckUsage(); CheckUsage();
await _pushRegistrationService.CreateOrUpdateRegistrationAsync(model.PushToken, Prefix(model.DeviceId), await _pushRegistrationService.CreateOrUpdateRegistrationAsync(model.PushToken, Prefix(model.DeviceId),
@ -54,7 +54,7 @@ namespace Bit.Api.Controllers
} }
[HttpPut("add-organization")] [HttpPut("add-organization")]
public async Task PutAddOrganization([FromBody]PushUpdateRequestModel model) public async Task PutAddOrganization([FromBody] PushUpdateRequestModel model)
{ {
CheckUsage(); CheckUsage();
await _pushRegistrationService.AddUserRegistrationOrganizationAsync( await _pushRegistrationService.AddUserRegistrationOrganizationAsync(
@ -62,7 +62,7 @@ namespace Bit.Api.Controllers
} }
[HttpPut("delete-organization")] [HttpPut("delete-organization")]
public async Task PutDeleteOrganization([FromBody]PushUpdateRequestModel model) public async Task PutDeleteOrganization([FromBody] PushUpdateRequestModel model)
{ {
CheckUsage(); CheckUsage();
await _pushRegistrationService.DeleteUserRegistrationOrganizationAsync( await _pushRegistrationService.DeleteUserRegistrationOrganizationAsync(
@ -70,7 +70,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("send")] [HttpPost("send")]
public async Task PostSend([FromBody]PushSendRequestModel model) public async Task PostSend([FromBody] PushSendRequestModel model)
{ {
CheckUsage(); CheckUsage();

View File

@ -1,25 +1,25 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Utilities;
using Bit.Core.Settings;
using Bit.Core.Enums;
using Bit.Core.Context;
using Azure.Messaging.EventGrid; using Azure.Messaging.EventGrid;
using Bit.Api.Utilities;
using System.Collections.Generic;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Bit.Core.Models.Table; using Bit.Api.Utilities;
using Newtonsoft.Json;
using Bit.Core.Models.Data;
using Microsoft.Extensions.Logging;
using Bit.Core; using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {

View File

@ -2,9 +2,9 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Bit.Core.Services;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -35,7 +35,7 @@ namespace Bit.Api.Controllers
[HttpPut("domains")] [HttpPut("domains")]
[HttpPost("domains")] [HttpPost("domains")]
public async Task<DomainsResponseModel> PutDomains([FromBody]UpdateDomainsRequestModel model) public async Task<DomainsResponseModel> PutDomains([FromBody] UpdateDomainsRequestModel model)
{ {
var user = await _userService.GetUserByPrincipalAsync(User); var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null) if (user == null)

View File

@ -1,18 +1,18 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Response;
using Bit.Core.Enums;
using Bit.Core.Enums.Provider;
using Bit.Core.Exceptions;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Bit.Core.Services;
using Bit.Core.Repositories;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using System.Linq;
using Bit.Core.Models.Table;
using System.Collections.Generic;
using Bit.Api.Models.Response;
using Bit.Core.Enums.Provider;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {

View File

@ -1,23 +1,23 @@
using System; using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Microsoft.AspNetCore.Identity;
using Bit.Core.Models.Table;
using Bit.Core.Enums;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Bit.Api.Models.Request.Accounts; using Bit.Api.Models.Request.Accounts;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Bit.Api.Models.Response.TwoFactor; using Bit.Api.Models.Response.TwoFactor;
using Bit.Core.Context; using Bit.Core.Context;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Models.Table;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Bit.Core.Utilities.Duo; using Bit.Core.Utilities.Duo;
using Bit.Core.Settings;
using Fido2NetLib; using Fido2NetLib;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {
@ -83,7 +83,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("get-authenticator")] [HttpPost("get-authenticator")]
public async Task<TwoFactorAuthenticatorResponseModel> GetAuthenticator([FromBody]SecretVerificationRequestModel model) public async Task<TwoFactorAuthenticatorResponseModel> GetAuthenticator([FromBody] SecretVerificationRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
var response = new TwoFactorAuthenticatorResponseModel(user); var response = new TwoFactorAuthenticatorResponseModel(user);
@ -93,7 +93,7 @@ namespace Bit.Api.Controllers
[HttpPut("authenticator")] [HttpPut("authenticator")]
[HttpPost("authenticator")] [HttpPost("authenticator")]
public async Task<TwoFactorAuthenticatorResponseModel> PutAuthenticator( public async Task<TwoFactorAuthenticatorResponseModel> PutAuthenticator(
[FromBody]UpdateTwoFactorAuthenticatorRequestModel model) [FromBody] UpdateTwoFactorAuthenticatorRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
model.ToUser(user); model.ToUser(user);
@ -111,7 +111,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("get-yubikey")] [HttpPost("get-yubikey")]
public async Task<TwoFactorYubiKeyResponseModel> GetYubiKey([FromBody]SecretVerificationRequestModel model) public async Task<TwoFactorYubiKeyResponseModel> GetYubiKey([FromBody] SecretVerificationRequestModel model)
{ {
var user = await CheckAsync(model, true); var user = await CheckAsync(model, true);
var response = new TwoFactorYubiKeyResponseModel(user); var response = new TwoFactorYubiKeyResponseModel(user);
@ -120,7 +120,7 @@ namespace Bit.Api.Controllers
[HttpPut("yubikey")] [HttpPut("yubikey")]
[HttpPost("yubikey")] [HttpPost("yubikey")]
public async Task<TwoFactorYubiKeyResponseModel> PutYubiKey([FromBody]UpdateTwoFactorYubicoOtpRequestModel model) public async Task<TwoFactorYubiKeyResponseModel> PutYubiKey([FromBody] UpdateTwoFactorYubicoOtpRequestModel model)
{ {
var user = await CheckAsync(model, true); var user = await CheckAsync(model, true);
model.ToUser(user); model.ToUser(user);
@ -137,7 +137,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("get-duo")] [HttpPost("get-duo")]
public async Task<TwoFactorDuoResponseModel> GetDuo([FromBody]SecretVerificationRequestModel model) public async Task<TwoFactorDuoResponseModel> GetDuo([FromBody] SecretVerificationRequestModel model)
{ {
var user = await CheckAsync(model, true); var user = await CheckAsync(model, true);
var response = new TwoFactorDuoResponseModel(user); var response = new TwoFactorDuoResponseModel(user);
@ -146,7 +146,7 @@ namespace Bit.Api.Controllers
[HttpPut("duo")] [HttpPut("duo")]
[HttpPost("duo")] [HttpPost("duo")]
public async Task<TwoFactorDuoResponseModel> PutDuo([FromBody]UpdateTwoFactorDuoRequestModel model) public async Task<TwoFactorDuoResponseModel> PutDuo([FromBody] UpdateTwoFactorDuoRequestModel model)
{ {
var user = await CheckAsync(model, true); var user = await CheckAsync(model, true);
try try
@ -167,7 +167,7 @@ namespace Bit.Api.Controllers
[HttpPost("~/organizations/{id}/two-factor/get-duo")] [HttpPost("~/organizations/{id}/two-factor/get-duo")]
public async Task<TwoFactorDuoResponseModel> GetOrganizationDuo(string id, public async Task<TwoFactorDuoResponseModel> GetOrganizationDuo(string id,
[FromBody]SecretVerificationRequestModel model) [FromBody] SecretVerificationRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
@ -190,7 +190,7 @@ namespace Bit.Api.Controllers
[HttpPut("~/organizations/{id}/two-factor/duo")] [HttpPut("~/organizations/{id}/two-factor/duo")]
[HttpPost("~/organizations/{id}/two-factor/duo")] [HttpPost("~/organizations/{id}/two-factor/duo")]
public async Task<TwoFactorDuoResponseModel> PutOrganizationDuo(string id, public async Task<TwoFactorDuoResponseModel> PutOrganizationDuo(string id,
[FromBody]UpdateTwoFactorDuoRequestModel model) [FromBody] UpdateTwoFactorDuoRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
@ -224,7 +224,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("get-webauthn")] [HttpPost("get-webauthn")]
public async Task<TwoFactorWebAuthnResponseModel> GetWebAuthn([FromBody]SecretVerificationRequestModel model) public async Task<TwoFactorWebAuthnResponseModel> GetWebAuthn([FromBody] SecretVerificationRequestModel model)
{ {
var user = await CheckAsync(model, true); var user = await CheckAsync(model, true);
var response = new TwoFactorWebAuthnResponseModel(user); var response = new TwoFactorWebAuthnResponseModel(user);
@ -232,7 +232,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("get-webauthn-challenge")] [HttpPost("get-webauthn-challenge")]
public async Task<CredentialCreateOptions> GetWebAuthnChallenge([FromBody]SecretVerificationRequestModel model) public async Task<CredentialCreateOptions> GetWebAuthnChallenge([FromBody] SecretVerificationRequestModel model)
{ {
var user = await CheckAsync(model, true); var user = await CheckAsync(model, true);
var reg = await _userService.StartWebAuthnRegistrationAsync(user); var reg = await _userService.StartWebAuthnRegistrationAsync(user);
@ -241,7 +241,7 @@ namespace Bit.Api.Controllers
[HttpPut("webauthn")] [HttpPut("webauthn")]
[HttpPost("webauthn")] [HttpPost("webauthn")]
public async Task<TwoFactorWebAuthnResponseModel> PutWebAuthn([FromBody]TwoFactorWebAuthnRequestModel model) public async Task<TwoFactorWebAuthnResponseModel> PutWebAuthn([FromBody] TwoFactorWebAuthnRequestModel model)
{ {
var user = await CheckAsync(model, true); var user = await CheckAsync(model, true);
@ -256,7 +256,7 @@ namespace Bit.Api.Controllers
} }
[HttpDelete("webauthn")] [HttpDelete("webauthn")]
public async Task<TwoFactorWebAuthnResponseModel> DeleteWebAuthn([FromBody]TwoFactorWebAuthnDeleteRequestModel model) public async Task<TwoFactorWebAuthnResponseModel> DeleteWebAuthn([FromBody] TwoFactorWebAuthnDeleteRequestModel model)
{ {
var user = await CheckAsync(model, true); var user = await CheckAsync(model, true);
await _userService.DeleteWebAuthnKeyAsync(user, model.Id.Value); await _userService.DeleteWebAuthnKeyAsync(user, model.Id.Value);
@ -265,7 +265,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("get-email")] [HttpPost("get-email")]
public async Task<TwoFactorEmailResponseModel> GetEmail([FromBody]SecretVerificationRequestModel model) public async Task<TwoFactorEmailResponseModel> GetEmail([FromBody] SecretVerificationRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
var response = new TwoFactorEmailResponseModel(user); var response = new TwoFactorEmailResponseModel(user);
@ -273,7 +273,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("send-email")] [HttpPost("send-email")]
public async Task SendEmail([FromBody]TwoFactorEmailRequestModel model) public async Task SendEmail([FromBody] TwoFactorEmailRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
model.ToUser(user); model.ToUser(user);
@ -282,7 +282,7 @@ namespace Bit.Api.Controllers
[AllowAnonymous] [AllowAnonymous]
[HttpPost("send-email-login")] [HttpPost("send-email-login")]
public async Task SendEmailLogin([FromBody]TwoFactorEmailRequestModel model) public async Task SendEmailLogin([FromBody] TwoFactorEmailRequestModel model)
{ {
var user = await _userManager.FindByEmailAsync(model.Email.ToLowerInvariant()); var user = await _userManager.FindByEmailAsync(model.Email.ToLowerInvariant());
if (user != null) if (user != null)
@ -300,7 +300,7 @@ namespace Bit.Api.Controllers
[HttpPut("email")] [HttpPut("email")]
[HttpPost("email")] [HttpPost("email")]
public async Task<TwoFactorEmailResponseModel> PutEmail([FromBody]UpdateTwoFactorEmailRequestModel model) public async Task<TwoFactorEmailResponseModel> PutEmail([FromBody] UpdateTwoFactorEmailRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
model.ToUser(user); model.ToUser(user);
@ -319,7 +319,7 @@ namespace Bit.Api.Controllers
[HttpPut("disable")] [HttpPut("disable")]
[HttpPost("disable")] [HttpPost("disable")]
public async Task<TwoFactorProviderResponseModel> PutDisable([FromBody]TwoFactorProviderRequestModel model) public async Task<TwoFactorProviderResponseModel> PutDisable([FromBody] TwoFactorProviderRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
await _userService.DisableTwoFactorProviderAsync(user, model.Type.Value, _organizationService); await _userService.DisableTwoFactorProviderAsync(user, model.Type.Value, _organizationService);
@ -330,7 +330,7 @@ namespace Bit.Api.Controllers
[HttpPut("~/organizations/{id}/two-factor/disable")] [HttpPut("~/organizations/{id}/two-factor/disable")]
[HttpPost("~/organizations/{id}/two-factor/disable")] [HttpPost("~/organizations/{id}/two-factor/disable")]
public async Task<TwoFactorProviderResponseModel> PutOrganizationDisable(string id, public async Task<TwoFactorProviderResponseModel> PutOrganizationDisable(string id,
[FromBody]TwoFactorProviderRequestModel model) [FromBody] TwoFactorProviderRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
@ -352,7 +352,7 @@ namespace Bit.Api.Controllers
} }
[HttpPost("get-recover")] [HttpPost("get-recover")]
public async Task<TwoFactorRecoverResponseModel> GetRecover([FromBody]SecretVerificationRequestModel model) public async Task<TwoFactorRecoverResponseModel> GetRecover([FromBody] SecretVerificationRequestModel model)
{ {
var user = await CheckAsync(model, false); var user = await CheckAsync(model, false);
var response = new TwoFactorRecoverResponseModel(user); var response = new TwoFactorRecoverResponseModel(user);
@ -361,7 +361,7 @@ namespace Bit.Api.Controllers
[HttpPost("recover")] [HttpPost("recover")]
[AllowAnonymous] [AllowAnonymous]
public async Task PostRecover([FromBody]TwoFactorRecoveryRequestModel model) public async Task PostRecover([FromBody] TwoFactorRecoveryRequestModel model)
{ {
if (!await _userService.RecoverTwoFactorAsync(model.Email, model.MasterPasswordHash, model.RecoveryCode, if (!await _userService.RecoverTwoFactorAsync(model.Email, model.MasterPasswordHash, model.RecoveryCode,
_organizationService)) _organizationService))

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Response; using Bit.Api.Models.Response;
using Microsoft.AspNetCore.Mvc; using Bit.Core.Exceptions;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Bit.Core.Exceptions; using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers namespace Bit.Api.Controllers
{ {

View File

@ -9,7 +9,7 @@ namespace Bit.Api.Models.Request.Accounts
public string Country { get; set; } public string Country { get; set; }
public string PostalCode { get; set; } public string PostalCode { get; set; }
public virtual IEnumerable<ValidationResult> Validate (ValidationContext validationContext) public virtual IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{ {
if (Country == "US" && string.IsNullOrWhiteSpace(PostalCode)) if (Country == "US" && string.IsNullOrWhiteSpace(PostalCode))
{ {

View File

@ -1,4 +1,4 @@
namespace Bit.Api.Models.Request namespace Bit.Api.Models.Request
{ {
public class AttachmentRequestModel public class AttachmentRequestModel
{ {

View File

@ -1,4 +1,4 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums; using Bit.Core.Enums;

View File

@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Utilities; using Bit.Core.Utilities;

View File

@ -37,7 +37,7 @@ namespace Bit.Api.Models.Request.Organizations
public class SsoConfigurationDataRequest : IValidatableObject public class SsoConfigurationDataRequest : IValidatableObject
{ {
public SsoConfigurationDataRequest() {} public SsoConfigurationDataRequest() { }
[Required] [Required]
public SsoType ConfigType { get; set; } public SsoType ConfigType { get; set; }

View File

@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Bit.Api.Models.Request.Organizations namespace Bit.Api.Models.Request.Organizations
{ {

View File

@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Bit.Api.Models.Request.Organizations; using Bit.Api.Models.Request.Organizations;
using Bit.Core.Utilities; using Bit.Core.Utilities;

View File

@ -1,4 +1,4 @@
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Models.Api; using Bit.Core.Models.Api;
namespace Bit.Api.Models.Response namespace Bit.Api.Models.Response

View File

@ -1,4 +1,4 @@
using System; using System;
using Bit.Core.Models.Api; using Bit.Core.Models.Api;
namespace Bit.Api.Models.Response namespace Bit.Api.Models.Response

View File

@ -1,4 +1,4 @@
using System; using System;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Models.Api; using Bit.Core.Models.Api;
using Bit.Core.Models.StaticStore; using Bit.Core.Models.StaticStore;

View File

@ -7,7 +7,7 @@ namespace Bit.Api.Models.Response
{ {
public class ProfileOrganizationResponseModel : ResponseModel public class ProfileOrganizationResponseModel : ResponseModel
{ {
public ProfileOrganizationResponseModel(string str) : base(str) {} public ProfileOrganizationResponseModel(string str) : base(str) { }
public ProfileOrganizationResponseModel(OrganizationUserOrganizationDetails organization) : this("profileOrganization") public ProfileOrganizationResponseModel(OrganizationUserOrganizationDetails organization) : this("profileOrganization")
{ {

View File

@ -1,4 +1,4 @@
using Bit.Core.Models.Api; using Bit.Core.Models.Api;
namespace Bit.Api.Models.Response namespace Bit.Api.Models.Response
{ {

View File

@ -1,4 +1,4 @@
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Models.Api; using Bit.Core.Models.Api;
namespace Bit.Api.Models.Response namespace Bit.Api.Models.Response

View File

@ -1,4 +1,4 @@
using System; using System;
using Bit.Core.Models.Api; using Bit.Core.Models.Api;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;

View File

@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Hosting; using AspNetCoreRateLimit;
using Microsoft.Extensions.Hosting;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Serilog.Events; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using AspNetCoreRateLimit; using Serilog.Events;
namespace Bit.Api namespace Bit.Api
{ {

View File

@ -85,7 +85,7 @@ namespace Bit.Api.Public.Controllers
[ProducesResponseType(typeof(CollectionResponseModel), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(CollectionResponseModel), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> Put(Guid id, [FromBody]CollectionUpdateRequestModel model) public async Task<IActionResult> Put(Guid id, [FromBody] CollectionUpdateRequestModel model)
{ {
var existingCollection = await _collectionRepository.GetByIdAsync(id); var existingCollection = await _collectionRepository.GetByIdAsync(id);
if (existingCollection == null || existingCollection.OrganizationId != _currentContext.OrganizationId) if (existingCollection == null || existingCollection.OrganizationId != _currentContext.OrganizationId)

View File

@ -39,7 +39,7 @@ namespace Bit.Api.Public.Controllers
/// </remarks> /// </remarks>
[HttpGet] [HttpGet]
[ProducesResponseType(typeof(ListResponseModel<EventResponseModel>), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(ListResponseModel<EventResponseModel>), (int)HttpStatusCode.OK)]
public async Task<IActionResult> List([FromQuery]EventFilterRequestModel request) public async Task<IActionResult> List([FromQuery] EventFilterRequestModel request)
{ {
var dateRange = request.ToDateRange(); var dateRange = request.ToDateRange();
var result = new PagedResult<IEvent>(); var result = new PagedResult<IEvent>();

View File

@ -104,7 +104,7 @@ namespace Bit.Api.Public.Controllers
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(GroupResponseModel), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(GroupResponseModel), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
public async Task<IActionResult> Post([FromBody]GroupCreateUpdateRequestModel model) public async Task<IActionResult> Post([FromBody] GroupCreateUpdateRequestModel model)
{ {
var group = model.ToGroup(_currentContext.OrganizationId.Value); var group = model.ToGroup(_currentContext.OrganizationId.Value);
var associations = model.Collections?.Select(c => c.ToSelectionReadOnly()); var associations = model.Collections?.Select(c => c.ToSelectionReadOnly());
@ -126,7 +126,7 @@ namespace Bit.Api.Public.Controllers
[ProducesResponseType(typeof(GroupResponseModel), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(GroupResponseModel), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> Put(Guid id, [FromBody]GroupCreateUpdateRequestModel model) public async Task<IActionResult> Put(Guid id, [FromBody] GroupCreateUpdateRequestModel model)
{ {
var existingGroup = await _groupRepository.GetByIdAsync(id); var existingGroup = await _groupRepository.GetByIdAsync(id);
if (existingGroup == null || existingGroup.OrganizationId != _currentContext.OrganizationId) if (existingGroup == null || existingGroup.OrganizationId != _currentContext.OrganizationId)
@ -152,7 +152,7 @@ namespace Bit.Api.Public.Controllers
[ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> PutMemberIds(Guid id, [FromBody]UpdateMemberIdsRequestModel model) public async Task<IActionResult> PutMemberIds(Guid id, [FromBody] UpdateMemberIdsRequestModel model)
{ {
var existingGroup = await _groupRepository.GetByIdAsync(id); var existingGroup = await _groupRepository.GetByIdAsync(id);
if (existingGroup == null || existingGroup.OrganizationId != _currentContext.OrganizationId) if (existingGroup == null || existingGroup.OrganizationId != _currentContext.OrganizationId)

View File

@ -115,7 +115,7 @@ namespace Bit.Api.Public.Controllers
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(MemberResponseModel), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(MemberResponseModel), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
public async Task<IActionResult> Post([FromBody]MemberCreateRequestModel model) public async Task<IActionResult> Post([FromBody] MemberCreateRequestModel model)
{ {
var associations = model.Collections?.Select(c => c.ToSelectionReadOnly()); var associations = model.Collections?.Select(c => c.ToSelectionReadOnly());
var invite = new OrganizationUserInvite var invite = new OrganizationUserInvite
@ -144,7 +144,7 @@ namespace Bit.Api.Public.Controllers
[ProducesResponseType(typeof(MemberResponseModel), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(MemberResponseModel), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> Put(Guid id, [FromBody]MemberUpdateRequestModel model) public async Task<IActionResult> Put(Guid id, [FromBody] MemberUpdateRequestModel model)
{ {
var existingUser = await _organizationUserRepository.GetByIdAsync(id); var existingUser = await _organizationUserRepository.GetByIdAsync(id);
if (existingUser == null || existingUser.OrganizationId != _currentContext.OrganizationId) if (existingUser == null || existingUser.OrganizationId != _currentContext.OrganizationId)
@ -180,7 +180,7 @@ namespace Bit.Api.Public.Controllers
[ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> PutGroupIds(Guid id, [FromBody]UpdateGroupIdsRequestModel model) public async Task<IActionResult> PutGroupIds(Guid id, [FromBody] UpdateGroupIdsRequestModel model)
{ {
var existingUser = await _organizationUserRepository.GetByIdAsync(id); var existingUser = await _organizationUserRepository.GetByIdAsync(id);
if (existingUser == null || existingUser.OrganizationId != _currentContext.OrganizationId) if (existingUser == null || existingUser.OrganizationId != _currentContext.OrganizationId)

View File

@ -40,7 +40,7 @@ namespace Bit.Api.Public.Controllers
[HttpPost("import")] [HttpPost("import")]
[ProducesResponseType(typeof(MemberResponseModel), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(MemberResponseModel), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
public async Task<IActionResult> Import([FromBody]OrganizationImportRequestModel model) public async Task<IActionResult> Import([FromBody] OrganizationImportRequestModel model)
{ {
if (!_globalSettings.SelfHosted && !model.LargeImport && if (!_globalSettings.SelfHosted && !model.LargeImport &&
(model.Groups.Count() > 2000 || model.Members.Count(u => !u.Deleted) > 2000)) (model.Groups.Count() > 2000 || model.Members.Count(u => !u.Deleted) > 2000))

View File

@ -88,7 +88,7 @@ namespace Bit.Api.Public.Controllers
[ProducesResponseType(typeof(PolicyResponseModel), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(PolicyResponseModel), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> Put(PolicyType type, [FromBody]PolicyUpdateRequestModel model) public async Task<IActionResult> Put(PolicyType type, [FromBody] PolicyUpdateRequestModel model)
{ {
var policy = await _policyRepository.GetByOrganizationIdTypeAsync( var policy = await _policyRepository.GetByOrganizationIdTypeAsync(
_currentContext.OrganizationId.Value, type); _currentContext.OrganizationId.Value, type);

View File

@ -122,11 +122,11 @@ namespace Bit.Api
services.AddDefaultServices(globalSettings); services.AddDefaultServices(globalSettings);
services.AddCoreLocalizationServices(); services.AddCoreLocalizationServices();
#if OSS #if OSS
services.AddOosServices(); services.AddOosServices();
#else #else
services.AddCommCoreServices(); services.AddCommCoreServices();
#endif #endif
// MVC // MVC
services.AddMvc(config => services.AddMvc(config =>

View File

@ -1,13 +1,13 @@
using Bit.Core.Utilities; using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Azure.Messaging.EventGrid;
using Azure.Messaging.EventGrid.SystemEvents;
using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using Azure.Messaging.EventGrid;
using Azure.Messaging.EventGrid.SystemEvents;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
namespace Bit.Api.Utilities namespace Bit.Api.Utilities
{ {

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc.Filters; using System;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding;
using System;
namespace Bit.Api.Utilities namespace Bit.Api.Utilities
{ {

View File

@ -1,15 +1,15 @@
using System; using System;
using Bit.Api.Models.Public.Response; using Bit.Api.Models.Public.Response;
using InternalApi = Bit.Core.Models.Api;
using Bit.Core.Exceptions; using Bit.Core.Exceptions;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using Stripe; using Stripe;
using Microsoft.Extensions.Hosting; using InternalApi = Bit.Core.Models.Api;
namespace Bit.Api.Utilities namespace Bit.Api.Utilities
{ {

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc; using System.Linq;
using Bit.Api.Models.Public.Response;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using InternalApi = Bit.Core.Models.Api; using InternalApi = Bit.Core.Models.Api;
using System.Linq;
using Bit.Api.Models.Public.Response;
namespace Bit.Api.Utilities namespace Bit.Api.Utilities
{ {

View File

@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Http; using System;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Net.Http.Headers;
using System;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Api.Models.Request; using Bit.Api.Models.Request;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Bit.Api.Utilities namespace Bit.Api.Utilities

View File

@ -1,13 +1,13 @@
using Bit.Core; using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace Bit.Billing.Controllers namespace Bit.Billing.Controllers
{ {

View File

@ -1,4 +1,9 @@
using Bit.Billing.Models; using System;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Bit.Billing.Models;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
@ -6,11 +11,6 @@ using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
namespace Bit.Billing.Controllers namespace Bit.Billing.Controllers
{ {

View File

@ -1,20 +1,19 @@
using Bit.Core.Repositories; using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations; using Bit.Core.Repositories;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
namespace Bit.Billing.Controllers namespace Bit.Billing.Controllers
{ {

View File

@ -1,6 +1,6 @@
using System; using System;
using Microsoft.AspNetCore.Mvc;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Billing.Controllers namespace Bit.Billing.Controllers
{ {

View File

@ -1,4 +1,8 @@
using Bit.Billing.Utilities; using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Bit.Billing.Utilities;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Bit.Core.Repositories; using Bit.Core.Repositories;
@ -7,10 +11,6 @@ using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace Bit.Billing.Controllers namespace Bit.Billing.Controllers
{ {
@ -183,7 +183,7 @@ namespace Bit.Billing.Controllers
} }
} }
// Catch foreign key violations because user/org could have been deleted. // Catch foreign key violations because user/org could have been deleted.
catch (SqlException e) when(e.Number == 547) { } catch (SqlException e) when (e.Number == 547) { }
} }
else if (ipnTransaction.PaymentStatus == "Refunded" || ipnTransaction.PaymentStatus == "Reversed") else if (ipnTransaction.PaymentStatus == "Refunded" || ipnTransaction.PaymentStatus == "Reversed")
{ {

View File

@ -1,4 +1,10 @@
using Bit.Core.Enums; using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Bit.Core.Enums;
using Bit.Core.Models.Business; using Bit.Core.Models.Business;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Bit.Core.Repositories; using Bit.Core.Repositories;
@ -11,12 +17,6 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Stripe; using Stripe;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Bit.Billing.Controllers namespace Bit.Billing.Controllers
{ {
@ -322,7 +322,7 @@ namespace Bit.Billing.Controllers
await _transactionRepository.CreateAsync(tx); await _transactionRepository.CreateAsync(tx);
} }
// Catch foreign key violations because user/org could have been deleted. // Catch foreign key violations because user/org could have been deleted.
catch (SqlException e) when(e.Number == 547) { } catch (SqlException e) when (e.Number == 547) { }
} }
else if (parsedEvent.Type.Equals("charge.refunded")) else if (parsedEvent.Type.Equals("charge.refunded"))
{ {

View File

@ -18,7 +18,7 @@ namespace Bit.Billing.Jobs
IServiceProvider serviceProvider, IServiceProvider serviceProvider,
ILogger<JobsHostedService> logger, ILogger<JobsHostedService> logger,
ILogger<JobListener> listenerLogger) ILogger<JobListener> listenerLogger)
: base(globalSettings, serviceProvider, logger, listenerLogger) {} : base(globalSettings, serviceProvider, logger, listenerLogger) { }
public override async Task StartAsync(CancellationToken cancellationToken) public override async Task StartAsync(CancellationToken cancellationToken)
{ {

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Hosting; using Bit.Core.Utilities;
using Bit.Core.Utilities; using Microsoft.AspNetCore.Hosting;
using Serilog.Events;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Serilog.Events;
namespace Bit.Billing namespace Bit.Billing
{ {

View File

@ -1,17 +1,17 @@
using System; using System;
using Microsoft.AspNetCore.Builder; using System.Globalization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Bit.Core.Context; using Bit.Core.Context;
using Bit.Core.Settings; using Bit.Core.Settings;
using Stripe;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing;
using System.Globalization; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Stripe;
namespace Bit.Billing namespace Bit.Billing
{ {

View File

@ -1,3 +1,3 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Core.Test")] [assembly: InternalsVisibleTo("Core.Test")]

View File

@ -1,4 +1,4 @@
using System; using System;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;

View File

@ -1,4 +1,4 @@
using System; using System;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Enums.Provider; using Bit.Core.Enums.Provider;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;

View File

@ -1,16 +1,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Bit.Core.Models.Table;
using Bit.Core.Enums;
using Microsoft.AspNetCore.Http;
using Bit.Core.Repositories;
using System.Threading.Tasks;
using System.Security.Claims; using System.Security.Claims;
using System.Threading.Tasks;
using Bit.Core.Enums;
using Bit.Core.Enums.Provider; using Bit.Core.Enums.Provider;
using Bit.Core.Utilities;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Http;
namespace Bit.Core.Context namespace Bit.Core.Context
{ {

View File

@ -1,4 +1,4 @@
namespace Bit.Core.Enums namespace Bit.Core.Enums
{ {
public static class BitwardenClient public static class BitwardenClient
{ {

View File

@ -1,4 +1,4 @@
namespace Bit.Core.Enums namespace Bit.Core.Enums
{ {
public enum CipherStateAction public enum CipherStateAction
{ {

View File

@ -1,4 +1,4 @@
namespace Bit.Core.Enums namespace Bit.Core.Enums
{ {
public enum FileUploadType public enum FileUploadType
{ {

View File

@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Enums namespace Bit.Core.Enums
{ {

View File

@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Enums namespace Bit.Core.Enums
{ {

View File

@ -1,4 +1,4 @@
namespace Bit.Core.Enums namespace Bit.Core.Enums
{ {
public enum SupportedDatabaseProviders public enum SupportedDatabaseProviders
{ {

View File

@ -1,11 +1,11 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Bit.Core.Models.Table;
using Bit.Core.Enums; using Bit.Core.Enums;
using OtpNet; using Bit.Core.Models.Table;
using Bit.Core.Services; using Bit.Core.Services;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using OtpNet;
namespace Bit.Core.Identity namespace Bit.Core.Identity
{ {

View File

@ -1,13 +1,13 @@
using System.Threading.Tasks; using System;
using Microsoft.AspNetCore.Identity; using System.Threading.Tasks;
using Bit.Core.Models.Table;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Utilities.Duo;
using Bit.Core.Models; using Bit.Core.Models;
using System; using Bit.Core.Models.Table;
using Microsoft.Extensions.DependencyInjection;
using Bit.Core.Services; using Bit.Core.Services;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities.Duo;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Core.Identity namespace Bit.Core.Identity
{ {

View File

@ -1,11 +1,11 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Bit.Core.Models.Table;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Services;
using Microsoft.Extensions.DependencyInjection;
using Bit.Core.Models; using Bit.Core.Models;
using Bit.Core.Models.Table;
using Bit.Core.Services;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Core.Identity namespace Bit.Core.Identity
{ {

View File

@ -1,9 +1,9 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Core.Models.Table;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Utilities.Duo;
using Bit.Core.Models; using Bit.Core.Models;
using Bit.Core.Models.Table;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities.Duo;
namespace Bit.Core.Identity namespace Bit.Core.Identity
{ {

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
using Microsoft.AspNetCore.Identity;
namespace Bit.Core.Identity namespace Bit.Core.Identity
{ {

Some files were not shown because too many files have changed in this diff Show More