Skip to content

Commit 32e8286

Browse files
committed
Updated README
1 parent 295a3a1 commit 32e8286

File tree

2 files changed

+51
-145
lines changed

2 files changed

+51
-145
lines changed

plugins/stack-overflow-teams-backend/README.md

Lines changed: 14 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,109 +6,56 @@ Backend counterpart of the Stack Overflow for Teams Plugin.
66

77
The **Stack Overflow for Teams Backend plugin** is responsible for:
88

9-
10-
11-
- **Indexing all questions** from the private Stack Overflow instance (an enhanced version of the existing community plugins in the Backstage repository).
12-
13-
- **Handling API requests** via ``createStackOverflowApi`` and ``createStackOverflowService`` to the Stack Overflow instance for retrieving:
14-
15-
- `/users`
16-
17-
- `/tags`
18-
19-
- `/questions`
20-
21-
- Posting new questions via `/questions`
22-
23-
- **Managing OAuth authentication flow** to securely access Stack Overflow private instances via ``createStackOverflowAuth``
24-
25-
9+
- **Indexing all questions** from the private Stack Overflow instance (an enhanced version of the existing community plugins in the Backstage repository).
10+
- **Handling API requests** via ``createStackOverflowApi`` and ``createStackOverflowService`` to the Stack Overflow instance for retrieving:
11+
- `/users`
12+
- `/tags`
13+
- `/questions`
14+
- Posting new questions via `/questions`
15+
- **Managing OAuth authentication flow** to securely access Stack Overflow private instances via ``createStackOverflowAuth``
16+
- **Encrypts** the Stack Overflow Token before sending it as an http-only cookie to the frontend.
2617

2718
## OAuth Authentication Flow
2819

29-
30-
31-
The backend is the only component that directly utilizes **Stack Overflow access tokens** for requests.
32-
33-
20+
The backend is the only component that directly utilizes the **encrypted Stack Overflow access tokens** for requests.
3421

3522
### **Authorization Flow Details**
3623

