mirror of
https://github.com/ansible/awx.git
synced 2026-03-25 12:55:04 -02:30
Added CSRF Origin in settings (#14062)
This commit is contained in:
@@ -14,7 +14,7 @@ class ConfConfig(AppConfig):
|
|||||||
def ready(self):
|
def ready(self):
|
||||||
self.module.autodiscover()
|
self.module.autodiscover()
|
||||||
|
|
||||||
if not set(sys.argv) & {'migrate', 'check_migrations'}:
|
if not set(sys.argv) & {'migrate', 'check_migrations', 'showmigrations'}:
|
||||||
from .settings import SettingsWrapper
|
from .settings import SettingsWrapper
|
||||||
|
|
||||||
SettingsWrapper.initialize()
|
SettingsWrapper.initialize()
|
||||||
|
|||||||
@@ -94,6 +94,20 @@ register(
|
|||||||
category_slug='system',
|
category_slug='system',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
register(
|
||||||
|
'CSRF_TRUSTED_ORIGINS',
|
||||||
|
default=[],
|
||||||
|
field_class=fields.StringListField,
|
||||||
|
label=_('CSRF Trusted Origins List'),
|
||||||
|
help_text=_(
|
||||||
|
"If the service is behind a reverse proxy/load balancer, use this setting "
|
||||||
|
"to configure the schema://addresses from which the service should trust "
|
||||||
|
"Origin header values. "
|
||||||
|
),
|
||||||
|
category=_('System'),
|
||||||
|
category_slug='system',
|
||||||
|
)
|
||||||
|
|
||||||
register(
|
register(
|
||||||
'LICENSE',
|
'LICENSE',
|
||||||
field_class=fields.DictField,
|
field_class=fields.DictField,
|
||||||
|
|||||||
@@ -158,6 +158,11 @@ REMOTE_HOST_HEADERS = ['REMOTE_ADDR', 'REMOTE_HOST']
|
|||||||
# REMOTE_HOST_HEADERS will be trusted unconditionally')
|
# REMOTE_HOST_HEADERS will be trusted unconditionally')
|
||||||
PROXY_IP_ALLOWED_LIST = []
|
PROXY_IP_ALLOWED_LIST = []
|
||||||
|
|
||||||
|
# If we are behind a reverse proxy/load balancer, use this setting to
|
||||||
|
# allow the scheme://addresses from which Tower should trust csrf requests from
|
||||||
|
# If this setting is an empty list (the default), we will only trust ourself
|
||||||
|
CSRF_TRUSTED_ORIGINS = []
|
||||||
|
|
||||||
CUSTOM_VENV_PATHS = []
|
CUSTOM_VENV_PATHS = []
|
||||||
|
|
||||||
# Warning: this is a placeholder for a database setting
|
# Warning: this is a placeholder for a database setting
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ function MiscSystemDetail() {
|
|||||||
'TOWER_URL_BASE',
|
'TOWER_URL_BASE',
|
||||||
'DEFAULT_EXECUTION_ENVIRONMENT',
|
'DEFAULT_EXECUTION_ENVIRONMENT',
|
||||||
'PROXY_IP_ALLOWED_LIST',
|
'PROXY_IP_ALLOWED_LIST',
|
||||||
|
'CSRF_TRUSTED_ORIGINS',
|
||||||
'AUTOMATION_ANALYTICS_LAST_GATHER',
|
'AUTOMATION_ANALYTICS_LAST_GATHER',
|
||||||
'AUTOMATION_ANALYTICS_LAST_ENTRIES',
|
'AUTOMATION_ANALYTICS_LAST_ENTRIES',
|
||||||
'UI_NEXT'
|
'UI_NEXT'
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ describe('<MiscSystemDetail />', () => {
|
|||||||
TOWER_URL_BASE: 'https://towerhost',
|
TOWER_URL_BASE: 'https://towerhost',
|
||||||
REMOTE_HOST_HEADERS: [],
|
REMOTE_HOST_HEADERS: [],
|
||||||
PROXY_IP_ALLOWED_LIST: [],
|
PROXY_IP_ALLOWED_LIST: [],
|
||||||
|
CSRF_TRUSTED_ORIGINS: [],
|
||||||
LICENSE: null,
|
LICENSE: null,
|
||||||
REDHAT_USERNAME: 'name1',
|
REDHAT_USERNAME: 'name1',
|
||||||
REDHAT_PASSWORD: '$encrypted$',
|
REDHAT_PASSWORD: '$encrypted$',
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ function MiscSystemEdit() {
|
|||||||
'TOWER_URL_BASE',
|
'TOWER_URL_BASE',
|
||||||
'DEFAULT_EXECUTION_ENVIRONMENT',
|
'DEFAULT_EXECUTION_ENVIRONMENT',
|
||||||
'PROXY_IP_ALLOWED_LIST',
|
'PROXY_IP_ALLOWED_LIST',
|
||||||
|
'CSRF_TRUSTED_ORIGINS',
|
||||||
'UI_NEXT'
|
'UI_NEXT'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -95,6 +96,7 @@ function MiscSystemEdit() {
|
|||||||
await submitForm({
|
await submitForm({
|
||||||
...form,
|
...form,
|
||||||
PROXY_IP_ALLOWED_LIST: formatJson(form.PROXY_IP_ALLOWED_LIST),
|
PROXY_IP_ALLOWED_LIST: formatJson(form.PROXY_IP_ALLOWED_LIST),
|
||||||
|
CSRF_TRUSTED_ORIGINS: formatJson(form.CSRF_TRUSTED_ORIGINS),
|
||||||
REMOTE_HOST_HEADERS: formatJson(form.REMOTE_HOST_HEADERS),
|
REMOTE_HOST_HEADERS: formatJson(form.REMOTE_HOST_HEADERS),
|
||||||
DEFAULT_EXECUTION_ENVIRONMENT:
|
DEFAULT_EXECUTION_ENVIRONMENT:
|
||||||
form.DEFAULT_EXECUTION_ENVIRONMENT?.id || null,
|
form.DEFAULT_EXECUTION_ENVIRONMENT?.id || null,
|
||||||
@@ -239,6 +241,11 @@ function MiscSystemEdit() {
|
|||||||
config={system.PROXY_IP_ALLOWED_LIST}
|
config={system.PROXY_IP_ALLOWED_LIST}
|
||||||
isRequired
|
isRequired
|
||||||
/>
|
/>
|
||||||
|
<ObjectField
|
||||||
|
name="CSRF_TRUSTED_ORIGINS"
|
||||||
|
config={system.CSRF_TRUSTED_ORIGINS}
|
||||||
|
isRequired
|
||||||
|
/>
|
||||||
{submitError && <FormSubmitError error={submitError} />}
|
{submitError && <FormSubmitError error={submitError} />}
|
||||||
{revertError && <FormSubmitError error={revertError} />}
|
{revertError && <FormSubmitError error={revertError} />}
|
||||||
</FormColumnLayout>
|
</FormColumnLayout>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const systemData = {
|
|||||||
REMOTE_HOST_HEADERS: ['REMOTE_ADDR', 'REMOTE_HOST'],
|
REMOTE_HOST_HEADERS: ['REMOTE_ADDR', 'REMOTE_HOST'],
|
||||||
TOWER_URL_BASE: 'https://localhost:3000',
|
TOWER_URL_BASE: 'https://localhost:3000',
|
||||||
PROXY_IP_ALLOWED_LIST: [],
|
PROXY_IP_ALLOWED_LIST: [],
|
||||||
|
CSRF_TRUSTED_ORIGINS: [],
|
||||||
UI_NEXT: false,
|
UI_NEXT: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,20 @@
|
|||||||
"read_only": false
|
"read_only": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"CSRF_TRUSTED_ORIGINS": {
|
||||||
|
"type": "list",
|
||||||
|
"required": true,
|
||||||
|
"label": "CSRF Origins List",
|
||||||
|
"help_text": "If the service is behind a reverse proxy/load balancer, use this setting to configure the schema://addresses from which the service should trust Origin header values. ",
|
||||||
|
"category": "System",
|
||||||
|
"category_slug": "system",
|
||||||
|
"default": [],
|
||||||
|
"child": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true,
|
||||||
|
"read_only": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"REDHAT_USERNAME": {
|
"REDHAT_USERNAME": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": false,
|
"required": false,
|
||||||
@@ -4487,6 +4501,17 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"CSRF_TRUSTED_ORIGINS": {
|
||||||
|
"type": "list",
|
||||||
|
"label": "CSRF Origins List",
|
||||||
|
"help_text": "If the service is behind a reverse proxy/load balancer, use this setting to configure the schema://addresses from which the service should trust Origin header values. ",
|
||||||
|
"category": "System",
|
||||||
|
"category_slug": "system",
|
||||||
|
"defined_in_file": false,
|
||||||
|
"child": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"LICENSE": {
|
"LICENSE": {
|
||||||
"type": "nested object",
|
"type": "nested object",
|
||||||
"label": "License",
|
"label": "License",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"REMOTE_HOST"
|
"REMOTE_HOST"
|
||||||
],
|
],
|
||||||
"PROXY_IP_ALLOWED_LIST": [],
|
"PROXY_IP_ALLOWED_LIST": [],
|
||||||
|
"CSRF_TRUSTED_ORIGINS": [],
|
||||||
"LICENSE": {},
|
"LICENSE": {},
|
||||||
"REDHAT_USERNAME": "",
|
"REDHAT_USERNAME": "",
|
||||||
"REDHAT_PASSWORD": "",
|
"REDHAT_PASSWORD": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user