Skip to content

Commit 7d0dde7

Browse files
committed
Merge branch 'main' into jmccannon/ac/pm-32073-bulk-org-ability
# Conflicts: # src/Core/Services/Implementations/FeatureRoutedCacheService.cs
2 parents 0e519bc + 914d412 commit 7d0dde7

131 files changed

Lines changed: 26315 additions & 478 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/_move_edd_db_scripts.yml

Lines changed: 50 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,9 @@ jobs:
2020
copy_edd_scripts: ${{ steps.check-script-existence.outputs.copy_edd_scripts }}
2121

2222
steps:
23-
- name: Log in to Azure
24-
uses: bitwarden/gh-actions/azure-login@main
25-
with:
26-
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
27-
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
28-
client_id: ${{ secrets.AZURE_CLIENT_ID }}
29-
30-
- name: Retrieve secrets
31-
id: retrieve-secrets
32-
uses: bitwarden/gh-actions/get-keyvault-secrets@main
33-
with:
34-
keyvault: "bitwarden-ci"
35-
secrets: "github-pat-bitwarden-devops-bot-repo-scope"
36-
37-
- name: Log out from Azure
38-
uses: bitwarden/gh-actions/azure-logout@main
39-
4023
- name: Check out branch
4124
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4225
with:
43-
token: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }}
4426
persist-credentials: false
4527

4628
- name: Get script prefix
@@ -64,14 +46,46 @@ jobs:
6446
contents: write
6547
pull-requests: write
6648
id-token: write
67-
actions: read
6849
if: ${{ needs.setup.outputs.copy_edd_scripts == 'true' }}
6950
steps:
51+
- name: Log in to Azure
52+
uses: bitwarden/gh-actions/azure-login@main
53+
with:
54+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
55+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
56+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
57+
58+
- name: Retrieve Slack secrets
59+
id: retrieve-slack
60+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
61+
with:
62+
keyvault: "bitwarden-ci"
63+
secrets: "devops-alerts-slack-webhook-url"
64+
65+
- name: Retrieve secrets
66+
id: retrieve-secret
67+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
68+
with:
69+
keyvault: gh-org-bitwarden
70+
secrets: "BW-GHAPP-ID,BW-GHAPP-KEY"
71+
72+
- name: Log out from Azure
73+
uses: bitwarden/gh-actions/azure-logout@main
74+
75+
- name: Generate GH App token
76+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
77+
id: app-token
78+
with:
79+
app-id: ${{ steps.retrieve-secret.outputs.BW-GHAPP-ID }}
80+
private-key: ${{ steps.retrieve-secret.outputs.BW-GHAPP-KEY }}
81+
owner: ${{ github.repository_owner }}
82+
7083
- name: Check out repo
7184
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7285
with:
7386
fetch-depth: 0
7487
persist-credentials: true
88+
token: ${{ steps.app-token.outputs.token }}
7589