37-
38-
39-
![image](https://github.com/user-attachments/assets/1a7df089-c3c6-49a4-8761-38479e89214a)
40-
41-
42-
4324
#### **`/auth/start`**
4425

4526
- Generates **PKCE Code Verifier**.
46-
4727
- Hashes Code Verifier to obtain **Code Challenge**.
48-
4928
- Generates a **state** (random string).
50-
5129
- Stores **Code Verifier** and **State** in a **secure, HTTP-only cookie** accessible only to the server.
5230

53-
54-
5531
#### **`/callback`**
5632

5733
- Retrieves the stored **Code Verifier** and **State**.
58-
5934
- Validates that the received **state** matches the one from Stack Overflow's query string parameter.
60-
6135
- The backend requests an **Access Token** using the stored **Code Verifier**.
62-
63-
- Stores the **Stack Overflow Access Token** in a **secure, HTTP-only cookie**.
64-
65-
66-
36+
- Backend **encrypts the token**, using the JWT secret stored in memory.
37+
- Stores the **encrypted Stack Overflow Access Token** in a **secure, HTTP-only cookie**.
6738

6839
## Installation
6940

70-
71-
7241
This plugin is installed via the `backstage-plugin-stack-overflow-teams-backend` package. To install it to your backend package, run the following command:
7342

74-
75-
7643
```bash
77-
78-
# From your root directory
79-
80-
yarn --cwd packages/backend add backstage-plugin-stack-overflow-teams-backend
81-
44+
yarn --cwd packages/backend add backstage-plugin-stack-overflow-teams-backend
8245
```
8346

84-
85-
8647
Then add the plugin to your backend in `packages/backend/src/index.ts`:
8748

88-
89-
9049
```ts
91-
92-
const backend = createBackend();
50+
const backend = createBackend();
9351

9452
// ...
9553

9654
backend.add(import('backstage-plugin-stack-overflow-teams-backend'));
97-
9855
```
9956

100-
101-
10257
## Development
10358

104-
105-
106-
This plugin backend can be started in a standalone mode from directly in this
107-
108-
package with `yarn start`. It is a limited setup that is most convenient when
109-
110-
developing the plugin backend itself.
111-
112-
59+
This plugin backend can be started in a standalone mode from directly in this package with `yarn start`. It is a limited setup that is most convenient when developing the plugin backend itself.
11360

11461
If you want to run the entire project, including the frontend, run `yarn dev` from the root directory.
Lines changed: 37 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,91 @@
1-
21
# Stack Overflow Teams Frontend Plugin
32

43
This package is the **frontend component** of the `stack-overflow-teams` plugin for Backstage.
54

65
## Areas of Responsibility
76

8-
It provides the UI and interacts with the [backend service](https://github.com/EstoesMoises/backstage-stackoverflow/tree/main/plugins/stack-overflow-teams-backend) to fetch data from your Stack Overflow Enterprise instance.
7+
It provides the UI and interacts with the [backend service](https://github.com/EstoesMoises/backstage-stackoverflow/tree/main/plugins/stack-overflow-teams-backend) to fetch data from your Stack Overflow Enterprise instance.
98

109
### Backend Dependency
1110

1211
To fully utilize this plugin, you must also install and configure the corresponding **backend package** (`backstage-plugin-stack-overflow-teams-backend`) in your Backstage backend. The frontend plugin relies on the backend for API communication and authentication handling.
1312

1413
## More details
1514

16-
1715
### Enhanced `<StackOverflowSearchResultListItem />`
1816

19-
This component, is a modified version of the [community plugin.](https://github.com/backstage/community-plugins/tree/main/workspaces/stack-overflow/plugins/stack-overflow/src/search/StackOverflowSearchResultListItem)
20-
21-
It adds a more Stack Overflow like interface, adding more information such as the questions' score, user role, user reputation and timestamp for the questions.
17+
This component is a modified version of the [community plugin.](https://github.com/backstage/community-plugins/tree/main/workspaces/stack-overflow/plugins/stack-overflow/src/search/StackOverflowSearchResultListItem)
2218

19+
It adds a more Stack Overflow-like interface, including additional information such as the questions' score, user role, user reputation, and timestamp.
2320

2421
---
2522

2623
### Individual Frontend Components
2724

25+
- **`<StackOverflowMe />`**
2826

27+
Displays information about the authenticated user.
2928

30-
- **`<StackOverflowMe />`**
31-
32-
Displays information about the authenticated user.
33-
29+
- **`<StackOverflowPostQuestionModal />`**
3430

31+
Provides a form for users to create a new Stack Overflow question. Once submitted, an API request is executed to create the question.
32+
33+
This form listens to the `'openAskQuestionModal'` event. You can utilize this anywhere in your Backstage UI. To invoke the form, add the component to your UI along with a button that dispatches the event. Example:
3534

36-
- **`<StackOverflowPostQuestionModal />`**
37-
38-
Provides a form for users to create a new Stack Overflow question. Once submitted, an API request is executed to create the question.
39-
40-
This form listens to the `'openAskQuestionModal'` event. You can utilize this anywhere in you Backstage UI, to invoque the form you must add the component to your UI, but also a button that dispatches the event. E.g.:
41-
42-
<SidebarItem
43-
35+
```tsx
36+
<SidebarItem
4437
icon={StackOverflowIcon}
45-
46-
onClick={() => window.dispatchEvent(new Event('openAskQuestionModal'))}
47-
38+
onClick={() => window.dispatchEvent(new Event('openAskQuestionModal'))}
4839
text="Ask a Question"
49-
50-
/>
51-
52-
<StackOverflowPostQuestionModal />
53-
40+
/>
5441

42+
<StackOverflowPostQuestionModal />
43+
```
5544

56-
- **`<StackOverflowQuestion />`**
57-
58-
Retrieves questions from the API. Uses standard pagination, displaying only the first 30 API results.
59-
45+
- **`<StackOverflowQuestion />`**
6046

47+
Retrieves questions from the API. Uses standard pagination, displaying only the first 30 API results.
6148

62-
- **`<StackOverflowTags />`**
63-
64-
Retrieves tags from the API. Uses standard pagination, displaying only the first 30 API results.
65-
49+
- **`<StackOverflowTags />`**
6650

51+
Retrieves tags from the API. Uses standard pagination, displaying only the first 30 API results.
6752

68-
- **`<StackOverflowUsers />`**
69-
70-
Retrieves users from the API. Uses standard pagination, displaying only the first 30 API results.
71-
72-
- **`<StackOverflowHub />`**
73-
74-
The below various components collectively create this informative hub.
75-
53+
- **`<StackOverflowUsers />`**
7654

55+
Retrieves users from the API. Uses standard pagination, displaying only the first 30 API results.
7756

78-
## Authentication Components
79-
57+
- **`<StackOverflowHub />`**
8058

59+
Various components collectively create this informative hub.
8160

82-
- **`<StackAuthStart />`**
83-
84-
Initiates **`/auth/start`** on the backend.
61+
## Authentication Components
8562

63+
- **`<StackAuthStart />`**
8664

65+
Initiates **`/auth/start`** on the backend.
8766

88-
- **`<StackAuthLoading />`**
89-
90-
Handles loading state during authentication.
91-
67+
- **`<StackAuthLoading />`**
9268

69+
Handles the loading state during authentication.
9370

94-
- **`<StackAuthCallback />`**
95-
96-
Receives the code and state from your Stack Overflow Enterprise instance as part of the OAuth process and initiates **`/callback`** in the backend.
97-
71+
- **`<StackAuthCallback />`**
9872

73+
Receives the code and state from your Stack Overflow Enterprise instance as part of the OAuth process and initiates **`/callback`** in the backend.
9974

100-
- **`<StackAuthSuccess />`**
101-
102-
Displays authentication success state.
103-
75+
- **`<StackAuthSuccess />`**
10476

77+
Displays authentication success state.
10578

106-
- **`<StackAuthFailed />`**
107-
108-
Displays authentication failure state.
109-
79+
- **`<StackAuthFailed />`**
11080

81+
Displays authentication failure state.
11182

11283
### Page
11384

85+
- **`<StackOverflowTeamsPage />`**
11486

115-
116-
- **`<StackOverflowTeamsPage />`**
117-
118-
119-
120-
This page triggers authentication components, it bundles and orchestrates everything for you so you don't have to use the authentication components separated. If authenticated, it will return the `<StackOverflowHub />`.
121-
122-
87+
This page triggers authentication components, bundles, and orchestrates everything for you so you don't have to use the authentication components separately. If authenticated, it will return the `<StackOverflowHub />`.
12388

12489
### API Requests
12590

126-
127-
128-
The frontend plugin creates an API Ref for StackOverflow for Teams, which can be found under the `/api` folder. **All API requests from the frontend are directed to Backstage's backend**.
129-
130-
131-
132-
91+
The frontend plugin creates an API Ref for Stack Overflow for Teams, which can be found under the `/api` folder. **All API requests from the frontend are directed to Backstage's backend**.

0 commit comments

Comments
 (0)