1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-24 12:35:25 +01:00

[PS-40] Upgrade to .NET 6 (#2056)

* Bump to .NET 6

* Update Docker images

* Update docs

* Update workflow for linter

* Add all common versions to props file

* Update tools manifest

* Update csproj files

* Update packages.lock.json files

* Switch to setup-dotnet

* Remove msbuild

* Fix deps breaking changes

* Manually install msbuild

* Use msbuild for build

* Fix verbosity switch

* Remove unused exceptions

* Address linter feedback

* Make Obsolete warnings suggestions for now.

* Force Evaluate

* Format on tests

* Run formatting again.

* Use windows 2022

* force evaluate

* Fix restore

* Fix linter

* Skip test

* Update Directory.Build.props

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>

* Address PR feedback

* Add IntegationTest for Rate limiter

* Fix test

* Reenable test

* Reorder test

* Skip test again

* Add tracking link

* Update .github/workflows/build.yml

Co-authored-by: Micaiah Martin <77340197+mimartin12@users.noreply.github.com>

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
Co-authored-by: Micaiah Martin <77340197+mimartin12@users.noreply.github.com>
This commit is contained in:
Justin Baur 2022-06-24 10:39:34 -04:00 committed by GitHub
parent b8d41b47f1
commit daeaa42851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
95 changed files with 15042 additions and 32574 deletions

View File

@ -2,26 +2,20 @@
"version": 1, "version": 1,
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"dotnet-format": {
"version": "5.1.250801",
"commands": [
"dotnet-format"
]
},
"swashbuckle.aspnetcore.cli": { "swashbuckle.aspnetcore.cli": {
"version": "5.0.0-rc4", "version": "6.3.1",
"commands": [ "commands": [
"swagger" "swagger"
] ]
}, },
"coverlet.console": { "coverlet.console": {
"version": "3.0.3", "version": "3.1.2",
"commands": [ "commands": [
"coverlet" "coverlet"
] ]
}, },
"dotnet-reportgenerator-globaltool": { "dotnet-reportgenerator-globaltool": {
"version": "4.8.8", "version": "5.1.6",
"commands": [ "commands": [
"reportgenerator" "reportgenerator"
] ]

View File

@ -73,6 +73,12 @@ dotnet_naming_style.end_in_async.required_suffix = Async
dotnet_naming_style.end_in_async.capitalization = pascal_case dotnet_naming_style.end_in_async.capitalization = pascal_case
dotnet_naming_style.end_in_async.word_separator = dotnet_naming_style.end_in_async.word_separator =
# Obsolete warnings, this should be removed or changed to warning once we address some of the obsolete items.
dotnet_diagnostic.CS0618.severity = suggestion
# Obsolete warnings, this should be removed or changed to warning once we address some of the obsolete items.
dotnet_diagnostic.CS0612.severity = suggestion
# CSharp code style settings: # CSharp code style settings:
[*.cs] [*.cs]
# Prefer "var" everywhere # Prefer "var" everywhere

View File

@ -35,33 +35,28 @@ jobs:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
# TODO: This can be removed when upgrading to .NET 6
- name: Restore tools
run: dotnet tool restore
- name: Verify Format - name: Verify Format
run: dotnet tool run dotnet-format --check run: dotnet format --verify-no-changes
testing: testing:
name: Testing name: Testing
runs-on: windows-2019 runs-on: windows-2022
env: env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps: steps:
- name: Set up NuGet - name: Set up dotnet
uses: nuget/setup-nuget@04b0c2b8d1b97922f67eca497d7cf0bf17b8ffe1 uses: actions/setup-dotnet@9211491ffb35dd6a6657ca4f45d43dfe6e97c829
with: with:
nuget-version: '5' dotnet-version: '6.0.x'
- name: Set up MSBuild - name: Set up MSBuild
uses: microsoft/setup-msbuild@ab534842b4bdf384b8aaf93765dc6f721d9f5fab uses: microsoft/setup-msbuild@ab534842b4bdf384b8aaf93765dc6f721d9f5fab
- name: Print environment - name: Print environment
run: | run: |
nuget help | grep Version
msbuild -version
dotnet --info dotnet --info
msbuild -version
nuget help | grep Version
echo "GitHub ref: $GITHUB_REF" echo "GitHub ref: $GITHUB_REF"
echo "GitHub event: $GITHUB_EVENT" echo "GitHub event: $GITHUB_EVENT"
@ -69,18 +64,13 @@ jobs:
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
- name: Restore - name: Restore
run: msbuild /t:restore /p:RestoreLockedMode=true run: dotnet restore --locked-mode
shell: pwsh shell: pwsh
- name: Build solution - name: Build solution
run: msbuild bitwarden-server.sln /p:Configuration=Debug /verbosity:minimal run: msbuild bitwarden-server.sln /p:Configuration=Debug /verbosity:minimal
shell: pwsh shell: pwsh
# TODO: This can be removed when upgrading to .NET 6
- name: Restore tools
run: dotnet tool restore
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
shell: pwsh shell: pwsh

22
.vscode/launch.json vendored
View File

@ -93,7 +93,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "buildIdentity", "preLaunchTask": "buildIdentity",
"program": "${workspaceFolder}/src/Identity/bin/Debug/net5.0/Identity.dll", "program": "${workspaceFolder}/src/Identity/bin/Debug/net6.0/Identity.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/Identity", "cwd": "${workspaceFolder}/src/Identity",
"stopAtEntry": false, "stopAtEntry": false,
@ -115,7 +115,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "buildAPI", "preLaunchTask": "buildAPI",
"program": "${workspaceFolder}/src/Api/bin/Debug/net5.0/Api.dll", "program": "${workspaceFolder}/src/Api/bin/Debug/net6.0/Api.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/Api", "cwd": "${workspaceFolder}/src/Api",
"stopAtEntry": false, "stopAtEntry": false,
@ -160,7 +160,7 @@
"request": "launch", "request": "launch",
"preLaunchTask": "buildAdmin", "preLaunchTask": "buildAdmin",
"OS-COMMENT4": "If you have changed target frameworks, make sure to update the program path.", "OS-COMMENT4": "If you have changed target frameworks, make sure to update the program path.",
"program": "${workspaceFolder}/src/Admin/bin/Debug/net5.0/Admin.dll", "program": "${workspaceFolder}/src/Admin/bin/Debug/net6.0/Admin.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/Admin", "cwd": "${workspaceFolder}/src/Admin",
"stopAtEntry": false, "stopAtEntry": false,
@ -183,7 +183,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "buildSso", "preLaunchTask": "buildSso",
"program": "${workspaceFolder}/bitwarden_license/src/Sso/bin/Debug/net5.0/Sso.dll", "program": "${workspaceFolder}/bitwarden_license/src/Sso/bin/Debug/net6.0/Sso.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/bitwarden_license/src/Sso", "cwd": "${workspaceFolder}/bitwarden_license/src/Sso",
"stopAtEntry": false, "stopAtEntry": false,
@ -205,7 +205,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "buildEventsProcessor", "preLaunchTask": "buildEventsProcessor",
"program": "${workspaceFolder}/src/EventsProcessor/bin/Debug/net5.0/EventsProcessor.dll", "program": "${workspaceFolder}/src/EventsProcessor/bin/Debug/net6.0/EventsProcessor.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/EventsProcessor", "cwd": "${workspaceFolder}/src/EventsProcessor",
"stopAtEntry": false, "stopAtEntry": false,
@ -227,7 +227,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "buildIcons", "preLaunchTask": "buildIcons",
"program": "${workspaceFolder}/src/Icons/bin/Debug/net5.0/Icons.dll", "program": "${workspaceFolder}/src/Icons/bin/Debug/net6.0/Icons.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/Icons", "cwd": "${workspaceFolder}/src/Icons",
"stopAtEntry": false, "stopAtEntry": false,
@ -249,7 +249,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "buildIdentity", "preLaunchTask": "buildIdentity",
"program": "${workspaceFolder}/src/Identity/bin/Debug/net5.0/Identity.dll", "program": "${workspaceFolder}/src/Identity/bin/Debug/net6.0/Identity.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/Identity", "cwd": "${workspaceFolder}/src/Identity",
"stopAtEntry": false, "stopAtEntry": false,
@ -273,7 +273,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "buildAPI", "preLaunchTask": "buildAPI",
"program": "${workspaceFolder}/src/Api/bin/Debug/net5.0/Api.dll", "program": "${workspaceFolder}/src/Api/bin/Debug/net6.0/Api.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/Api", "cwd": "${workspaceFolder}/src/Api",
"stopAtEntry": false, "stopAtEntry": false,
@ -298,7 +298,7 @@
"request": "launch", "request": "launch",
"preLaunchTask": "buildAdmin", "preLaunchTask": "buildAdmin",
"OS-COMMENT4": "If you have changed target frameworks, make sure to update the program path.", "OS-COMMENT4": "If you have changed target frameworks, make sure to update the program path.",
"program": "${workspaceFolder}/src/Admin/bin/Debug/net5.0/Admin.dll", "program": "${workspaceFolder}/src/Admin/bin/Debug/net6.0/Admin.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/Admin", "cwd": "${workspaceFolder}/src/Admin",
"stopAtEntry": false, "stopAtEntry": false,
@ -323,7 +323,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "buildSso", "preLaunchTask": "buildSso",
"program": "${workspaceFolder}/bitwarden_license/src/Sso/bin/Debug/net5.0/Sso.dll", "program": "${workspaceFolder}/bitwarden_license/src/Sso/bin/Debug/net6.0/Sso.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/bitwarden_license/src/Sso", "cwd": "${workspaceFolder}/bitwarden_license/src/Sso",
"stopAtEntry": false, "stopAtEntry": false,
@ -347,7 +347,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "buildEventsProcessor", "preLaunchTask": "buildEventsProcessor",
"program": "${workspaceFolder}/src/EventsProcessor/bin/Debug/net5.0/EventsProcessor.dll", "program": "${workspaceFolder}/src/EventsProcessor/bin/Debug/net6.0/EventsProcessor.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/EventsProcessor", "cwd": "${workspaceFolder}/src/EventsProcessor",
"stopAtEntry": false, "stopAtEntry": false,

View File

@ -1,10 +1,51 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<!--Current Version: -->
<Version>2022.5.2</Version> <Version>2022.5.2</Version>
<RootNamespace>Bit.$(MSBuildProjectName)</RootNamespace> <RootNamespace>Bit.$(MSBuildProjectName)</RootNamespace>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup> </PropertyGroup>
</Project> <!--
This section is for packages that we use multiple times throughout the solution
It gives us a single place to manage the version to ensure we are using the same version
across the solution.
-->
<PropertyGroup>
<!--
NuGet: https://www.nuget.org/packages/Microsoft.NET.Test.Sdk
-->
<MicrosoftNetTestSdkVersion>17.1.0</MicrosoftNetTestSdkVersion>
<!--
NuGet: https://www.nuget.org/packages/xunit
-->
<XUnitVersion>2.4.1</XUnitVersion>
<!--
NuGet: https://www.nuget.org/packages/xunit
-->
<XUnitRunnerVisualStudioVersion>2.4.3</XUnitRunnerVisualStudioVersion>
<!--
NuGet: https://www.nuget.org/packages/coverlet.collector/
-->
<CoverletCollectorVersion>3.1.2</CoverletCollectorVersion>
<!--
NuGet: https://www.nuget.org/packages/Swashbuckle.AspNetCore/
-->
<MicrosoftVisualStudioWebCodeGenerationDesignVersion>6.0.3</MicrosoftVisualStudioWebCodeGenerationDesignVersion>
<!--
NuGet: https://www.nuget.org/packages/NSubstitute/
-->
<NSubstitueVersion>4.3.0</NSubstitueVersion>
<!--
NuGet: https://www.nuget.org/packages/AutoFixture.Xunit2/
-->
<AutoFixtureXUnit2Version>4.17.0</AutoFixtureXUnit2Version>
<!--
NuGet: https://www.nuget.org/packages/AutoFixture.AutoNSubstitute/
-->
<AutoFixtureAutoNSubstituteVersion>4.17.0</AutoFixtureAutoNSubstituteVersion>
</PropertyGroup>
</Project>

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\src\Core\Core.csproj" /> <ProjectReference Include="..\..\..\src\Core\Core.csproj" />
</ItemGroup> </ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

View File

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Sustainsys.Saml2.AspNetCore2" Version="2.8.0" /> <PackageReference Include="Sustainsys.Saml2.AspNetCore2" Version="2.9.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> <PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0"> <PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

View File

@ -233,8 +233,7 @@ namespace Bit.CommCore.Test.Services
} }
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task AcceptUserAsync_UserIsInvalid_Throws(ProviderUser providerUser, User user, public async Task AcceptUserAsync_UserIsInvalid_Throws(SutProvider<ProviderService> sutProvider)
SutProvider<ProviderService> sutProvider)
{ {
var exception = await Assert.ThrowsAsync<BadRequestException>( var exception = await Assert.ThrowsAsync<BadRequestException>(
() => sutProvider.Sut.AcceptUserAsync(default, default, default)); () => sutProvider.Sut.AcceptUserAsync(default, default, default));

File diff suppressed because it is too large Load Diff

View File

@ -19,8 +19,8 @@
</Choose> </Choose>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.21.0" /> <PackageReference Include="Microsoft.Azure.Cosmos" Version="3.26.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="$(MicrosoftVisualStudioWebCodeGenerationDesignVersion)" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

File diff suppressed because it is too large Load Diff

View File

@ -29,13 +29,8 @@
</Choose> </Choose>
<ItemGroup> <ItemGroup>
<PackageReference Include="Azure.Messaging.EventGrid" Version="4.7.0" /> <PackageReference Include="Azure.Messaging.EventGrid" Version="4.10.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Swashbuckle.AspNetCore.Cli" Version="4.0.1" />
</ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

View File

@ -80,6 +80,10 @@ namespace Bit.Api
// Rate limiting // Rate limiting
services.AddSingleton<IIpPolicyStore, MemoryCacheIpPolicyStore>(); services.AddSingleton<IIpPolicyStore, MemoryCacheIpPolicyStore>();
services.AddSingleton<IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>(); services.AddSingleton<IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>();
// Ref: https://github.com/stefanprodan/AspNetCoreRateLimit/issues/216
services.AddSingleton<IProcessingStrategy, AsyncKeyLockProcessingStrategy>();
// Ref: https://github.com/stefanprodan/AspNetCoreRateLimit/issues/66
services.AddSingleton<IRateLimitConfiguration, RateLimitConfiguration>();
} }
// Identity // Identity

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="$(MicrosoftVisualStudioWebCodeGenerationDesignVersion)" />
</ItemGroup> </ItemGroup>
</Project> </Project>

File diff suppressed because it is too large Load Diff

View File

@ -20,37 +20,36 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.3.101.182" /> <PackageReference Include="AWSSDK.SimpleEmail" Version="3.7.0.150" />
<PackageReference Include="AWSSDK.SQS" Version="3.3.103.15" /> <PackageReference Include="AWSSDK.SQS" Version="3.7.2.47" />
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" Version="1.2.1" /> <PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" Version="1.2.1" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.10.0" /> <PackageReference Include="Azure.Storage.Blobs" Version="12.11.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.3.2" /> <PackageReference Include="Azure.Storage.Queues" Version="12.9.0" />
<PackageReference Include="BitPay.Light" Version="1.0.1907" /> <PackageReference Include="BitPay.Light" Version="1.0.1907" />
<PackageReference Include="Fido2.AspNet" Version="3.0.0-beta2" /> <PackageReference Include="Fido2.AspNet" Version="3.0.0-beta2" />
<PackageReference Include="Handlebars.Net" Version="1.10.1" /> <PackageReference Include="Handlebars.Net" Version="2.1.2" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" /> <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="MailKit" Version="2.8.0" /> <PackageReference Include="MailKit" Version="3.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.9" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.4" />
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.7" /> <PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.8" />
<PackageReference Include="Microsoft.Azure.NotificationHubs" Version="3.3.0" /> <PackageReference Include="Microsoft.Azure.NotificationHubs" Version="4.1.0" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.1.3" /> <PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.9" /> <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="6.0.4" />
<PackageReference Include="Quartz" Version="3.1.0" /> <PackageReference Include="Quartz" Version="3.4.0" />
<PackageReference Include="SendGrid" Version="9.25.3" /> <PackageReference Include="SendGrid" Version="9.27.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" /> <PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" /> <PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" /> <PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
<PackageReference Include="Sentry.Serilog" Version="2.1.5" /> <PackageReference Include="Sentry.Serilog" Version="3.16.0" />
<PackageReference Include="IdentityServer4" Version="4.0.4" /> <PackageReference Include="IdentityServer4" Version="4.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Serilog.Sinks.AzureCosmosDB" Version="1.0.0" /> <PackageReference Include="Serilog.Sinks.AzureCosmosDB" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.SyslogMessages" Version="1.0.5" /> <PackageReference Include="Serilog.Sinks.SyslogMessages" Version="2.0.6" />
<PackageReference Include="System.Text.Json" Version="4.7.2" /> <PackageReference Include="AspNetCoreRateLimit" Version="4.0.2" />
<PackageReference Include="AspNetCoreRateLimit" Version="2.1.0" /> <PackageReference Include="Braintree" Version="5.12.0" />
<PackageReference Include="Braintree" Version="4.18.0" /> <PackageReference Include="Stripe.net" Version="39.107.0" />
<PackageReference Include="Stripe.net" Version="37.26.0" />
<PackageReference Include="Otp.NET" Version="1.2.2" /> <PackageReference Include="Otp.NET" Version="1.2.2" />
<PackageReference Include="YubicoDotNetClient" Version="1.2.0" /> <PackageReference Include="YubicoDotNetClient" Version="1.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />

View File

@ -9,6 +9,7 @@ using Bit.Core.Entities;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Settings; using Bit.Core.Settings;
using Microsoft.Extensions.Logging;
namespace Bit.Core.Services namespace Bit.Core.Services
{ {
@ -21,6 +22,8 @@ namespace Bit.Core.Services
private static readonly TimeSpan blobLinkLiveTime = TimeSpan.FromMinutes(1); private static readonly TimeSpan blobLinkLiveTime = TimeSpan.FromMinutes(1);
private readonly BlobServiceClient _blobServiceClient; private readonly BlobServiceClient _blobServiceClient;
private readonly Dictionary<string, BlobContainerClient> _attachmentContainers = new Dictionary<string, BlobContainerClient>(); private readonly Dictionary<string, BlobContainerClient> _attachmentContainers = new Dictionary<string, BlobContainerClient>();
private readonly ILogger<AzureAttachmentStorageService> _logger;
private string BlobName(Guid cipherId, CipherAttachment.MetaData attachmentData, Guid? organizationId = null, bool temp = false) => private string BlobName(Guid cipherId, CipherAttachment.MetaData attachmentData, Guid? organizationId = null, bool temp = false) =>
string.Concat( string.Concat(
temp ? "temp/" : "", temp ? "temp/" : "",
@ -53,9 +56,11 @@ namespace Bit.Core.Services
} }
public AzureAttachmentStorageService( public AzureAttachmentStorageService(
GlobalSettings globalSettings) GlobalSettings globalSettings,
ILogger<AzureAttachmentStorageService> logger)
{ {
_blobServiceClient = new BlobServiceClient(globalSettings.Attachment.ConnectionString); _blobServiceClient = new BlobServiceClient(globalSettings.Attachment.ConnectionString);
_logger = logger;
} }
public async Task<string> GetAttachmentDownloadUrlAsync(Cipher cipher, CipherAttachment.MetaData attachmentData) public async Task<string> GetAttachmentDownloadUrlAsync(Cipher cipher, CipherAttachment.MetaData attachmentData)
@ -226,6 +231,7 @@ namespace Bit.Core.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Unhandled error in ValidateFileAsync");
return (false, null); return (false, null);
} }
} }