7690
- name: Generate branch name
7791
id: branch_name
@@ -82,7 +96,9 @@ jobs:
8296
- name: "Create branch"
8397
env:
8498
BRANCH: ${{ steps.branch_name.outputs.branch_name }}
85-
run: git switch -c "$BRANCH"
99+
run: |
100+
git switch -c "$BRANCH"
101+
git push -u origin "$BRANCH"
86102
87103
- name: Move scripts and finalization database schema
88104
id: move-files
@@ -134,58 +150,32 @@ jobs:
134150
done
135151
136152
echo "moved_files=$moved_files" >> "$GITHUB_OUTPUT"
137-
138-
- name: Log in to Azure
139-
uses: bitwarden/gh-actions/azure-login@main
140-
with:
141-
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
142-
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
143-
client_id: ${{ secrets.AZURE_CLIENT_ID }}
144-
145-
- name: Retrieve secrets
146-
id: retrieve-secrets
147-
uses: bitwarden/gh-actions/get-keyvault-secrets@main
148-
with:
149-
keyvault: "bitwarden-ci"
150-
secrets: "github-gpg-private-key,
151-
github-gpg-private-key-passphrase,
152-
devops-alerts-slack-webhook-url"
153-
154-
- name: Log out from Azure
155-
uses: bitwarden/gh-actions/azure-logout@main
156-
157-
- name: Import GPG keys
158-
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
159-
with:
160-
gpg_private_key: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key }}
161-
passphrase: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key-passphrase }}
162-
git_user_signingkey: true
163-
git_commit_gpgsign: true
164-
165-
- name: Commit and push changes
153+
154+
- name: Check for changes
166155
id: commit
167-
env:
168-
BRANCH_NAME: ${{ steps.branch_name.outputs.branch_name }}
169156
run: |
170-
git config --local user.email "106330231+bitwarden-devops-bot@users.noreply.github.com"
171-
git config --local user.name "bitwarden-devops-bot"
172157
if [ -n "$(git status --porcelain)" ]; then
173-
git add .
174-
git commit -m "Move EDD database scripts" -a
175-
git push -u origin "${BRANCH_NAME}"
176158
echo "pr_needed=true" >> "$GITHUB_OUTPUT"
177159
else
178-
echo "No changes to commit!";
179160
echo "pr_needed=false" >> "$GITHUB_OUTPUT"
180-
echo "### :mega: No changes to commit! PR was ommited." >> "$GITHUB_STEP_SUMMARY"
161+
echo "No changes to commit!"
162+
echo "### :mega: No changes to commit! PR was omitted." >> "$GITHUB_STEP_SUMMARY"
181163
fi
182164
165+
- name: Commit and push changes
166+
if: ${{ steps.commit.outputs.pr_needed == 'true' }}
167+
uses: bitwarden/gh-actions/api-commit@main
168+
with:
169+
token: ${{ steps.app-token.outputs.token }}
170+
branch: ${{ steps.branch_name.outputs.branch_name }}
171+
message: "Move EDD database scripts"
172+
183173
- name: Create PR for ${{ steps.branch_name.outputs.branch_name }}
184174
if: ${{ steps.commit.outputs.pr_needed == 'true' }}
185175
id: create-pr
186176
env:
187177
BRANCH: ${{ steps.branch_name.outputs.branch_name }}
188-
GH_TOKEN: ${{ github.token }}
178+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
189179
MOVED_FILES: ${{ steps.move-files.outputs.moved_files }}
190180
TITLE: "Move EDD database scripts"
191181
run: |
@@ -205,7 +195,7 @@ jobs:
205195
if: ${{ steps.commit.outputs.pr_needed == 'true' }}
206196
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
207197
env:
208-
SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }}
198+
SLACK_WEBHOOK_URL: ${{ steps.retrieve-slack.outputs.devops-alerts-slack-webhook-url }}
209199
with:
210200
message: "Created PR for moving EDD database scripts: ${{ steps.create-pr.outputs.pr_url }}"
211201
status: ${{ job.status }}

.github/workflows/build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,7 @@ jobs:
480480

481481
bitwarden-lite-build:
482482
name: Trigger Bitwarden lite build
483-
if: |
484-
github.event_name != 'pull_request'
485-
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
483+
if: github.event_name != 'pull_request'
486484
runs-on: ubuntu-22.04
487485
needs: build-artifacts
488486
permissions:

.github/workflows/cleanup-rc-branch.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,28 @@ jobs:
2121
client_id: ${{ secrets.AZURE_CLIENT_ID }}
2222

2323
- name: Retrieve bot secrets
24-
id: retrieve-bot-secrets
24+
id: retrieve-secret
2525
uses: bitwarden/gh-actions/get-keyvault-secrets@main
2626
with:
27-
keyvault: bitwarden-ci
28-
secrets: "github-pat-bitwarden-devops-bot-repo-scope"
27+
keyvault: gh-org-bitwarden
28+
secrets: "BW-GHAPP-ID,BW-GHAPP-KEY"
2929

