# CSP blocks in-line script

**URL:** https://forum.opensearch.org/t/csp-blocks-in-line-script/13435
**Category:** OpenSearch Dashboards
**Created:** [March 21, 2023, 10:51am UTC](https://forum.opensearch.org/t/csp-blocks-in-line-script/13435 "2023-03-21T10:51:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![346pablo](https://avatars.discourse-cdn.com/v4/letter/3/41988e/32.png) [@346pablo](https://forum.opensearch.org/u/346pablo)
#### Post date: [March 21, 2023, 10:51am UTC](https://forum.opensearch.org/t/csp-blocks-in-line-script/13435/1 "2023-03-21T10:51:00Z")

</div>

**Versions**

Docker v20.10.23  
Minikube v1.29.0  
Kubernetes v1.26.1  
OpenSearch - Operator v2.2.1

* * *

**Describe the issue** :

When I forward the OpenSearch dashboard to port 5601 and open `http://localhost:5601` in my browser, the page loads (showing UI to enter user and password) but the console registers an error that says the Content Security Policy (CSP) has blocked in-line scripts from executing.

([Screenshot by Lightshot](https://prnt.sc/TR4y0kUKXpys))

Then, when I try to access the dashboard with admin / admin it just says “invalid username/password” or returns 500 - Internal Server Error.

([Screenshot by Lightshot](https://prnt.sc/vn5AV5L3_wHz))

The thing is that all solutions mention modifying the content-security-policy file or attributes but I have no clue where is that file stored for my configuration.

* * *

**Configuration** :

This is the command order that I execute from scratch:

1. `minikube start --cpus=8 --memory=8192` (otherwise it has insufficient cpu / memory and the pods won’t load)

2. `helm repo add opensearch-operator https://opster.github.io/opensearch-k8s-operator/`

3. `helm install my-opensearch-operator opensearch-operator/opensearch-operator --version 2.2.1`

At this point, the controller manager pod is created correctly without errors:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/4/4047c8e2f8f52c050ac5619f5b3bac9528996462.png)

Then, I navigate to the folder that contains the OpenSearch .yaml file to create the OpenSearch cluster. This is the opensearch-cluster.yaml file that I use:

```auto
apiVersion: opensearch.opster.io/v1
kind: OpenSearchCluster
metadata:
  name: my-cluster
  namespace: default
spec:
  general:
    version: 1.3.0
    httpPort: 9200
    vendor: opensearch
    serviceName: my-cluster
    pluginsList: ["repository-s3","https://github.com/aiven/prometheus-exporter-plugin-for-opensearch/releases/download/1.3.0.0/prometheus-exporter-1.3.0.0.zip"]
  dashboards:
    version: 1.3.0
    enable: true
    replicas: 1
    resources:
      requests:
         memory: "1Gi"
         cpu: "500m"
      limits:
         memory: "1Gi"
         cpu: "500m"
  confMgmt:
    smartScaler: true
  nodePools:
    - component: masters
      replicas: 1
      diskSize: "30Gi"
      nodeSelector:
      resources:
         requests:
            memory: "1Gi"
            cpu: "500m"
         limits:
            memory: "1Gi"
            cpu: "500m"
      roles:
        - "master"
        - "data"
    - component: nodes
      replicas: 1
      diskSize: "30Gi"
      nodeSelector:
      resources:
         requests:
            memory: "1Gi"
            cpu: "500m"
         limits:
            memory: "1Gi"
            cpu: "500m"
      roles:
        - "data"
    - component: coordinators
      replicas: 1
      diskSize: "30Gi"
      nodeSelector:
      resources:
         requests:
            memory: "1Gi"
            cpu: "500m"
         limits:
            memory: "1Gi"
            cpu: "500m"
      roles:
        - "ingest"

```

1. `kubectl apply -f opensearch-cluster.yaml`

When the command is executed, all the pods start creating.

`https://prnt.sc/os7hYK1SBtCN`

However, the bootstrap pod won’t create properly because of a problem with not enough max virtual memory areas.

To solve this, a command to increase that needs to be run:

1. `wsl -d docker-desktop sysctl -w vm.max_map_count=262144`

Here is a screenshot of all pods finally configured.

`https://prnt.sc/pnsCM06Q2FMV`

1. `kubectl port-forward svc/my-cluster-dashboards 5601`

2. Open in browser: `http://localhost:5601`

Now when I open developer tools,

`https://prnt.sc/TR4y0kUKXpys`

1. Enter credentials `admin / admin`

And after entering the credentials, I get this error:

500 - Internal Server Error:  
`https://prnt.sc/vn5AV5L3_wHz`

---

<div class="post-metadata">

### Author: ![ashwinpc](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/ashwinpc/32/4948_2.png) [@ashwinpc](https://forum.opensearch.org/u/ashwinpc)
#### Post date: [March 23, 2023, 8:18pm UTC](https://forum.opensearch.org/t/csp-blocks-in-line-script/13435/2 "2023-03-23T20:18:38Z")

</div>

@346pablo can you attach the screenshots directly? I’m unable to view them

---

<div class="post-metadata">

### Author: ![harrykrishnan](https://avatars.discourse-cdn.com/v4/letter/h/7c8e57/32.png) [@harrykrishnan](https://forum.opensearch.org/u/harrykrishnan)
#### Post date: [June 7, 2023, 12:53pm UTC](https://forum.opensearch.org/t/csp-blocks-in-line-script/13435/3 "2023-06-07T12:53:04Z")

</div>

Did you solved this problem? If yes let me know the steps or configurations you have followed.

---

<div class="post-metadata">

### Author: ![AMoo-Miki](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/amoo-miki/32/4642_2.png) [@AMoo-Miki](https://forum.opensearch.org/u/AMoo-Miki)
#### Post date: [June 7, 2023, 6:21pm UTC](https://forum.opensearch.org/t/csp-blocks-in-line-script/13435/4 "2023-06-07T18:21:20Z")

</div>

The CSP error you see is caused by Dashboards trying to check the CSP settings of the browser. You would notice the next line in the console asks you to ignore that.

 ![Screenshot 2023-06-07 at 11.15.39 AM](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/d/daada6664e064acb2e205a96250630ed6aea45cc.png)

If entering the username and password, without modifying any CSP settings, returns “invalid username/password” then those credentials are not what’s expected. However, if you get “internal server error”, the best clues are in the log files of OpenSearch and OpenSearch Dashboards; in fact, they would say exactly what went wrong.
