Skip to content

Commit b5b44da

Browse files
Update JIT part1 and part 2 (#485)
* update-part2-tuts * update the file names
1 parent abb177e commit b5b44da

24 files changed

+29
-29
lines changed

content/docs/tutorials/just-in-time-part1.md renamed to content/docs/tutorials/just-in-time-database-access-part1.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This tutorial will guide you through setting up Just-in-Time (JIT) access using
1818
This is Part 1 of our tutorial series on implementing Just-in-Time (JIT) access:
1919

2020
- Part 1: JIT database access via Bytebase GUI
21-
- Part 2: [Approve JIT database access via Slack](/docs/tutorials/just-in-time-part2)
21+
- Part 2: [Approve JIT database access via Slack](/docs/tutorials/just-in-time-database-access-part2)
2222
- Part 3: Request JIT database access via Slack
2323

2424
## Prerequisites
@@ -53,7 +53,7 @@ As a developer user, you will not have the access to query the production databa
5353

5454
1. Click `hr_prod`, you will see the SQL Editor icon is greyed out, which means you don't have access to this database in SQL Editor. Even you click **SQL Editor** button on the top bar to navigate to the SQL Editor page, you still don't have access to this database.
5555

56-
![bb-sql-editor-grey](/content/docs/tutorials/just-in-time-part1/bb-sql-editor-grey.webp)
56+
![bb-sql-editor-grey](/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-grey.webp)
5757

5858
## Step 3 - DBA assign you access to the production database (Community and Pro Plan)
5959

@@ -65,11 +65,11 @@ In Bytebase **Community** and **Pro Plan**, the Admin/DBA can assign you access
6565

6666
1. In the **Grant Access** modal, select the `SQL Editor User` role, then set 1 day Expiration, and click **Confirm** button. Here you may notice in Community and Pro Plan, you can only set access to all databases in the project.
6767

68-
![bb-community-grant-query](/content/docs/tutorials/just-in-time-part1/bb-community-grant-query.webp)
68+
![bb-community-grant-query](/content/docs/tutorials/just-in-time-database-access-part1/bb-community-grant-query.webp)
6969

7070
1. After the access is granted, login as the developer user again, you should see the SQL Editor icon is no longer greyed out, which means you have access to the production database in SQL Editor. After one day, the access will expire automatically.
7171

72-
![bb-sql-editor-query](/content/docs/tutorials/just-in-time-part1/bb-sql-editor-query.webp)
72+
![bb-sql-editor-query](/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-query.webp)
7373

7474
## Step 4 - Request a JIT access to the production database (Enterprise Plan)
7575

@@ -81,37 +81,37 @@ In Bytebase **Enterprise Plan**, you can request a JIT access to the production
8181

8282
1. Click **CI/CD** > **Custom Approval** on the left sidebar. Assign licenses to the instances to enable this feature.
8383

84-
![bb-assign-license](/content/docs/tutorials/just-in-time-part1/bb-assign-license.webp)
84+
![bb-assign-license](/content/docs/tutorials/just-in-time-database-access-part1/bb-assign-license.webp)
8585

8686
1. Scroll down to **Request Querier Role** section, add `high` risk an approval flow `Project Owner`.
8787

88-
![bb-custom-approval](/content/docs/tutorials/just-in-time-part1/bb-custom-approval.webp)
88+
![bb-custom-approval](/content/docs/tutorials/just-in-time-database-access-part1/bb-custom-approval.webp)
8989

9090
1. Click **CI/CD** > **Risk Center** on the left sidebar. Define a High risk policy for `Request Querier Role` which triggers when the environment is `Prod`.
9191

92-
![bb-risk-center](/content/docs/tutorials/just-in-time-part1/bb-risk-center.webp)
92+
![bb-risk-center](/content/docs/tutorials/just-in-time-database-access-part1/bb-risk-center.webp)
9393

9494
1. Login as the developer user again, then go to SQL Editor page. Click **Connect to a database** or **Select a database to start**. You should see the `hr_prod` and `hr_test` databases listed, click **Request query** to request a JIT access.
9595

96-
![bb-sql-editor-request](/content/docs/tutorials/just-in-time-part1/bb-sql-editor-request.webp)
96+
![bb-sql-editor-request](/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-request.webp)
9797

9898
1. Another way is to go to **Database > Databases** page, click **Request Querier Role**.
9999

100-
![bb-databases-request](/content/docs/tutorials/just-in-time-part1/bb-databases-request.webp)
100+
![bb-databases-request](/content/docs/tutorials/just-in-time-database-access-part1/bb-databases-request.webp)
101101

102102
1. In the **Request Querier Role** modal, choose **Manually select**, then `employee` `salary` and `title` under `hr_prod` database, and click **OK** button. Here you may also specify the expiration time which can be a specific time, or relative time from now.
103103

104-
![bb-sql-editor-choose](/content/docs/tutorials/just-in-time-part1/bb-sql-editor-choose.webp)
104+
![bb-sql-editor-choose](/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-choose.webp)
105105

106-
![bb-sql-editor-custom-expr](/content/docs/tutorials/just-in-time-part1/bb-sql-editor-custom-expr.webp)
106+
![bb-sql-editor-custom-expr](/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-custom-expr.webp)
107107

108108
1. An request issue will be created, switch to the project owner (the admin user), go to **Issue** page, you should see the request issue. Click **Approve** button to approve the request.
109109

110-
![bb-request-waiting](/content/docs/tutorials/just-in-time-part1/bb-request-waiting.webp)
110+
![bb-request-waiting](/content/docs/tutorials/just-in-time-database-access-part1/bb-request-waiting.webp)
111111

112112
1. Switch back to the developer user, go to SQL Editor page, you should be able to query from these three tables. If you query from other tables, you will get errors and suggest to request a JIT access.
113113

114-
![bb-sql-editor-not-ok](/content/docs/tutorials/just-in-time-part1/bb-sql-editor-not-ok.webp)
114+
![bb-sql-editor-not-ok](/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-not-ok.webp)
115115

116116
1. After the developer user get the access, he can solve the incident. The admin user can revoke the access directly from the **Manage** > **Members** page or wait for the access expiration.
117117

content/docs/tutorials/just-in-time-part2.md renamed to content/docs/tutorials/just-in-time-database-access-part2.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ estimated_time: '30 mins'
99
description: 'In this tutorial, we will demonstrate how to automate JIT access via Slack, utilizing Bytebase webhooks and API'
1010
---
1111

12-
In the [previous tutorial](/docs/tutorials/just-in-time-part1), we demonstrated how to set up JIT access using the Bytebase GUI. In this tutorial, we will cover how to automate JIT access via Slack, utilizing Bytebase webhooks and API.
12+
In the [previous tutorial](/docs/tutorials/just-in-time-database-access-part1), we demonstrated how to set up JIT access using the Bytebase GUI. In this tutorial, we will cover how to automate JIT access via Slack, utilizing Bytebase webhooks and API.
1313

1414
When developers need urgent production database access during incidents but lack permissions, they can request Just-in-Time (JIT) access. By triggering the Bytebase webhook, the DBA will receive a notification in Slack immediately and can approve there.
1515

1616
---
1717

1818
This is Part 2 of our tutorial series on implementing Just-in-Time (JIT) access:
1919

20-
- Part 1: [Grant JIT database access via Bytebase GUI](/docs/tutorials/just-in-time-part1)
20+
- Part 1: [Grant JIT database access via Bytebase GUI](/docs/tutorials/just-in-time-database-access-part1)
2121
- Part 2: Approve JIT database access via Slack (this one)
2222
- Part 3: Request JIT database access via Slack
2323

@@ -31,7 +31,7 @@ The complete code for this tutorial is available at: [slack-example](https://git
3131

3232
</HintBlock>
3333

34-
This tutorial skips the Bytebase setup part, if you haven't set up the Bytebase and registered admin and developer users, please follow instructions in the [previous tutorial](/docs/tutorials/just-in-time-part1).
34+
This tutorial skips the Bytebase setup part, if you haven't set up the Bytebase and registered admin and developer users, please follow instructions in the [previous tutorial](/docs/tutorials/just-in-time-database-access-part1).
3535

3636
## Prerequisites
3737

@@ -49,7 +49,7 @@ Before you begin, make sure you have:
4949

5050
## Step 1 - Finished the previous tutorial
5151

52-
Make sure you finished the [previous tutorial](/docs/tutorials/just-in-time-part1) and have the Bytebase instance running. Particularly, pay attention to **Step 4**, which is to request JIT access via Bytebase GUI.
52+
Make sure you finished the [previous tutorial](/docs/tutorials/just-in-time-database-access-part1) and have the Bytebase instance running. Particularly, pay attention to **Step 4**, which is to request JIT access via Bytebase GUI.
5353

5454
The `Request role` feature is supported by **Enterprise Plan** which will be needed for this tutorial, other plans only allow the `Assign role` feature which is not enough. You may request a trial from [here](https://www.bytebase.com/contact-us/).
5555

@@ -67,7 +67,7 @@ The `Request role` feature is supported by **Enterprise Plan** which will be nee
6767
1. By using VS Code's [Port forwarding](https://code.visualstudio.com/docs/editor/port-forwarding), you can forward the local server's ports:
6868
- `3000` for the `slack-example` app
6969
- `8080` for the Bytebase instance
70-
![vscode-ports](/content/docs/tutorials/just-in-time-part2/vscode-ports.webp)
70+
![vscode-ports](/content/docs/tutorials/just-in-time-database-access-part2/vscode-ports.webp)
7171
1. Copy the 8080 port forwarded address to the `.env.local` file as `BB_HOST`.
7272
1. Also, go to Bytebase, click **Settings > General** to set the address as **External URL**.
7373

@@ -78,19 +78,19 @@ The `Request role` feature is supported by **Enterprise Plan** which will be nee
7878
1. Set the **Name** as `Slack` webhook, **URL** as `YOUR_3000_FORWARDED_URL/api/bytebase/webhook`.
7979
1. Select `Issue approval needed` as **Triggering activities**.
8080
1. Click **Test webhook** and if it's successful, then click **Create**.
81-
![bb-webhook](/content/docs/tutorials/just-in-time-part2/bb-webhook.webp)
81+
![bb-webhook](/content/docs/tutorials/just-in-time-database-access-part2/bb-webhook.webp)
8282

8383
## Step 5 - Create and invite a Slack bot
8484

8585
1. Go to [Slack apps](https://api.slack.com/apps) and click **Create New App**.
8686
1. Choose **From scratch**, enter the **App name**, and select your **Workspace**.
8787
1. Go to **OAuth & Permissions** and add the following permissions under **Scopes**:
88-
- `chat:write`
89-
- `chat:write.public`
88+
- `chat:write` (send message)
89+
- `channels:read` (read channel id for public channel)
90+
- `groups:read` (read channel id for private channel)
9091
1. Scroll up to **OAuth Tokens**, click **Install to YOUR_WORKSPACE**, and authorize the app.
9192
1. Copy the **Bot User OAuth Token** and paste it into the `.env.local` file as **SLACK_BOT_TOKEN**.
9293
1. Choose a channel and invite the bot to the channel by typing `/invite @YOUR_BOT_NAME`.
93-
1. Get the **Channel ID** via copying the channel link and extracting the ID from the URL. Copy and paste it into the `.env.local` file as **SLACK_CHANNEL_ID**.
9494
1. Go to **Interactivity & Shortcuts** in app settings, turn on **Interactivity** and add the **Request URL**: `YOUR_3000_FORWARDED_URL/api/slack/interact`. Click **Save Changes**.
9595

9696
## Step 6 - Verify the workflow
@@ -100,24 +100,24 @@ Now, everything is ready, let's verify the workflow:
100100
1. Go to Bytebase, log in as the developer and go into the `Sample Project`.
101101
1. By default, the developer has no permission to access the database. Click **Manage > Members** and you'll see the devloper only has **Project Developer** role. If you go to **SQL Editor**, you'll see the `hr_prod` database is not accessible.
102102
1. Click **Database > databases**, select the `hr_prod` database, and click **Request Querier role**.
103-
![bb-db-request](/content/docs/tutorials/just-in-time-part2/bb-db-request.webp)
103+
![bb-db-request](/content/docs/tutorials/just-in-time-database-access-part2/bb-db-request.webp)
104104
1. Choose the database or table you want to access, and click **OK**.
105-
![bb-request-select](/content/docs/tutorials/just-in-time-part2/bb-request-select.webp)
105+
![bb-request-select](/content/docs/tutorials/just-in-time-database-access-part2/bb-request-select.webp)
106106
1. A request issue is created, the configured custom approval flow will be matched.
107-
![bb-issue-waiting](/content/docs/tutorials/just-in-time-part2/bb-issue-waiting.webp)
107+
![bb-issue-waiting](/content/docs/tutorials/just-in-time-database-access-part2/bb-issue-waiting.webp)
108108
1. Go to Slack, the bot already sent a message to the channel, which is triggered by the webhook.
109-
![slack-to-approve](/content/docs/tutorials/just-in-time-part2/slack-to-approve.webp)
109+
![slack-to-approve](/content/docs/tutorials/just-in-time-database-access-part2/slack-to-approve.webp)
110110
1. Click **Approve** and the Slack Bot will trigger the interact API, which calls Bytebase API to approve the issue.
111-
![slack-request-approved](/content/docs/tutorials/just-in-time-part2/slack-request-approved.webp)
111+
![slack-request-approved](/content/docs/tutorials/just-in-time-database-access-part2/slack-request-approved.webp)
112112
1. Go back to Bytebase, the issue is approved. The developer can access the database now.
113-
![bb-issue-approved](/content/docs/tutorials/just-in-time-part2/bb-issue-approved.webp)
113+
![bb-issue-approved](/content/docs/tutorials/just-in-time-database-access-part2/bb-issue-approved.webp)
114114

115115
## Code structure
116116

117117
If digging into the code is your interest, here is a brief explanation of the code structure:
118118

119119
- `src/app/api/bytebase/webhook/route.ts`: handle the webhook from Bytebase.
120-
- `src/app/api/slack/interact/route.ts`: handle the interaction from Slack.
120+
- `src/app/api/slack/interact/route.ts`: handle the interaction (Approve or Deny) from Slack to Bytebase.
121121
- `src/lib/slack.ts`: send the message to Slack via using the its [web API](https://tools.slack.dev/node-slack-sdk/web-api/).
122122

123123
## Conclusion

public/content/docs/tutorials/just-in-time-part1/bb-assign-license.webp renamed to public/content/docs/tutorials/just-in-time-database-access-part1/bb-assign-license.webp

File renamed without changes.

public/content/docs/tutorials/just-in-time-part1/bb-community-grant-query.webp renamed to public/content/docs/tutorials/just-in-time-database-access-part1/bb-community-grant-query.webp

File renamed without changes.

public/content/docs/tutorials/just-in-time-part1/bb-custom-approval.webp renamed to public/content/docs/tutorials/just-in-time-database-access-part1/bb-custom-approval.webp

File renamed without changes.

public/content/docs/tutorials/just-in-time-part1/bb-databases-request.webp renamed to public/content/docs/tutorials/just-in-time-database-access-part1/bb-databases-request.webp

File renamed without changes.

public/content/docs/tutorials/just-in-time-part1/bb-request-waiting.webp renamed to public/content/docs/tutorials/just-in-time-database-access-part1/bb-request-waiting.webp

File renamed without changes.

public/content/docs/tutorials/just-in-time-part1/bb-risk-center.webp renamed to public/content/docs/tutorials/just-in-time-database-access-part1/bb-risk-center.webp

File renamed without changes.

public/content/docs/tutorials/just-in-time-part1/bb-sql-editor-choose.webp renamed to public/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-choose.webp

File renamed without changes.

public/content/docs/tutorials/just-in-time-part1/bb-sql-editor-custom-expr.webp renamed to public/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-custom-expr.webp

File renamed without changes.

0 commit comments

Comments
 (0)