mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
plugins/clnrest: Add rest-csp
option for config
This commit is contained in:
parent
eca3a33e69
commit
51578e1f77
2 changed files with 4 additions and 2 deletions
|
@ -8,3 +8,4 @@ plugin.add_option(name="rest-protocol", default="https", description="REST serve
|
|||
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)
|
||||
|
|
|
@ -2,17 +2,18 @@ import json5
|
|||
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:
|
||||
|
|
Loading…
Add table
Reference in a new issue