Skip to content

Commit a01560a

Browse files
committed
chore: add CSP and CORS instructions
1 parent f935133 commit a01560a

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

docs/docs/20-admins/30-operation/50-remote.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,81 @@ When using `"session_ingress_use_default_cluster_tls_cert": true`,
376376
_you have to set_ `"session_tls_secret_name": ""` as well, otherwise the API call will fail.
377377
:::
378378
379+
:::note
380+
If creating the resource pool fails with a message like `Could not find cluster with id XXXXXX in the list of clusters`. This means that you either got the cluster ID wrong or you need to restart the `data_service`, `k8s_watcher` and `data_tasks` services after you have added a new kubeconfig to the kubeconfigs secret.
381+
:::
382+
383+
### Security considerations
384+
385+
Renku sessions are embedded in an iframe. And when you run the session on a remote cluster
386+
then the session hostname is different from the website hostname that hosts the iframe.
387+
So to make this work we need to set the `SameSite` property on the session cookie to `none`.
388+
389+
This raises additional security concerns that should be mitigated as follows on the
390+
remote cluster ingress configuration.
391+
392+
:::note
393+
It may acceptable to just always open remote sessions in Renku via a separate tab.
394+
If this is the case then do not set the `SameSite` property to `none` and you do not have
395+
to implement the additional mitigations discussed below.
396+
:::
397+
398+
1. Enable Cross-Origin Resource Sharing (CORS)
399+
400+
```yaml
401+
nginx.ingress.kubernetes.io/enable-cors: "true"
402+
nginx.ingress.kubernetes.io/cors-allow-origin: "https://<remote hostname>"
403+
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
404+
nginx.ingress.kubernetes.io/cors-allow-methods: "GET, PUT, POST, DELETE, PATCH, OPTIONS"
405+
nginx.ingress.kubernetes.io/cors-allow-headers: "$http_access_control_request_headers"
406+
```
407+
408+
:::info
409+
You should add the `--skip-auth-preflight=true` to oauth2proxy in the session.
410+
This can be done via Helm chart values on the amalthea-sessions Helm chart.
411+
:::
412+
413+
2. Specify a Content Security Policy (CSP)
414+
415+
This says what hosts can embed the session in an iframe. If you are using nginx ingress
416+
as the ingress controller, you can set this via the following ingress annotation:
417+
418+
```yaml
419+
nginx.ingress.kubernetes.io/configuration-snippet: |
420+
more_set_headers "Content-Security-Policy: frame-ancestors 'self' <remote hostname>";
421+
```
422+
423+
With all of these ingress headers, the payload to create the cluster configuration via the API
424+
would look something like this:
425+
426+
```yaml
427+
{
428+
"name": "Remote Cluster",
429+
"config_name": "remote-cluster.yaml",
430+
"session_protocol": "https",
431+
"session_host": "sessions.example.org",
432+
"session_port": 443,
433+
"session_path": "/sessions",
434+
"session_ingress_class_name": "renku-user-session-ingress-class",
435+
"session_ingress_annotations": {
436+
"nginx.ingress.kubernetes.io/enable-cors": "true",
437+
"nginx.ingress.kubernetes.io/cors-allow-origin": "https://<local hostname>",
438+
"nginx.ingress.kubernetes.io/cors-allow-credentials": "true",
439+
"nginx.ingress.kubernetes.io/cors-allow-methods": "GET, PUT, POST, DELETE, PATCH, OPTIONS",
440+
"nginx.ingress.kubernetes.io/cors-allow-headers": "\"$http_access_control_request_headers\"",
441+
"nginx.ingress.kubernetes.io/configuration-snippet": "more_set_headers \"Content-Security-Policy: frame-ancestors 'self' https://<local hostname>\";\n",
442+
},
443+
"session_storage_class": "renku-user-session-storage-class",
444+
"session_tls_secret_name": "",
445+
"session_ingress_use_default_cluster_tls_cert": true
446+
}
447+
```
448+
449+
:::warning
450+
Removing or not setting the CORS and CSP headers above can have serious security implications.
451+
If you are using a different controller make sure you set all equivalent annotations.
452+
:::
453+
379454
### Create a resource pool for the remote cluster
380455

381456
Once the cluster connection has been defined, you can use the GET operation to retrieve the cluster connection descriptor, and from there retrieve the associated ULID and create a resource pool which is linked to it.

0 commit comments

Comments
 (0)