View File

@ -8,6 +8,7 @@ using Azure.Storage.Sas;
using Bit.Core.Entities; using Bit.Core.Entities;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Settings; using Bit.Core.Settings;
using Microsoft.Extensions.Logging;
namespace Bit.Core.Services namespace Bit.Core.Services
{ {
@ -16,6 +17,7 @@ namespace Bit.Core.Services
public const string FilesContainerName = "sendfiles"; public const string FilesContainerName = "sendfiles";
private static readonly TimeSpan _downloadLinkLiveTime = TimeSpan.FromMinutes(1); private static readonly TimeSpan _downloadLinkLiveTime = TimeSpan.FromMinutes(1);
private readonly BlobServiceClient _blobServiceClient; private readonly BlobServiceClient _blobServiceClient;
private readonly ILogger<AzureSendFileStorageService> _logger;
private BlobContainerClient _sendFilesContainerClient; private BlobContainerClient _sendFilesContainerClient;
public FileUploadType FileUploadType => FileUploadType.Azure; public FileUploadType FileUploadType => FileUploadType.Azure;
@ -24,9 +26,11 @@ namespace Bit.Core.Services
public static string BlobName(Send send, string fileId) => $"{send.Id}/{fileId}"; public static string BlobName(Send send, string fileId) => $"{send.Id}/{fileId}";
public AzureSendFileStorageService( public AzureSendFileStorageService(
GlobalSettings globalSettings) GlobalSettings globalSettings,
ILogger<AzureSendFileStorageService> logger)
{ {
_blobServiceClient = new BlobServiceClient(globalSettings.Send.ConnectionString); _blobServiceClient = new BlobServiceClient(globalSettings.Send.ConnectionString);
_logger = logger;
} }
public async Task UploadNewFileAsync(Stream stream, Send send, string fileId) public async Task UploadNewFileAsync(Stream stream, Send send, string fileId)
@ -125,6 +129,7 @@ namespace Bit.Core.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Unhandled error in ValidateFileAsync");
return (false, null); return (false, null);
} }
} }

