Skip to content

Commit

Permalink
plugins/clnrest: Add rest-csp option for config
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahanaFarooqui authored and rustyrussell committed Sep 19, 2023
1 parent eca3a33 commit 51578e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions plugins/clnrest/utilities/rpc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
plugin.add_option(name="rest-host", default="127.0.0.1", description="REST server host", opt_type="string", deprecated=False)
plugin.add_option(name="rest-port", default=None, description="REST server port to listen", opt_type="int", deprecated=False)
plugin.add_option(name="rest-cors-origins", default="*", description="Cross origin resource sharing origins", opt_type="string", deprecated=False, multi=True)
plugin.add_option(name="rest-csp", default="default-src 'self'; font-src 'self'; img-src 'self' data:; frame-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline';", description="Content security policy (CSP) for the server", opt_type="string", deprecated=False, multi=True)
5 changes: 3 additions & 2 deletions plugins/clnrest/utilities/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
import re
import json

CERTS_PATH, REST_PROTOCOL, REST_HOST, REST_PORT, REST_CORS_ORIGINS = "", "", "", "", []
CERTS_PATH, REST_PROTOCOL, REST_HOST, REST_PORT, REST_CSP, REST_CORS_ORIGINS = "", "", "", "", "", []


def set_config(options):
if 'rest-port' not in options:
return "`rest-port` option is not configured"
global CERTS_PATH, REST_PROTOCOL, REST_HOST, REST_PORT, REST_CORS_ORIGINS
global CERTS_PATH, REST_PROTOCOL, REST_HOST, REST_PORT, REST_CSP, REST_CORS_ORIGINS
CERTS_PATH = str(options["rest-certs"])
REST_PROTOCOL = str(options["rest-protocol"])
REST_HOST = str(options["rest-host"])
REST_PORT = int(options["rest-port"])
REST_CSP = str(options["rest-csp"])
cors_origins = options["rest-cors-origins"]
REST_CORS_ORIGINS.clear()
for origin in cors_origins:
Expand Down

0 comments on commit 51578e1

Please sign in to comment.