|
1 | | -[](https://api.reuse.software/info/github.com/openmcp-project/ui-backend) |
2 | | - |
3 | 1 | # ui-backend |
4 | 2 |
|
| 3 | +[](https://api.reuse.software/info/github.com/openmcp-project/ui-backend) |
| 4 | + |
5 | 5 | ## About this project |
6 | 6 |
|
7 | | -UI backend for @openmcp-project |
| 7 | +This is the backend for our [MCP UI](https://github.com/openmcp-project/ui-frontend). |
| 8 | +Its a simple proxy server which sits between the UI frontend and the Kubernetes API server. |
| 9 | + |
| 10 | +### Motivation |
| 11 | + |
| 12 | +We want to call the kubernetes api server directly from the browser, but we have several problems preventing us from calling the api from the browser: |
| 13 | + |
| 14 | +- TLS certificate is not signed from a well-known CA |
| 15 | +- CORS is not configured most of the time |
| 16 | + |
| 17 | +### Solution |
| 18 | + |
| 19 | +The `ui-backend` server acts like a proxy when talking to the Crate-Cluster or MCPs from the browser. |
| 20 | +The browser sends the request to the `ui-backend`, with authorization data and optionally the project, workspace and controlplane name of the MCP in header data. |
| 21 | + |
| 22 | +- If requesting the Crate: The request will get send to the crate cluster with the authorization data in the headers |
| 23 | +- If requesting an MCP: The `ui-backend` will call the Crate to get the `kubeconfig` of the MCP and then calls the MCP with that kubeconfig |
| 24 | + |
| 25 | +There are only some modifications done when piping the request to the api server, preventing some headers from going through. |
8 | 26 |
|
9 | 27 | ## Requirements and Setup |
10 | 28 |
|
11 | | -*Insert a short description what is required to get your project running...* |
| 29 | +You need to have a running mcp landscape. Then reference the KUBECONFIG for the backend using the `KUBECONFIG` environment variable. |
| 30 | + |
| 31 | +The backend can be started using: |
| 32 | + |
| 33 | +```bash |
| 34 | +go run cmd/server/main.go |
| 35 | +``` |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +You can reach the backend on port `3000` and the path as you would directly to the api server. |
| 40 | + |
| 41 | +```txt |
| 42 | +For example: http://localhost:3000/api/v1/namespaces |
| 43 | +``` |
| 44 | + |
| 45 | +Put the authorization data in the following headers: |
| 46 | + |
| 47 | +- `X-Client-Certificate-Data` |
| 48 | +- `X-Client-Key-Data` |
| 49 | + |
| 50 | +or (for OIDC): |
| 51 | + |
| 52 | +- `Authorization: <token>` |
| 53 | + |
| 54 | +Also configure the api-server you want to call: |
| 55 | + |
| 56 | +- Crate: Add the header `X-Use-Crate-Cluster: true` |
| 57 | +- MCP: Add the headers `X-Project-Name`, `X-Workspace-Name` and `X-Control-Plane-Name` |
| 58 | + |
| 59 | +### Parsing JSON |
| 60 | + |
| 61 | +`ui-backend` support jsonpath (kubectl version) and jq (gojq) to parse json before sending it to the client, reducing the data transfered to the client. |
| 62 | + |
| 63 | +Usage: |
| 64 | + |
| 65 | +- JsonPath: Add a header `X-jsonpath` with the jsonpath query |
| 66 | +- JQ: Add a header `X-jq` with the jq query |
12 | 67 |
|
13 | 68 | ## Support, Feedback, Contributing |
14 | 69 |
|
15 | 70 | This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/openmcp-project/ui-backend/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md). |
16 | 71 |
|
17 | 72 | ## Security / Disclosure |
| 73 | + |
18 | 74 | If you find any bug that may be a security problem, please follow our instructions at [in our security policy](https://github.com/openmcp-project/ui-backend/security/policy) on how to report it. Please do not create GitHub issues for security-related doubts or problems. |
19 | 75 |
|
20 | 76 | ## Code of Conduct |
|
0 commit comments