View File

@ -25,8 +25,8 @@ namespace Bit.Core.Services
private readonly GlobalSettings _globalSettings; private readonly GlobalSettings _globalSettings;
private readonly IMailDeliveryService _mailDeliveryService; private readonly IMailDeliveryService _mailDeliveryService;
private readonly IMailEnqueuingService _mailEnqueuingService; private readonly IMailEnqueuingService _mailEnqueuingService;
private readonly Dictionary<string, Func<object, string>> _templateCache = private readonly Dictionary<string, HandlebarsTemplate<object, object>> _templateCache =
new Dictionary<string, Func<object, string>>(); new Dictionary<string, HandlebarsTemplate<object, object>>();
private bool _registeredHelpersAndPartials = false; private bool _registeredHelpersAndPartials = false;

View File

@ -851,7 +851,7 @@ namespace Bit.Core.Services
if (userCount > license.Seats.Value) if (userCount > license.Seats.Value)
{ {
throw new BadRequestException($"Your organization currently has {userCount} seats filled. " + throw new BadRequestException($"Your organization currently has {userCount} seats filled. " +
$"Your new license only has ({ license.Seats.Value}) seats. Remove some users."); $"Your new license only has ({license.Seats.Value}) seats. Remove some users.");
} }
} }

View File

@ -161,8 +161,9 @@ namespace Bit.Core.Services
} }
} }
} }
catch (Exception e) catch (Exception ex)
{ {
_logger.LogError(ex, "Error creating customer, walking back operation.");
if (customer != null) if (customer != null)
{ {
await _stripeAdapter.CustomerDeleteAsync(customer.Id); await _stripeAdapter.CustomerDeleteAsync(customer.Id);

View File

@ -21,12 +21,12 @@ namespace Bit.Core.Utilities
IMemoryCache memoryCache, IMemoryCache memoryCache,
IBlockIpService blockIpService, IBlockIpService blockIpService,
RequestDelegate next, RequestDelegate next,
IProcessingStrategy processingStrategy,
IRateLimitConfiguration rateLimitConfiguration,
IOptions<IpRateLimitOptions> options, IOptions<IpRateLimitOptions> options,
IRateLimitCounterStore counterStore,
IIpPolicyStore policyStore, IIpPolicyStore policyStore,
ILogger<CustomIpRateLimitMiddleware> logger, ILogger<CustomIpRateLimitMiddleware> logger)
IIpAddressParser ipParser = null) : base(next, processingStrategy, options, policyStore, rateLimitConfiguration, logger)
: base(next, options, counterStore, policyStore, logger, ipParser)
{ {
_memoryCache = memoryCache; _memoryCache = memoryCache;
_blockIpService = blockIpService; _blockIpService = blockIpService;
@ -44,7 +44,7 @@ namespace Bit.Core.Utilities
return httpContext.Response.WriteAsJsonAsync(errorModel, cancellationToken: httpContext.RequestAborted); return httpContext.Response.WriteAsJsonAsync(errorModel, cancellationToken: httpContext.RequestAborted);
} }
public override void LogBlockedRequest(HttpContext httpContext, ClientRequestIdentity identity, protected override void LogBlockedRequest(HttpContext httpContext, ClientRequestIdentity identity,
RateLimitCounter counter, RateLimitRule rule) RateLimitCounter counter, RateLimitRule rule)
{ {
base.LogBlockedRequest(httpContext, identity, counter, rule); base.LogBlockedRequest(httpContext, identity, counter, rule);

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

View File

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AngleSharp" Version="0.14.0" /> <PackageReference Include="AngleSharp" Version="0.16.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

View File

@ -44,6 +44,10 @@ namespace Bit.Identity
{ {
services.Configure<IpRateLimitOptions>(Configuration.GetSection("IpRateLimitOptions")); services.Configure<IpRateLimitOptions>(Configuration.GetSection("IpRateLimitOptions"));
services.Configure<IpRateLimitPolicies>(Configuration.GetSection("IpRateLimitPolicies")); services.Configure<IpRateLimitPolicies>(Configuration.GetSection("IpRateLimitPolicies"));
// Ref: https://github.com/stefanprodan/AspNetCoreRateLimit/issues/216
services.AddSingleton<IProcessingStrategy, AsyncKeyLockProcessingStrategy>();
// Ref: https://github.com/stefanprodan/AspNetCoreRateLimit/issues/66
services.AddSingleton<IRateLimitConfiguration, RateLimitConfiguration>();
} }
// Data Protection // Data Protection

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" /> <ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.SqlClient;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Core.Entities.Provider; using Bit.Core.Entities.Provider;
@ -8,7 +9,6 @@ using Bit.Core.Models.Data;
using Bit.Core.Repositories; using Bit.Core.Repositories;
using Bit.Core.Settings; using Bit.Core.Settings;
using Dapper; using Dapper;
using Microsoft.Data.SqlClient;
namespace Bit.Infrastructure.Dapper.Repositories namespace Bit.Infrastructure.Dapper.Repositories
{ {

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.SqlClient;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Core.Entities.Provider; using Bit.Core.Entities.Provider;
@ -10,7 +11,6 @@ using Bit.Core.Repositories;
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Dapper; using Dapper;
using Microsoft.Data.SqlClient;
namespace Bit.Infrastructure.Dapper.Repositories namespace Bit.Infrastructure.Dapper.Repositories
{ {

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="linq2db.EntityFrameworkCore" Version="5.2.1" /> <PackageReference Include="linq2db.EntityFrameworkCore" Version="6.7.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.12" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.3" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

View File

@ -5,8 +5,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="5.0.9" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="6.0.4" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="5.0.9" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="6.0.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Infrastructure.Dapper\Infrastructure.Dapper.csproj" /> <ProjectReference Include="..\Infrastructure.Dapper\Infrastructure.Dapper.csproj" />
<ProjectReference Include="..\Core\Core.csproj" /> <ProjectReference Include="..\Core\Core.csproj" />

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Security.Claims; using System.Security.Claims;
@ -599,7 +600,7 @@ namespace Bit.SharedWeb.Utilities
{ {
options.ServerDomain = new Uri(globalSettings.BaseServiceUri.Vault).Host; options.ServerDomain = new Uri(globalSettings.BaseServiceUri.Vault).Host;
options.ServerName = "Bitwarden"; options.ServerName = "Bitwarden";
options.Origin = globalSettings.BaseServiceUri.Vault; options.Origins = new HashSet<string> { globalSettings.BaseServiceUri.Vault, };
options.TimestampDriftTolerance = 300000; options.TimestampDriftTolerance = 300000;
}); });
} }

File diff suppressed because it is too large Load Diff

View File

@ -5,18 +5,18 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3"> <PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="NSubstitute" Version="4.2.2" /> <PackageReference Include="NSubstitute" Version="$(NSubstitueVersion)" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2"> <PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="AutoFixture.Xunit2" Version="4.14.0" /> <PackageReference Include="AutoFixture.Xunit2" Version="$(AutoFixtureXUnit2Version)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -5,18 +5,18 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> <PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0"> <PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="AutoFixture.Xunit2" Version="4.14.0" /> <PackageReference Include="AutoFixture.Xunit2" Version="$(AutoFixtureXUnit2Version)" />
<PackageReference Include="NSubstitute" Version="4.2.2" /> <PackageReference Include="NSubstitute" Version="$(NSubstitueVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -3,16 +3,17 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<RootNamespace>Bit.Test.Common</RootNamespace> <RootNamespace>Bit.Test.Common</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="NSubstitute" Version="4.2.2"/> <ItemGroup>
<PackageReference Include="xunit" Version="2.4.1"/> <PackageReference Include="NSubstitute" Version="$(NSubstitueVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2"> <PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="AutoFixture.Xunit2" Version="4.14.0"/> <PackageReference Include="AutoFixture.Xunit2" Version="$(AutoFixtureXUnit2Version)" />
<PackageReference Include="AutoFixture.AutoNSubstitute" Version="4.14.0"/> <PackageReference Include="AutoFixture.AutoNSubstitute" Version="$(AutoFixtureAutoNSubstituteVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1"/> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="Kralizek.AutoFixture.Extensions.MockHttp" Version="1.2.0"/> <PackageReference Include="Kralizek.AutoFixture.Extensions.MockHttp" Version="1.2.0"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -4,20 +4,20 @@
<RootNamespace>Bit.Core.Test</RootNamespace> <RootNamespace>Bit.Core.Test</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3"> <PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1"/> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="Moq" Version="4.16.1"/> <PackageReference Include="Moq" Version="4.17.2" />
<PackageReference Include="NSubstitute" Version="4.2.2"/> <PackageReference Include="NSubstitute" Version="$(NSubstitueVersion)" />
<PackageReference Include="xunit" Version="2.4.1"/> <PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2"> <PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="AutoFixture.Xunit2" Version="4.14.0"/> <PackageReference Include="AutoFixture.Xunit2" Version="$(AutoFixtureXUnit2Version)" />
<PackageReference Include="AutoFixture.AutoNSubstitute" Version="4.14.0"/> <PackageReference Include="AutoFixture.AutoNSubstitute" Version="$(AutoFixtureAutoNSubstituteVersion)" />
<PackageReference Include="Kralizek.AutoFixture.Extensions.MockHttp" Version="1.2.0"/> <PackageReference Include="Kralizek.AutoFixture.Extensions.MockHttp" Version="1.2.0"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -72,9 +72,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
} }
[CiSkippedTheory, EfUserCipherAutoData] [CiSkippedTheory, EfUserCipherAutoData]
public async void CreateAsync_BumpsUserAccountRevisionDate(Cipher cipher, User user, public async void CreateAsync_BumpsUserAccountRevisionDate(Cipher cipher, User user, List<EfRepo.CipherRepository> suts, List<EfRepo.UserRepository> efUserRepos)
CipherCompare equalityComparer, List<EfRepo.CipherRepository> suts, List<EfRepo.UserRepository> efUserRepos,
SqlRepo.CipherRepository sqlCipherRepo, SqlRepo.UserRepository sqlUserRepo)
{ {
var bumpedUsers = new List<User>(); var bumpedUsers = new List<User>();
foreach (var sut in suts) foreach (var sut in suts)
@ -98,8 +96,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
[CiSkippedTheory, EfOrganizationCipherAutoData] [CiSkippedTheory, EfOrganizationCipherAutoData]
public async void CreateAsync_BumpsOrgUserAccountRevisionDates(Cipher cipher, List<User> users, public async void CreateAsync_BumpsOrgUserAccountRevisionDates(Cipher cipher, List<User> users,
List<OrganizationUser> orgUsers, Collection collection, Organization org, CipherCompare equalityComparer, List<OrganizationUser> orgUsers, Collection collection, Organization org, List<EfRepo.CipherRepository> suts, List<EfRepo.UserRepository> efUserRepos, List<EfRepo.OrganizationRepository> efOrgRepos,
List<EfRepo.CipherRepository> suts, List<EfRepo.UserRepository> efUserRepos, List<EfRepo.OrganizationRepository> efOrgRepos,
List<EfRepo.OrganizationUserRepository> efOrgUserRepos, List<EfRepo.CollectionRepository> efCollectionRepos) List<EfRepo.OrganizationUserRepository> efOrgUserRepos, List<EfRepo.CollectionRepository> efCollectionRepos)
{ {
var savedCiphers = new List<Cipher>(); var savedCiphers = new List<Cipher>();

View File

@ -66,8 +66,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
[CiSkippedTheory, EfOrganizationAutoData] [CiSkippedTheory, EfOrganizationAutoData]
public async void DeleteAsync_Works_DataMatches(Organization organization, public async void DeleteAsync_Works_DataMatches(Organization organization,
SqlRepo.OrganizationRepository sqlOrganizationRepo, OrganizationCompare equalityComparer, SqlRepo.OrganizationRepository sqlOrganizationRepo, List<EfRepo.OrganizationRepository> suts)
List<EfRepo.OrganizationRepository> suts)
{ {
foreach (var sut in suts) foreach (var sut in suts)
{ {
@ -118,8 +117,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
[CiSkippedTheory, EfOrganizationAutoData] [CiSkippedTheory, EfOrganizationAutoData]
public async void GetManyByEnabledAsync_Works_DataMatches(Organization organization, public async void GetManyByEnabledAsync_Works_DataMatches(Organization organization,
SqlRepo.OrganizationRepository sqlOrganizationRepo, OrganizationCompare equalityCompare, SqlRepo.OrganizationRepository sqlOrganizationRepo, List<EfRepo.OrganizationRepository> suts)
List<EfRepo.OrganizationRepository> suts)
{ {
var returnedOrgs = new List<Organization>(); var returnedOrgs = new List<Organization>();
foreach (var sut in suts) foreach (var sut in suts)
@ -139,9 +137,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
// testing data matches here would require manipulating all organization abilities in the db // testing data matches here would require manipulating all organization abilities in the db
[CiSkippedTheory, EfOrganizationAutoData] [CiSkippedTheory, EfOrganizationAutoData]
public async void GetManyAbilitiesAsync_Works(Organization organization, public async void GetManyAbilitiesAsync_Works(SqlRepo.OrganizationRepository sqlOrganizationRepo, List<EfRepo.OrganizationRepository> suts)
SqlRepo.OrganizationRepository sqlOrganizationRepo, OrganizationCompare equalityComparer,
List<EfRepo.OrganizationRepository> suts)
{ {
var list = new List<OrganizationAbility>(); var list = new List<OrganizationAbility>();
foreach (var sut in suts) foreach (var sut in suts)

View File

@ -106,8 +106,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
} }
[CiSkippedTheory, EfOrganizationUserAutoData] [CiSkippedTheory, EfOrganizationUserAutoData]
public async void DeleteAsync_Works_DataMatches(OrganizationUser orgUser, User user, Organization org, public async void DeleteAsync_Works_DataMatches(OrganizationUser orgUser, User user, Organization org, List<EfRepo.OrganizationUserRepository> suts,
OrganizationUserCompare equalityComparer, List<EfRepo.OrganizationUserRepository> suts,
List<EfRepo.UserRepository> efUserRepos, List<EfRepo.OrganizationRepository> efOrgRepos, List<EfRepo.UserRepository> efUserRepos, List<EfRepo.OrganizationRepository> efOrgRepos,
SqlRepo.OrganizationUserRepository sqlOrgUserRepo, SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationUserRepository sqlOrgUserRepo, SqlRepo.UserRepository sqlUserRepo,
SqlRepo.OrganizationRepository sqlOrgRepo) SqlRepo.OrganizationRepository sqlOrgRepo)

View File

@ -97,8 +97,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
} }
[CiSkippedTheory, EfSsoConfigAutoData] [CiSkippedTheory, EfSsoConfigAutoData]
public async void DeleteAsync_Works_DataMatches(SsoConfig ssoConfig, Organization org, public async void DeleteAsync_Works_DataMatches(SsoConfig ssoConfig, Organization org, List<EfRepo.SsoConfigRepository> suts,
SsoConfigCompare equalityComparer, List<EfRepo.SsoConfigRepository> suts,
List<EfRepo.OrganizationRepository> efOrgRepos, SqlRepo.SsoConfigRepository sqlSsoConfigRepo, List<EfRepo.OrganizationRepository> efOrgRepos, SqlRepo.SsoConfigRepository sqlSsoConfigRepo,
SqlRepo.OrganizationRepository sqlOrganizationRepo) SqlRepo.OrganizationRepository sqlOrganizationRepo)
{ {
@ -211,7 +210,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
// Testing that data matches here would involve manipulating all SsoConfig records in the db // Testing that data matches here would involve manipulating all SsoConfig records in the db
[CiSkippedTheory, EfSsoConfigAutoData] [CiSkippedTheory, EfSsoConfigAutoData]
public async void GetManyByRevisionNotBeforeDate_Works(SsoConfig ssoConfig, DateTime notBeforeDate, public async void GetManyByRevisionNotBeforeDate_Works(SsoConfig ssoConfig, DateTime notBeforeDate,
Organization org, SsoConfigCompare equalityComparer, List<EfRepo.SsoConfigRepository> suts, Organization org, List<EfRepo.SsoConfigRepository> suts,
List<EfRepo.OrganizationRepository> efOrgRepos) List<EfRepo.OrganizationRepository> efOrgRepos)
{ {
foreach (var sut in suts) foreach (var sut in suts)

View File

@ -102,8 +102,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
} }
[CiSkippedTheory, EfSsoUserAutoData] [CiSkippedTheory, EfSsoUserAutoData]
public async void DeleteAsync_Works_DataMatches(SsoUser ssoUser, Organization org, User user, public async void DeleteAsync_Works_DataMatches(SsoUser ssoUser, Organization org, User user, List<EfRepo.SsoUserRepository> suts,
SsoUserCompare equalityComparer, List<EfRepo.SsoUserRepository> suts,
List<EfRepo.UserRepository> efUserRepos, List<EfRepo.OrganizationRepository> efOrgRepos, List<EfRepo.UserRepository> efUserRepos, List<EfRepo.OrganizationRepository> efOrgRepos,
SqlRepo.SsoUserRepository sqlSsoUserRepo, SqlRepo.UserRepository sqlUserRepo, SqlRepo.SsoUserRepository sqlSsoUserRepo, SqlRepo.UserRepository sqlUserRepo,
SqlRepo.OrganizationRepository sqlOrganizationRepo) SqlRepo.OrganizationRepository sqlOrganizationRepo)
@ -146,7 +145,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
[CiSkippedTheory, EfSsoUserAutoData] [CiSkippedTheory, EfSsoUserAutoData]
public async void DeleteAsync_UserIdOrganizationId_Works_DataMatches(SsoUser ssoUser, public async void DeleteAsync_UserIdOrganizationId_Works_DataMatches(SsoUser ssoUser,
User user, Organization org, SsoUserCompare equalityComparer, List<EfRepo.SsoUserRepository> suts, User user, Organization org, List<EfRepo.SsoUserRepository> suts,
List<EfRepo.UserRepository> efUserRepos, List<EfRepo.OrganizationRepository> efOrgRepos, List<EfRepo.UserRepository> efUserRepos, List<EfRepo.OrganizationRepository> efOrgRepos,
SqlRepo.SsoUserRepository sqlSsoUserRepo, SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationRepository sqlOrgRepo SqlRepo.SsoUserRepository sqlSsoUserRepo, SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationRepository sqlOrgRepo
) )

View File

@ -65,8 +65,7 @@ namespace Bit.Core.Test.Repositories.EntityFramework
} }
[CiSkippedTheory, EfUserAutoData] [CiSkippedTheory, EfUserAutoData]
public async void DeleteAsync_Works_DataMatches(User user, UserCompare equalityComparer, public async void DeleteAsync_Works_DataMatches(User user, List<EfRepo.UserRepository> suts, SqlRepo.UserRepository sqlUserRepo)
List<EfRepo.UserRepository> suts, SqlRepo.UserRepository sqlUserRepo)
{ {
foreach (var sut in suts) foreach (var sut in suts)
{ {

View File

@ -1,6 +1,7 @@
using System; using System;
using Bit.Core.Services; using Bit.Core.Services;
using Bit.Core.Settings; using Bit.Core.Settings;
using Microsoft.Extensions.Logging;
using NSubstitute; using NSubstitute;
using Xunit; using Xunit;
@ -11,12 +12,14 @@ namespace Bit.Core.Test.Services
private readonly AzureAttachmentStorageService _sut; private readonly AzureAttachmentStorageService _sut;
private readonly GlobalSettings _globalSettings; private readonly GlobalSettings _globalSettings;
private readonly ILogger<AzureAttachmentStorageService> _logger;
public AzureAttachmentStorageServiceTests() public AzureAttachmentStorageServiceTests()
{ {
_globalSettings = new GlobalSettings(); _globalSettings = new GlobalSettings();
_logger = Substitute.For<ILogger<AzureAttachmentStorageService>>();
_sut = new AzureAttachmentStorageService(_globalSettings); _sut = new AzureAttachmentStorageService(_globalSettings, _logger);
} }
// Remove this test when we add actual tests. It only proves that // Remove this test when we add actual tests. It only proves that

View File

@ -35,8 +35,7 @@ namespace Bit.Core.Test.Services
[Theory, CollectionAutoData] [Theory, CollectionAutoData]
public async Task SaveAsync_DefaultIdWithGroups_CreateCollectionWithGroupsInRepository(Collection collection, public async Task SaveAsync_DefaultIdWithGroups_CreateCollectionWithGroupsInRepository(Collection collection,
IEnumerable<SelectionReadOnly> groups, Organization organization, OrganizationUser organizationUser, IEnumerable<SelectionReadOnly> groups, Organization organization, SutProvider<CollectionService> sutProvider)
SutProvider<CollectionService> sutProvider)
{ {
collection.Id = default; collection.Id = default;
organization.UseGroups = true; organization.UseGroups = true;
@ -70,7 +69,7 @@ namespace Bit.Core.Test.Services
[Theory, CollectionAutoData] [Theory, CollectionAutoData]
public async Task SaveAsync_OrganizationNotUseGroup_CreateCollectionWithoutGroupsInRepository(Collection collection, IEnumerable<SelectionReadOnly> groups, public async Task SaveAsync_OrganizationNotUseGroup_CreateCollectionWithoutGroupsInRepository(Collection collection, IEnumerable<SelectionReadOnly> groups,
Organization organization, OrganizationUser organizationUser, SutProvider<CollectionService> sutProvider) Organization organization, SutProvider<CollectionService> sutProvider)
{ {
collection.Id = default; collection.Id = default;
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organization.Id).Returns(organization); sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organization.Id).Returns(organization);
@ -120,7 +119,7 @@ namespace Bit.Core.Test.Services
} }
[Theory, CollectionAutoData] [Theory, CollectionAutoData]
public async Task SaveAsync_ExceedsOrganizationMaxCollections_ThrowsBadRequest(Collection collection, Collection collection1, Collection collection2, Organization organization, SutProvider<CollectionService> sutProvider) public async Task SaveAsync_ExceedsOrganizationMaxCollections_ThrowsBadRequest(Collection collection, Organization organization, SutProvider<CollectionService> sutProvider)
{ {
collection.Id = default; collection.Id = default;
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organization.Id).Returns(organization); sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organization.Id).Returns(organization);

View File

@ -68,7 +68,7 @@ namespace Bit.Core.Test.Services
} }
[Theory, CustomAutoData(typeof(SutProviderCustomization))] [Theory, CustomAutoData(typeof(SutProviderCustomization))]
public async Task SaveAsync_NonExistingOrganizationId_ThrowsBadRequest(Group group, Organization organization, SutProvider<GroupService> sutProvider) public async Task SaveAsync_NonExistingOrganizationId_ThrowsBadRequest(Group group, SutProvider<GroupService> sutProvider)
{ {
var exception = await Assert.ThrowsAsync<BadRequestException>( var exception = await Assert.ThrowsAsync<BadRequestException>(
() => sutProvider.Sut.SaveAsync(group)); () => sutProvider.Sut.SaveAsync(group));

View File

@ -869,7 +869,7 @@ namespace Bit.Core.Test.Services
[InlinePaidOrganizationAutoData(0, null, 100, true, "")] [InlinePaidOrganizationAutoData(0, null, 100, true, "")]
[InlinePaidOrganizationAutoData(1, 100, null, true, "")] [InlinePaidOrganizationAutoData(1, 100, null, true, "")]
[InlinePaidOrganizationAutoData(1, 100, 100, false, "Cannot invite new users. Seat limit has been reached")] [InlinePaidOrganizationAutoData(1, 100, 100, false, "Cannot invite new users. Seat limit has been reached")]
public async Task CanScale(int seatsToAdd, int? currentSeats, int? maxAutoscaleSeats, public void CanScale(int seatsToAdd, int? currentSeats, int? maxAutoscaleSeats,
bool expectedResult, string expectedFailureMessage, Organization organization, bool expectedResult, string expectedFailureMessage, Organization organization,
SutProvider<OrganizationService> sutProvider) SutProvider<OrganizationService> sutProvider)
{ {
@ -891,7 +891,7 @@ namespace Bit.Core.Test.Services
} }
[Theory, PaidOrganizationAutoData] [Theory, PaidOrganizationAutoData]
public async Task CanScale_FailsOnSelfHosted(Organization organization, public void CanScale_FailsOnSelfHosted(Organization organization,
SutProvider<OrganizationService> sutProvider) SutProvider<OrganizationService> sutProvider)
{ {
sutProvider.GetDependency<IGlobalSettings>().SelfHosted.Returns(true); sutProvider.GetDependency<IGlobalSettings>().SelfHosted.Returns(true);

View File

@ -495,8 +495,6 @@ namespace Bit.Core.Test.Services
send.UserId = user.Id; send.UserId = user.Id;
send.Type = SendType.File; send.Type = SendType.File;
var testUrl = "https://test.com/";
sutProvider.GetDependency<IUserRepository>() sutProvider.GetDependency<IUserRepository>()
.GetByIdAsync(user.Id) .GetByIdAsync(user.Id)
.Returns(user); .Returns(user);

File diff suppressed because it is too large Load Diff

View File

@ -5,14 +5,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3"> <PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="NSubstitute" Version="4.2.2" /> <PackageReference Include="NSubstitute" Version="$(NSubstitueVersion)" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> <PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

View File

@ -14,7 +14,7 @@ namespace Bit.Icons.Test.Services
[InlineData("neverssl.com")] // http site [InlineData("neverssl.com")] // http site
[InlineData("ameritrade.com")] [InlineData("ameritrade.com")]
[InlineData("icloud.com")] [InlineData("icloud.com")]
[InlineData("bofa.com")] [InlineData("bofa.com", Skip = "Broken in pipeline for .NET 6. Tracking link: https://bitwarden.atlassian.net/browse/PS-982")]
public async Task GetIconAsync_Success(string domain) public async Task GetIconAsync_Success(string domain)
{ {
var sut = new IconFetchingService(GetLogger()); var sut = new IconFetchingService(GetLogger());

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -71,7 +72,7 @@ namespace Bit.Identity.IntegrationTest.Endpoints
{ "grant_type", "password" }, { "grant_type", "password" },
{ "username", username }, { "username", username },
{ "password", "master_password_hash" }, { "password", "master_password_hash" },
}), context => context.Request.Headers.Add("Auth-Email", CoreHelpers.Base64UrlEncodeString(username))); }), context => context.SetAuthEmail(username));
using var body = await AssertDefaultTokenBodyAsync(context); using var body = await AssertDefaultTokenBodyAsync(context);
var root = body.RootElement; var root = body.RootElement;
@ -174,7 +175,7 @@ namespace Bit.Identity.IntegrationTest.Endpoints
{ "grant_type", "password" }, { "grant_type", "password" },
{ "username", username }, { "username", username },
{ "password", "master_password_hash" }, { "password", "master_password_hash" },
}), context => context.Request.Headers.Add("Auth-Email", CoreHelpers.Base64UrlEncodeString("bad_value"))); }), context => context.SetAuthEmail("bad_value"));
Assert.Equal(StatusCodes.Status400BadRequest, context.Response.StatusCode); Assert.Equal(StatusCodes.Status400BadRequest, context.Response.StatusCode);
@ -399,6 +400,57 @@ namespace Bit.Identity.IntegrationTest.Endpoints
Assert.Equal("invalid_client", error); Assert.Equal("invalid_client", error);
} }
[Fact]
public async Task TokenEndpoint_ToQuickInOneSecond_BlockRequest()
{
const int AmountInOneSecondAllowed = 5;
// The rule we are testing is 10 requests in 1 second
var username = "test+ratelimiting@email.com";
var deviceId = "8f14a393-edfe-40ba-8c67-a856cb89c509";
await _factory.RegisterAsync(new RegisterRequestModel
{
Email = username,
MasterPasswordHash = "master_password_hash",
});
var database = _factory.GetDatabaseContext();
var user = await database.Users
.FirstAsync(u => u.Email == username);
var tasks = new Task<HttpContext>[AmountInOneSecondAllowed + 1];
for (var i = 0; i < AmountInOneSecondAllowed + 1; i++)
{
// Queue all the amount of calls allowed plus 1
tasks[i] = MakeRequest();
}
var responses = await Task.WhenAll(tasks);
var allowedCalls = responses[..AmountInOneSecondAllowed];
var notAllowedCall = responses[^1];
Assert.True(allowedCalls.All(c => c.Response.StatusCode == StatusCodes.Status200OK));
Assert.True(notAllowedCall.Response.StatusCode == StatusCodes.Status429TooManyRequests);
Task<HttpContext> MakeRequest()
{
return _factory.Server.PostAsync("/connect/token", new FormUrlEncodedContent(new Dictionary<string, string>
{
{ "scope", "api offline_access" },
{ "client_id", "web" },
{ "deviceType", DeviceTypeAsString(DeviceType.FirefoxBrowser) },
{ "deviceIdentifier", deviceId },
{ "deviceName", "firefox" },
{ "grant_type", "password" },
{ "username", username },
{ "password", "master_password_hash" },
}), context => context.SetAuthEmail(username).SetIp("1.1.1.2"));
}
}
private static string DeviceTypeAsString(DeviceType deviceType) private static string DeviceTypeAsString(DeviceType deviceType)
{ {
return ((int)deviceType).ToString(); return ((int)deviceType).ToString();

View File

@ -5,19 +5,19 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3"> <PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.15" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="NSubstitute" Version="4.2.2" /> <PackageReference Include="NSubstitute" Version="$(NSubstitueVersion)" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2"> <PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="AutoFixture.Xunit2" Version="4.14.0" /> <PackageReference Include="AutoFixture.Xunit2" Version="$(AutoFixtureXUnit2Version)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -59,7 +59,7 @@ namespace Bit.Identity.Test.Controllers
[Fact] [Fact]
public async Task PostPrelogin_WhenUserDoesNotExist_ShouldDefaultToSha256And100000Iterations() public async Task PostPrelogin_WhenUserDoesNotExist_ShouldDefaultToSha256And100000Iterations()
{ {
_userRepository.GetKdfInformationByEmailAsync(Arg.Any<string>()).Returns(Task.FromResult((UserKdfInformation)null)); _userRepository.GetKdfInformationByEmailAsync(Arg.Any<string>()).Returns(Task.FromResult<UserKdfInformation>(null!));
var response = await _sut.PostPrelogin(new PreloginRequestModel { Email = "user@example.com" }); var response = await _sut.PostPrelogin(new PreloginRequestModel { Email = "user@example.com" });
@ -112,4 +112,3 @@ namespace Bit.Identity.Test.Controllers
} }
} }
} }

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -6,18 +6,18 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3"> <PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="NSubstitute" Version="4.2.2" /> <PackageReference Include="NSubstitute" Version="$(NSubstitueVersion)" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2"> <PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="AutoFixture.Xunit2" Version="4.14.0" /> <PackageReference Include="AutoFixture.Xunit2" Version="$(AutoFixtureXUnit2Version)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
@ -50,6 +51,19 @@ namespace Bit.IntegrationTestCommon.Factories
string requestUri, string requestUri,
Action<HttpContext> extraConfiguration = null) Action<HttpContext> extraConfiguration = null)
=> SendAsync(server, HttpMethod.Get, requestUri, content: null, extraConfiguration); => SendAsync(server, HttpMethod.Get, requestUri, content: null, extraConfiguration);
public static HttpContext SetAuthEmail(this HttpContext context, string username)
{
context.Request.Headers.Add("Auth-Email", CoreHelpers.Base64UrlEncodeString(username));
return context;
}
public static HttpContext SetIp(this HttpContext context, string ip)
{
context.Connection.RemoteIpAddress = IPAddress.Parse(ip);
return context;
}
public static async Task<string> ReadBodyAsStringAsync(this HttpContext context) public static async Task<string> ReadBodyAsStringAsync(this HttpContext context)
{ {
using var sr = new StreamReader(context.Response.Body); using var sr = new StreamReader(context.Response.Body);

View File

@ -5,9 +5,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.15" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.15" /> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.5" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="dbup-sqlserver" Version="4.4.0" /> <PackageReference Include="dbup-sqlserver" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>9f1cd3e0-70f2-4921-8068-b2538fd7c3f7</UserSecretsId> <UserSecretsId>9f1cd3e0-70f2-4921-8068-b2538fd7c3f7</UserSecretsId>
</PropertyGroup> </PropertyGroup>
@ -11,7 +10,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.9"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Core\Core.csproj" /> <ProjectReference Include="..\..\src\Core\Core.csproj" />
<ProjectReference Include="..\..\src\Api\Api.csproj" /> <ProjectReference Include="..\..\src\Api\Api.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.9"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" LABEL com.bitwarden.product="bitwarden"

View File

@ -1,6 +1,6 @@
{ {
"version": 1, "version": 1,
"dependencies": { "dependencies": {
".NETCoreApp,Version=v5.0": {} "net6.0": {}
} }
} }

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 FROM mcr.microsoft.com/dotnet/aspnet:6.0
LABEL com.bitwarden.product="bitwarden" com.bitwarden.project="setup" LABEL com.bitwarden.product="bitwarden" com.bitwarden.project="setup"

View File

@ -181,7 +181,7 @@ namespace Bit.Setup
Console.ResetColor(); Console.ResetColor();
} }
public static Func<object, string> ReadTemplate(string templateName) public static HandlebarsDotNet.HandlebarsTemplate<object, object> ReadTemplate(string templateName)
{ {
var assembly = typeof(Helpers).GetTypeInfo().Assembly; var assembly = typeof(Helpers).GetTypeInfo().Assembly;
var fullTemplateName = $"Bit.Setup.Templates.{templateName}.hbs"; var fullTemplateName = $"Bit.Setup.Templates.{templateName}.hbs";

View File

@ -10,9 +10,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Handlebars.Net" Version="1.10.1" /> <PackageReference Include="Handlebars.Net" Version="2.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="YamlDotNet" Version="8.1.2" /> <PackageReference Include="YamlDotNet" Version="11.2.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

File diff suppressed because it is too large Load Diff