# Bug COMMS-637 - Error Content-Security-Policy with Hocuspocus integration due to URL scheme misconfiguration

Project: Stream Communicator
Status: closed
URL: https://community.openproject.org/work_packages/COMMS-637

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module | Modules and project features / Documents |
| Target versions | 17.2.0 |
| Observed in versions | 17.0.0 |
| Sprint |  |
| Backlog bucket |  |
| Bug found in version (deprecated) | 17.0.x |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers | Kabiru Mwenja |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

#### Description

After configuring an Hocuspocus Server (deployed with docker) in OpenProject 

When I try to edit a document, I have got an error :   
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/918907/content">

In developer console, I've got this error :

`Connecting to 'wss://hocuspocus.xxxxxx.fr/' violates the following Content Security Policy directive: "connect-src 'self'  https://hocuspocus.xxxxxx.fr". The action has been blocked.`

I added the CSP with :

`sudo openproject config:set OPENPROJECT_CSP_CONNECT_SRC="'self'  https://hocuspocus.xxxxxx.fr wss://hocuspocus.xxxxxx.fr"`

I ran

`sudo openproject configure`

`sudo openproject restart`

<br>

When I check in command line :

`sudo openproject config:get OPENPROJECT_CSP_CONNECT_SRC`

It returns :   `'self'  https://hocuspocus.xxxxxx.fr wss://hocuspocus.xxxxxx.fr`

So config seems ok

But when I check content-security-policy header tabs in developer console  of openproject pages, wss://hocuspocus.xxxxxx.fr is not present (only [https://hocuspocus.xxxxxx.fr](https://hocuspocus.xxxxxx.fr/) is included)

wss:// directives in OPENPROJECT\_CSP\_CONNECT\_SRC seems  to be ignored and not injected in content-security-policy header, and the error for hocuspocus still present

How to inject wss properly in content-security-policy ?

<br>

#### Expected Behavior

  - When configuring the hocuspocus server URL via the admin dashboard `<your-instance-url>/admin/settings/document_collaboration_settings` or via environment variable `OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__URL` it should be validated and feedback provided on invalid input E.g. inputting `https://` scheme instead of `ws://` scheme. There should also be clear form caption guiding the user on the expected input

<br>

**OpenProject installation type**

  - Packaged installation
    
      - Ubuntu 22.04
        
        <br>

**OpenProject version 17.1.0 (Abonnement Enterprise)**

**Browser**

- [x] Chrome
- [x] Firefox
- [ ] Safari
- [ ] Mobile Safari
- [ ] Other (please specify)

<br>
