1
0
mirror of https://github.com/bitwarden/server.git synced 2025-03-12 13:29:14 +01:00
The core infrastructure backend (API, database, Docker, etc).
Go to file
Rui Tomé 6e7c5b172c
[PM-18087] Add cipher permissions to response models (#5418)
* Add Manage permission to UserCipherDetails and CipherDetails_ReadByIdUserId

* Add Manage property to CipherDetails and UserCipherDetailsQuery

* Add integration test for CipherRepository Manage permission rules

* Update CipherDetails_ReadWithoutOrganizationsByUserId to include Manage permission

* Refactor UserCipherDetailsQuery to include detailed permission and organization properties

* Refactor CipherRepositoryTests to improve test organization and readability

- Split large test method into smaller, focused methods
- Added helper methods for creating test data and performing assertions
- Improved test coverage for cipher permissions in different scenarios
- Maintained existing test logic while enhancing code structure

* Refactor CipherRepositoryTests to consolidate cipher permission tests

- Removed redundant helper methods for permission assertions
- Simplified test methods for GetCipherPermissionsForOrganizationAsync, GetManyByUserIdAsync, and GetByIdAsync
- Maintained existing test coverage for cipher manage permissions
- Improved code readability and reduced code duplication

* Add integration test for CipherRepository group collection manage permissions

- Added new test method GetCipherPermissionsForOrganizationAsync_ManageProperty_RespectsCollectionGroupRules
- Implemented helper method CreateCipherInOrganizationCollectionWithGroup to support group-based collection permission testing
- Verified manage permissions are correctly applied based on group collection access settings

* Add @Manage parameter to Cipher stored procedures

- Updated CipherDetails_Create, CipherDetails_CreateWithCollections, and CipherDetails_Update stored procedures
- Added @Manage parameter with comment "-- not used"
- Included new stored procedure implementations in migration script
- Consistent with previous work on adding Manage property to cipher details

* Update UserCipherDetails functions to reorder Manage and ViewPassword columns

* [PM-18086] Add CanRestore and CanDelete authorization methods.

* [PM-18086] Address code review feedback.

* [PM-18086] Add missing part.

* [PM-18087] Add CipherPermissionsResponseModel for cipher permissions

* Add GetManyOrganizationAbilityAsync method to application cache service

* Add organization ability context to cipher response models

This change introduces organization ability context to various cipher response models across multiple controllers. The modifications include:

- Updating CipherResponseModel to include permissions based on user and organization ability
- Modifying CiphersController methods to fetch and pass organization abilities
- Updating SyncController to include organization abilities in sync response
- Adding organization ability context to EmergencyAccessController response generation

* Remove organization ability context from EmergencyAccessController

This change simplifies the EmergencyAccessController by removing unnecessary organization ability fetching and passing. Since emergency access only retrieves personal ciphers, the organization ability context is no longer needed in the response generation.

* Remove unused IApplicationCacheService from EmergencyAccessController

* Refactor EmergencyAccessViewResponseModel constructor

Remove unnecessary JsonConstructor attribute and simplify constructor initialization for EmergencyAccessViewResponseModel

* Refactor organization ability retrieval in CiphersController

Extract methods to simplify organization ability fetching for ciphers, reducing code duplication and improving readability. Added two private helper methods:
- GetOrganizationAbilityAsync: Retrieves organization ability for a single cipher
- GetManyOrganizationAbilitiesAsync: Retrieves organization abilities for multiple ciphers

* Update CiphersControllerTests to use GetUserByPrincipalAsync

Modify test methods to:
- Replace GetProperUserId with GetUserByPrincipalAsync
- Use User object instead of separate userId
- Update mocking to return User object
- Ensure user ID is correctly set in test scenarios

* Refactor CipherPermissionsResponseModel to use constructor-based initialization

* Refactor CipherPermissionsResponseModel to use record type and init-only properties

* [PM-18086] Undo files

* [PM-18086] Undo files

* Refactor organization abilities retrieval in cipher-related controllers and models

- Update CiphersController to use GetOrganizationAbilitiesAsync instead of individual methods
- Modify CipherResponseModel and CipherDetailsResponseModel to accept organization abilities dictionary
- Update CipherPermissionsResponseModel to handle organization abilities lookup
- Remove deprecated organization ability retrieval methods
- Simplify sync and emergency access response model handling of organization abilities

* Remove GetManyOrganizationAbilityAsync method

- Delete unused method from IApplicationCacheService interface
- Remove corresponding implementation in InMemoryApplicationCacheService
- Continues cleanup of organization ability retrieval methods

* Update CiphersControllerTests to include organization abilities retrieval

- Add organization abilities retrieval in test setup for PutCollections_vNext method
- Ensure consistent mocking of IApplicationCacheService in test scenarios

* Update error message for missing organization ability

---------

Co-authored-by: Jimmy Vo <huynhmaivo82@gmail.com>
2025-03-10 15:27:30 +00:00
.checkmarx Exclude dev directory from iac scans (#3807) 2024-02-15 08:53:03 -05:00
.config [deps] Billing: Update swashbuckle-aspnetcore monorepo to v7 (#5069) 2024-12-13 12:42:25 +01:00
.devcontainer Codespaces improvements (#4969) 2025-03-09 16:56:04 -04:00
.git-hooks Add git hook for formating (#2224) 2022-09-08 10:27:17 +02:00
.github Collect Code Coverage In DB Tests (#5431) 2025-02-20 11:19:48 -05:00
.run Add Rider launch configurations (#2646) 2023-01-31 06:20:46 +10:00
.vscode [pm-14415] Add recommended extensions for VS Code. (#5249) 2025-01-14 13:38:32 -05:00
bitwarden_license [PM-12601] Add discount to MSP during creation in Admin Portal (#5391) 2025-03-05 14:59:15 -05:00
dev [PM-17562] Add Azure Service Bus for Distributed Events (#5382) 2025-02-11 10:20:06 -05:00
perf [deps] Billing: Update BenchmarkDotNet to v0.14.0 (#4660) 2024-09-05 09:05:26 -04:00
src [PM-18087] Add cipher permissions to response models (#5418) 2025-03-10 15:27:30 +00:00
test [PM-18087] Add cipher permissions to response models (#5418) 2025-03-10 15:27:30 +00:00
util [PM-18972] - Fix query for Org By User Domain (#5474) 2025-03-07 12:32:21 +10:00
.dockerignore Bitwarden Unified Self-Host project (#2410) 2022-11-18 14:39:01 -05:00
.editorconfig Solution and editor configuration cleanup (#3099) 2023-07-13 17:34:11 -04:00
.git-blame-ignore-revs Add instructions (#2232) 2022-08-30 12:17:17 -04:00
.gitattributes Run dotnet format (#1764) 2021-12-16 15:35:09 +01:00
.gitignore [PM-10261] Migrate from gulp to webpack (#4569) 2024-07-31 15:41:55 -04:00
bitwarden-server.sln Scaffold Events Integration Tests (#5355) 2025-01-31 11:08:07 -05:00
CONTRIBUTING.md Update README and CONTRIBUTING to point to contributing.bitwarden.com (#2028) 2022-06-09 12:00:58 +02:00
Directory.Build.props Bumped version to 2025.3.0 2025-03-10 10:28:50 +00:00
global.json Devcontainer Improvements (#4466) 2024-07-08 10:48:02 -04:00
LICENSE_AGPL.txt split license file out to support bitwarden licensed code (#912) 2020-09-04 13:36:22 -04:00
LICENSE_BITWARDEN.txt Update paths to point to main instead of master (#3699) 2024-01-24 09:48:03 -05:00
LICENSE_FAQ.md Update paths to point to main instead of master (#3699) 2024-01-24 09:48:03 -05:00
LICENSE.txt Update paths to point to main instead of master (#3699) 2024-01-24 09:48:03 -05:00
README.md Adding code block format for README.md (#4695) 2024-08-27 09:23:41 +00:00
SECURITY.md Update SECURITY.md (#1913) 2022-03-15 15:54:08 -04:00
TRADEMARK_GUIDELINES.md Update TRADEMARK_GUIDELINES.md 2021-03-26 14:04:27 -04:00

Bitwarden

Github Workflow build on main DockerHub gitter chat


The Bitwarden Server project contains the APIs, database, and other core infrastructure items needed for the "backend" of all bitwarden client applications.

The server project is written in C# using .NET Core with ASP.NET Core. The database is written in T-SQL/SQL Server. The codebase can be developed, built, run, and deployed cross-platform on Windows, macOS, and Linux distributions.

Developer Documentation

Please refer to the Server Setup Guide in the Contributing Documentation for build instructions, recommended tooling, code style tips, and lots of other great information to get you started.

Deploy

docker

You can deploy Bitwarden using Docker containers on Windows, macOS, and Linux distributions. Use the provided PowerShell and Bash scripts to get started quickly. Find all of the Bitwarden images on Docker Hub.

Full documentation for deploying Bitwarden with Docker can be found in our help center at: https://help.bitwarden.com/article/install-on-premise/

Requirements

These dependencies are free to use.

Linux & macOS

curl -s -L -o bitwarden.sh \
    "https://func.bitwarden.com/api/dl/?app=self-host&platform=linux" \
    && chmod +x bitwarden.sh
./bitwarden.sh install
./bitwarden.sh start

Windows

Invoke-RestMethod -OutFile bitwarden.ps1 `
    -Uri "https://func.bitwarden.com/api/dl/?app=self-host&platform=windows"
.\bitwarden.ps1 -install
.\bitwarden.ps1 -start

We're Hiring!

Interested in contributing in a big way? Consider joining our team! We're hiring for many positions. Please take a look at our Careers page to see what opportunities are currently open as well as what it's like to work at Bitwarden.

Contribute

Code contributions are welcome! Please commit any pull requests against the main branch. Learn more about how to contribute by reading the Contributing Guidelines. Check out the Contributing Documentation for how to get started with your first contribution.

Security audits and feedback are welcome. Please open an issue or email us privately if the report is sensitive in nature. You can read our security policy in the SECURITY.md file. We also run a program on HackerOne.

No grant of any rights in the trademarks, service marks, or logos of Bitwarden is made (except as may be necessary to comply with the notice requirements as applicable), and use of any Bitwarden trademarks must comply with Bitwarden Trademark Guidelines.

Dotnet-format

Consider installing our git pre-commit hook for automatic formatting.

git config --local core.hooksPath .git-hooks