mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Added CSRF Origin in settings (#14062)
This commit is contained in:
parent
4a34ee1f1e
commit
5e9d514e5e
@ -14,7 +14,7 @@ class ConfConfig(AppConfig):
|
||||
def ready(self):
|
||||
self.module.autodiscover()
|
||||
|
||||
if not set(sys.argv) & {'migrate', 'check_migrations'}:
|
||||
if not set(sys.argv) & {'migrate', 'check_migrations', 'showmigrations'}:
|
||||
from .settings import SettingsWrapper
|
||||
|
||||
SettingsWrapper.initialize()
|
||||
|
||||
@ -94,6 +94,20 @@ register(
|
||||
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(
|
||||
'LICENSE',
|
||||
field_class=fields.DictField,
|
||||
|
||||
@ -158,6 +158,11 @@ REMOTE_HOST_HEADERS = ['REMOTE_ADDR', 'REMOTE_HOST']
|
||||
# REMOTE_HOST_HEADERS will be trusted unconditionally')
|
||||
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 = []
|
||||
|
||||
# Warning: this is a placeholder for a database setting
|
||||
|
||||
@ -59,6 +59,7 @@ function MiscSystemDetail() {
|
||||
'TOWER_URL_BASE',
|
||||
'DEFAULT_EXECUTION_ENVIRONMENT',
|
||||
'PROXY_IP_ALLOWED_LIST',
|
||||
'CSRF_TRUSTED_ORIGINS',
|
||||
'AUTOMATION_ANALYTICS_LAST_GATHER',
|
||||
'AUTOMATION_ANALYTICS_LAST_ENTRIES',
|
||||
'UI_NEXT'
|
||||
|
||||
@ -29,6 +29,7 @@ describe('<MiscSystemDetail />', () => {
|
||||
TOWER_URL_BASE: 'https://towerhost',
|
||||
REMOTE_HOST_HEADERS: [],
|
||||
PROXY_IP_ALLOWED_LIST: [],
|
||||
CSRF_TRUSTED_ORIGINS: [],
|
||||
LICENSE: null,
|
||||
REDHAT_USERNAME: 'name1',
|
||||
REDHAT_PASSWORD: '$encrypted$',
|
||||
|
||||
@ -53,6 +53,7 @@ function MiscSystemEdit() {
|
||||
'TOWER_URL_BASE',
|
||||
'DEFAULT_EXECUTION_ENVIRONMENT',
|
||||
'PROXY_IP_ALLOWED_LIST',
|
||||
'CSRF_TRUSTED_ORIGINS',
|
||||
'UI_NEXT'
|
||||
);
|
||||
|
||||
@ -95,6 +96,7 @@ function MiscSystemEdit() {
|
||||
await submitForm({
|
||||
...form,
|
||||
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),
|
||||
DEFAULT_EXECUTION_ENVIRONMENT:
|
||||
form.DEFAULT_EXECUTION_ENVIRONMENT?.id || null,
|
||||
@ -239,6 +241,11 @@ function MiscSystemEdit() {
|
||||
config={system.PROXY_IP_ALLOWED_LIST}
|
||||
isRequired
|
||||
/>
|
||||
<ObjectField
|
||||
name="CSRF_TRUSTED_ORIGINS"
|
||||
config={system.CSRF_TRUSTED_ORIGINS}
|
||||
isRequired
|
||||
/>
|
||||
{submitError && <FormSubmitError error={submitError} />}
|
||||
{revertError && <FormSubmitError error={revertError} />}
|
||||
</FormColumnLayout>
|
||||
|
||||
@ -39,6 +39,7 @@ const systemData = {
|
||||
REMOTE_HOST_HEADERS: ['REMOTE_ADDR', 'REMOTE_HOST'],
|
||||
TOWER_URL_BASE: 'https://localhost:3000',
|
||||
PROXY_IP_ALLOWED_LIST: [],
|
||||
CSRF_TRUSTED_ORIGINS: [],
|
||||
UI_NEXT: false,
|
||||
};
|
||||
|
||||
|
||||
@ -78,6 +78,20 @@
|
||||
"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": {
|
||||
"type": "string",
|
||||
"required": false,
|
||||
@ -4487,6 +4501,17 @@
|
||||
"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": {
|
||||
"type": "nested object",
|
||||
"label": "License",
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
"REMOTE_HOST"
|
||||
],
|
||||
"PROXY_IP_ALLOWED_LIST": [],
|
||||
"CSRF_TRUSTED_ORIGINS": [],
|
||||
"LICENSE": {},
|
||||
"REDHAT_USERNAME": "",
|
||||
"REDHAT_PASSWORD": "",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user