3030
- name: Log out from Azure
3131
uses: bitwarden/gh-actions/azure-logout@main
3232

33+
- name: Generate GH App token
34+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
35+
id: app-token
36+
with:
37+
app-id: ${{ steps.retrieve-secret.outputs.BW-GHAPP-ID }}
38+
private-key: ${{ steps.retrieve-secret.outputs.BW-GHAPP-KEY }}
39+
owner: ${{ github.repository_owner }}
40+
3341
- name: Checkout main
3442
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3543
with:
3644
ref: main
37-
token: ${{ steps.retrieve-bot-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }}
45+
token: ${{ steps.app-token.outputs.token }}
3846
persist-credentials: false
3947
fetch-depth: 0
4048

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
3+
namespace Bit.Api.AdminConsole.Authorization;
4+
5+
/// <summary>
6+
/// A no-op attribute which documents an intentional choice to not use
7+
/// <see cref="AuthorizeAttribute{T}"/> - for example, because you are manually handling
8+
/// authorization in imperative code, or the endpoint does not require authorization.
9+
/// Unlike <see cref="AllowAnonymousAttribute"/>, this does not bypass the class-level <see cref="AuthorizeAttribute"/>;
10+
/// it indicates that no <b>additional</b> authorization is needed.
11+
/// </summary>
12+
[AttributeUsage(AttributeTargets.Method)]
13+
public class NoopAuthorizeAttribute : Attribute;
Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Bit.Core.AdminConsole.Utilities.v2;
22
using Bit.Core.AdminConsole.Utilities.v2.Results;
33
using Bit.Core.Models.Api;
4+
using Microsoft.AspNetCore.Http.HttpResults;
45
using Microsoft.AspNetCore.Mvc;
56

67
namespace Bit.Api.AdminConsole.Controllers;
@@ -11,16 +12,29 @@ protected static IResult Handle(CommandResult commandResult) =>
1112
commandResult.Match<IResult>(
1213
error => error switch
1314
{
14-
BadRequestError badRequest => TypedResults.BadRequest(new ErrorResponseModel(badRequest.Message)),
15-
NotFoundError notFound => TypedResults.NotFound(new ErrorResponseModel(notFound.Message)),
16-
InternalError internalError => TypedResults.Json(
17-
new ErrorResponseModel(internalError.Message),
18-
statusCode: StatusCodes.Status500InternalServerError),
19-
_ => TypedResults.Json(
20-
new ErrorResponseModel(error.Message),
21-
statusCode: StatusCodes.Status500InternalServerError
22-
)
15+
BadRequestError badRequest => Error.BadRequest(badRequest.Message),
16+
NotFoundError notFound => Error.NotFound(notFound.Message),
17+
InternalError internalError => Error.InternalError(internalError.Message),
18+
_ => Error.InternalError(error.Message)
2319
},
2420
_ => TypedResults.NoContent()
2521
);
22+
23+
protected static class Error
24+
{
25+
public static NotFound<ErrorResponseModel> NotFound(string message = "Resource not found.") =>
26+
TypedResults.NotFound(new ErrorResponseModel(message));
27+
28+
public static UnauthorizedHttpResult Unauthorized() =>
29+
TypedResults.Unauthorized();
30+
31+
public static BadRequest<ErrorResponseModel> BadRequest(string message) =>
32+
TypedResults.BadRequest(new ErrorResponseModel(message));
33+
34+
public static JsonHttpResult<ErrorResponseModel> InternalError(
35+
string message = "Something went wrong with your request. Please contact support for assistance.") =>
36+
TypedResults.Json(
37+
new ErrorResponseModel(message),
38+
statusCode: StatusCodes.Status500InternalServerError);
39+
}
2640
}

0 commit comments

Comments
 (0)