Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SM-495] Access Policies - Individual Service Account - Project Tab #2697

Merged
merged 8 commits into from
Feb 16, 2023

Conversation

Thomas-Avery
Copy link
Contributor

@Thomas-Avery Thomas-Avery commented Feb 14, 2023

Type of change

- [ ] Bug fix
- [X] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

The purpose of this PR is to create endpoints required to support the individual service account - projects tab for secrets manager.

Code changes

  • bitwarden_license/src/Commercial.Core/SecretsManager/Commands/AccessPolicies/CreateAccessPoliciesCommand.cs
    bitwarden_license/test/Commercial.Core.Test/SecretsManager/AccessPolicies/CreateAccessPoliciesCommandTests.cs
    src/Core/SecretsManager/Commands/AccessPolicies/Interfaces/ICreateAccessPoliciesCommand.cs

Refactor to just one public method to support new endpoints.

  • bitwarden_license/src/Commercial.Infrastructure.EntityFramework/SecretsManager/Repositories/AccessPolicyRepository.cs
    src/Core/SecretsManager/Repositories/IAccessPolicyRepository.cs

New method for fetch access policies by the service account grantee.

  • src/Api/SecretsManager/Controllers/AccessPoliciesController.cs

Add in three new methods and some refactoring.

[HttpGet("/service-accounts/{id}/granted-policies")]

Fetch access policies where the service account is the grantee

[HttpPost("/service-accounts/{id}/granted-policies")]

Create access policies where the service account is the grantee

[HttpGet("/organizations/{id}/access-policies/projects/potential-grantees")]

Fetch projects that could potentially be used in access policy creation.

  • src/Api/SecretsManager/Models/Request/GrantedAccessPolicyRequest.cs

New request model for creation endpoint.

  • src/Api/SecretsManager/Models/Response/AccessPolicyResponseModel.cs

Add granted project name for responses.

  • src/Api/SecretsManager/Models/Response/PotentialGranteeResponseModel.cs

Add projects as a potential target

  • src/Core/SecretsManager/Repositories/IProjectRepository.cs
    bitwarden_license/src/Commercial.Infrastructure.EntityFramework/SecretsManager/Repositories/ProjectRepository.cs

New method for fetching projects that the user has write permissions to.

  • test/Api.Test/SecretsManager/Controllers/AccessPoliciesControllerTests.cs
    test/Api.IntegrationTest/SecretsManager/Controllers/AccessPoliciesControllerTest.cs
    bitwarden_license/test/Commercial.Core.Test/SecretsManager/AccessPolicies/CreateAccessPoliciesCommandTests.cs

Update tests

Before you submit

  • Please check for formatting errors (dotnet format --verify-no-changes) (required)
  • If making database changes - make sure you also update Entity Framework queries and/or migrations
  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team

@Thomas-Avery Thomas-Avery self-assigned this Feb 14, 2023
@Thomas-Avery Thomas-Avery requested a review from a team February 14, 2023 20:01
@Thomas-Avery Thomas-Avery marked this pull request as ready for review February 14, 2023 20:01
@Thomas-Avery Thomas-Avery merged commit f288787 into master Feb 16, 2023
@Thomas-Avery Thomas-Avery deleted the feature/sm-495-sa-projects branch February 16, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants