2012-02-04 17:40:31 -06:00
|
|
|
# Copyright 2012 United States Government as represented by the
|
2011-07-03 21:10:53 -07:00
|
|
|
# Administrator of the National Aeronautics and Space Administration.
|
|
|
|
# All Rights Reserved.
|
|
|
|
#
|
2012-02-04 17:40:31 -06:00
|
|
|
# Copyright 2012 Nebula, Inc.
|
2011-07-03 21:10:53 -07:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2011-01-12 13:43:31 -08:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import sys
|
2012-11-20 20:33:09 -08:00
|
|
|
import warnings
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2015-02-13 08:29:22 +01:00
|
|
|
import django
|
2014-01-03 17:31:49 +01:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2013-09-11 11:09:42 +01:00
|
|
|
|
2015-04-06 16:45:55 -05:00
|
|
|
from openstack_dashboard import exceptions
|
2015-07-17 15:58:34 +10:00
|
|
|
from openstack_dashboard.static_settings import find_static_files # noqa
|
2015-03-23 08:26:01 -06:00
|
|
|
from openstack_dashboard.static_settings import get_staticfiles_dirs # noqa
|
2015-01-13 14:45:07 +01:00
|
|
|
|
2012-08-05 12:52:21 -07:00
|
|
|
|
2012-11-20 20:33:09 -08:00
|
|
|
warnings.formatwarning = lambda message, category, *args, **kwargs: \
|
2013-09-05 15:49:35 +08:00
|
|
|
'%s: %s' % (category.__name__, message)
|
2012-11-20 20:33:09 -08:00
|
|
|
|
2011-01-12 13:43:31 -08:00
|
|
|
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
2012-06-20 13:37:10 -07:00
|
|
|
BIN_DIR = os.path.abspath(os.path.join(ROOT_PATH, '..', 'bin'))
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2012-01-04 14:46:40 -08:00
|
|
|
if ROOT_PATH not in sys.path:
|
|
|
|
sys.path.append(ROOT_PATH)
|
2011-01-12 13:43:31 -08:00
|
|
|
|
|
|
|
DEBUG = False
|
|
|
|
TEMPLATE_DEBUG = DEBUG
|
|
|
|
|
2012-04-13 21:46:04 -07:00
|
|
|
SITE_BRANDING = 'OpenStack Dashboard'
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2014-04-11 13:50:34 +02:00
|
|
|
WEBROOT = '/'
|
|
|
|
LOGIN_URL = None
|
|
|
|
LOGOUT_URL = None
|
|
|
|
LOGIN_REDIRECT_URL = None
|
2015-07-13 11:40:32 -06:00
|
|
|
STATIC_ROOT = None
|
2015-07-21 11:16:22 -06:00
|
|
|
STATIC_URL = None
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2012-02-28 23:27:46 -08:00
|
|
|
ROOT_URLCONF = 'openstack_dashboard.urls'
|
|
|
|
|
|
|
|
HORIZON_CONFIG = {
|
2012-10-04 15:43:40 -07:00
|
|
|
'user_home': 'openstack_dashboard.views.get_user_home',
|
2012-08-02 16:39:52 -07:00
|
|
|
'ajax_queue_limit': 10,
|
2013-03-06 16:21:12 -08:00
|
|
|
'auto_fade_alerts': {
|
|
|
|
'delay': 3000,
|
|
|
|
'fade_duration': 1500,
|
|
|
|
'types': ['alert-success', 'alert-info']
|
|
|
|
},
|
2012-08-05 12:52:21 -07:00
|
|
|
'help_url': "http://docs.openstack.org",
|
2015-04-06 16:45:55 -05:00
|
|
|
'exceptions': {'recoverable': exceptions.RECOVERABLE,
|
|
|
|
'not_found': exceptions.NOT_FOUND,
|
|
|
|
'unauthorized': exceptions.UNAUTHORIZED},
|
2015-08-12 11:12:18 -05:00
|
|
|
'modal_backdrop': 'static',
|
2014-05-08 12:34:21 -06:00
|
|
|
'angular_modules': [],
|
|
|
|
'js_files': [],
|
2015-02-08 22:00:18 -08:00
|
|
|
'js_spec_files': [],
|
2015-06-19 18:21:30 -07:00
|
|
|
'external_templates': [],
|
2012-02-28 23:27:46 -08:00
|
|
|
}
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2013-01-29 04:35:18 -05:00
|
|
|
# Set to True to allow users to upload images to glance via Horizon server.
|
|
|
|
# When enabled, a file form field will appear on the create image form.
|
|
|
|
# See documentation for deployment considerations.
|
|
|
|
HORIZON_IMAGES_ALLOW_UPLOAD = True
|
|
|
|
|
2013-09-11 11:09:42 +01:00
|
|
|
# The OPENSTACK_IMAGE_BACKEND settings can be used to customize features
|
|
|
|
# in the OpenStack Dashboard related to the Image service, such as the list
|
|
|
|
# of supported image formats.
|
|
|
|
OPENSTACK_IMAGE_BACKEND = {
|
|
|
|
'image_formats': [
|
2014-05-15 12:29:27 -04:00
|
|
|
('', _('Select format')),
|
2013-09-11 11:09:42 +01:00
|
|
|
('aki', _('AKI - Amazon Kernel Image')),
|
|
|
|
('ami', _('AMI - Amazon Machine Image')),
|
|
|
|
('ari', _('ARI - Amazon Ramdisk Image')),
|
2015-05-29 11:07:37 -05:00
|
|
|
('docker', _('Docker')),
|
2013-09-11 11:09:42 +01:00
|
|
|
('iso', _('ISO - Optical Disk Image')),
|
2015-01-28 12:07:49 +01:00
|
|
|
('ova', _('OVA - Open Virtual Appliance')),
|
2013-09-11 11:09:42 +01:00
|
|
|
('qcow2', _('QCOW2 - QEMU Emulator')),
|
|
|
|
('raw', _('Raw')),
|
2015-01-28 12:07:49 +01:00
|
|
|
('vdi', _('VDI - Virtual Disk Image')),
|
|
|
|
('vhd', _('VHD - Virtual Hard Disk')),
|
2015-03-04 10:38:33 -07:00
|
|
|
('vmdk', _('VMDK - Virtual Machine Disk')),
|
2013-09-11 11:09:42 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2011-01-12 13:43:31 -08:00
|
|
|
MIDDLEWARE_CLASSES = (
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
2012-04-13 21:46:04 -07:00
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
2011-01-12 13:43:31 -08:00
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
2015-02-13 08:29:22 +01:00
|
|
|
)
|
|
|
|
if django.VERSION >= (1, 8, 0):
|
|
|
|
MIDDLEWARE_CLASSES += (
|
|
|
|
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',)
|
|
|
|
else:
|
|
|
|
MIDDLEWARE_CLASSES += ('django.middleware.doc.XViewMiddleware',)
|
|
|
|
MIDDLEWARE_CLASSES += (
|
2011-10-31 11:31:05 -07:00
|
|
|
'horizon.middleware.HorizonMiddleware',
|
2011-06-03 14:23:25 +09:00
|
|
|
'django.middleware.locale.LocaleMiddleware',
|
2013-02-13 11:43:11 +02:00
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
2011-01-12 13:43:31 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
|
|
|
'django.core.context_processors.debug',
|
|
|
|
'django.core.context_processors.i18n',
|
|
|
|
'django.core.context_processors.request',
|
|
|
|
'django.core.context_processors.media',
|
2011-08-29 17:41:35 -07:00
|
|
|
'django.core.context_processors.static',
|
2011-01-12 13:43:31 -08:00
|
|
|
'django.contrib.messages.context_processors.messages',
|
2011-10-31 11:31:05 -07:00
|
|
|
'horizon.context_processors.horizon',
|
2012-10-04 15:43:40 -07:00
|
|
|
'openstack_dashboard.context_processors.openstack',
|
2011-01-12 13:43:31 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
TEMPLATE_LOADERS = (
|
2011-12-22 19:01:46 -08:00
|
|
|
'django.template.loaders.filesystem.Loader',
|
2012-04-26 19:22:51 -07:00
|
|
|
'django.template.loaders.app_directories.Loader',
|
2015-03-04 10:38:33 -07:00
|
|
|
'horizon.loaders.TemplateLoader',
|
2011-01-12 13:43:31 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
TEMPLATE_DIRS = (
|
|
|
|
os.path.join(ROOT_PATH, 'templates'),
|
|
|
|
)
|
|
|
|
|
2012-05-11 23:37:35 -07:00
|
|
|
STATICFILES_FINDERS = (
|
2014-03-24 10:40:03 -04:00
|
|
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
2012-05-11 23:37:35 -07:00
|
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
2014-08-25 10:58:39 +02:00
|
|
|
'compressor.finders.CompressorFinder',
|
2011-08-29 17:41:35 -07:00
|
|
|
)
|
2014-03-24 10:40:03 -04:00
|
|
|
|
2012-05-11 23:37:35 -07:00
|
|
|
COMPRESS_PRECOMPILERS = (
|
2015-08-14 20:51:21 -07:00
|
|
|
('text/scss', 'horizon.utils.scss_filter.HorizonScssFilter'),
|
2012-05-11 23:37:35 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
COMPRESS_CSS_FILTERS = (
|
|
|
|
'compressor.filters.css_default.CssAbsoluteFilter',
|
|
|
|
)
|
|
|
|
|
|
|
|
COMPRESS_ENABLED = True
|
|
|
|
COMPRESS_OUTPUT_DIR = 'dashboard'
|
|
|
|
COMPRESS_CSS_HASHING_METHOD = 'hash'
|
2012-06-11 14:20:32 -07:00
|
|
|
COMPRESS_PARSER = 'compressor.parser.HtmlParser'
|
2012-05-11 23:37:35 -07:00
|
|
|
|
2013-11-14 12:43:05 +01:00
|
|
|
INSTALLED_APPS = [
|
2012-02-28 23:27:46 -08:00
|
|
|
'openstack_dashboard',
|
2012-04-13 21:46:04 -07:00
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.auth',
|
2011-01-12 13:43:31 -08:00
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.messages',
|
2011-08-29 17:41:35 -07:00
|
|
|
'django.contrib.staticfiles',
|
2012-06-23 13:58:35 -07:00
|
|
|
'django.contrib.humanize',
|
2014-04-25 15:37:48 +02:00
|
|
|
'django_pyscss',
|
2014-09-22 10:50:12 -05:00
|
|
|
'openstack_dashboard.django_pyscss_fix',
|
2012-05-11 23:37:35 -07:00
|
|
|
'compressor',
|
2011-10-31 11:31:05 -07:00
|
|
|
'horizon',
|
2012-04-13 21:46:04 -07:00
|
|
|
'openstack_auth',
|
2013-11-14 12:43:05 +01:00
|
|
|
]
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2012-04-13 21:46:04 -07:00
|
|
|
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
|
|
|
|
AUTHENTICATION_BACKENDS = ('openstack_auth.backend.KeystoneBackend',)
|
2015-03-13 04:10:02 +00:00
|
|
|
AUTHENTICATION_URLS = ['openstack_auth.urls']
|
2014-06-23 10:35:20 +08:00
|
|
|
MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2012-04-11 14:04:08 -07:00
|
|
|
SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
|
|
|
|
SESSION_COOKIE_HTTPONLY = True
|
2011-01-12 13:43:31 -08:00
|
|
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
2012-04-11 14:04:08 -07:00
|
|
|
SESSION_COOKIE_SECURE = False
|
2013-06-20 12:52:37 +02:00
|
|
|
SESSION_TIMEOUT = 1800
|
2015-01-22 20:10:41 -08:00
|
|
|
# A token can be near the end of validity when a page starts loading, and
|
2014-04-17 11:18:00 +02:00
|
|
|
# invalid during the rendering which can cause errors when a page load.
|
|
|
|
# TOKEN_TIMEOUT_MARGIN defines a time in seconds we retrieve from token
|
|
|
|
# validity to avoid this issue. You can adjust this time depending on the
|
|
|
|
# performance of the infrastructure.
|
|
|
|
TOKEN_TIMEOUT_MARGIN = 10
|
2013-11-26 09:47:39 +01:00
|
|
|
|
2013-09-16 11:01:06 +02:00
|
|
|
# When using cookie-based sessions, log error when the session cookie exceeds
|
|
|
|
# the following size (common browsers drop cookies above a certain size):
|
|
|
|
SESSION_COOKIE_MAX_SIZE = 4093
|
2012-04-11 14:04:08 -07:00
|
|
|
|
2013-11-26 09:47:39 +01:00
|
|
|
# when doing upgrades, it may be wise to stick to PickleSerializer
|
2014-07-24 12:14:54 +02:00
|
|
|
# NOTE(berendt): Check during the K-cycle if this variable can be removed.
|
|
|
|
# https://bugs.launchpad.net/horizon/+bug/1349463
|
2013-11-26 09:47:39 +01:00
|
|
|
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
|
|
|
|
|
2011-06-03 14:23:25 +09:00
|
|
|
LANGUAGES = (
|
2014-05-08 10:06:05 +02:00
|
|
|
('de', 'German'),
|
2014-03-04 17:31:40 +01:00
|
|
|
('en', 'English'),
|
|
|
|
('en-au', 'Australian English'),
|
|
|
|
('en-gb', 'British English'),
|
|
|
|
('es', 'Spanish'),
|
|
|
|
('fr', 'French'),
|
2014-05-08 10:06:05 +02:00
|
|
|
('hi', 'Hindi'),
|
2014-03-04 17:31:40 +01:00
|
|
|
('ja', 'Japanese'),
|
|
|
|
('ko', 'Korean (Korea)'),
|
|
|
|
('nl', 'Dutch (Netherlands)'),
|
|
|
|
('pl', 'Polish'),
|
|
|
|
('pt-br', 'Portuguese (Brazil)'),
|
2015-04-13 10:50:47 -05:00
|
|
|
('ru', 'Russian'),
|
2014-05-08 10:06:05 +02:00
|
|
|
('sr', 'Serbian'),
|
2014-03-04 17:31:40 +01:00
|
|
|
('zh-cn', 'Simplified Chinese'),
|
2014-05-08 10:06:05 +02:00
|
|
|
('zh-tw', 'Chinese (Taiwan)'),
|
2011-06-03 14:23:25 +09:00
|
|
|
)
|
|
|
|
LANGUAGE_CODE = 'en'
|
2013-09-13 17:25:02 -07:00
|
|
|
LANGUAGE_COOKIE_NAME = 'horizon_language'
|
2011-06-02 15:23:09 +09:00
|
|
|
USE_I18N = True
|
2012-06-21 19:33:42 -07:00
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2014-03-24 06:54:12 +09:00
|
|
|
OPENSTACK_KEYSTONE_DEFAULT_ROLE = '_member_'
|
2011-10-31 11:31:05 -07:00
|
|
|
|
2012-05-24 15:25:35 -07:00
|
|
|
DEFAULT_EXCEPTION_REPORTER_FILTER = 'horizon.exceptions.HorizonReporterFilter'
|
|
|
|
|
Adding RBAC policy system and checks for identity
Adding file based RBAC engine for Horizon using copies of nova and
keystone policy.json files
Policy engine builds on top of oslo incubator policy.py, fileutils
was also pulled from oslo incubator as a dependency of policy.py
When Horizon runs and a policy check is made, a path and mapping of
services to policy files is used to load the rules into the policy
engine. Each check is mapped to a service type and validated. This
extra level of mapping is required because the policy.json files
may each contain a 'default' rule or unqualified (no service name
include) rule. Additionally, maintaining separate policy.json
files per service will allow easier syncing with the service
projects.
The engine allows for compound 'and' checks at this time. E.g.,
the way the Create User action is written, multiple APIs are
called to read data (roles, projects) and more are required to
update data (grants, user).
Other workflows e.g., Edit Project, should have separate save
actions per step as they are unrelated. Only the applicable
policy checks to that step were added. The separating unrelated
steps saves will should be future work.
The underlying engine supports more rule types that are used in the
underlying policy.json files.
Policy checks were added for all actions on tables in the Identity
Panel only. And the service policy files imported are limited in
this commit to reduce scope of the change.
Additionally, changes were made to the base action class to add
support or setting policy rules and an overridable method for
determining the policy check target. This reduces the need for
redundant code in each action policy check.
Note, the benefit Horizon has is that the underlying APIs will
correct us if we get it wrong, so if a policy file is not found for
a particular service, permission is assumed and the actual API call
to the service will fail if the action isn't authorized for that user.
Finally, adding documentation regarding policy enforcement.
Implements: blueprint rbac
Change-Id: I4a4a71163186b973229a0461b165c16936bc10e5
2013-08-16 17:28:46 -06:00
|
|
|
POLICY_FILES_PATH = os.path.join(ROOT_PATH, "conf")
|
|
|
|
# Map of local copy of service policy files
|
|
|
|
POLICY_FILES = {
|
|
|
|
'identity': 'keystone_policy.json',
|
2013-10-09 15:12:54 -06:00
|
|
|
'compute': 'nova_policy.json',
|
2014-01-30 21:01:41 -08:00
|
|
|
'volume': 'cinder_policy.json',
|
|
|
|
'image': 'glance_policy.json',
|
2014-02-10 20:10:49 -08:00
|
|
|
'orchestration': 'heat_policy.json',
|
2014-02-05 14:01:17 -08:00
|
|
|
'network': 'neutron_policy.json',
|
2015-02-06 17:00:27 -07:00
|
|
|
'telemetry': 'ceilometer_policy.json',
|
Adding RBAC policy system and checks for identity
Adding file based RBAC engine for Horizon using copies of nova and
keystone policy.json files
Policy engine builds on top of oslo incubator policy.py, fileutils
was also pulled from oslo incubator as a dependency of policy.py
When Horizon runs and a policy check is made, a path and mapping of
services to policy files is used to load the rules into the policy
engine. Each check is mapped to a service type and validated. This
extra level of mapping is required because the policy.json files
may each contain a 'default' rule or unqualified (no service name
include) rule. Additionally, maintaining separate policy.json
files per service will allow easier syncing with the service
projects.
The engine allows for compound 'and' checks at this time. E.g.,
the way the Create User action is written, multiple APIs are
called to read data (roles, projects) and more are required to
update data (grants, user).
Other workflows e.g., Edit Project, should have separate save
actions per step as they are unrelated. Only the applicable
policy checks to that step were added. The separating unrelated
steps saves will should be future work.
The underlying engine supports more rule types that are used in the
underlying policy.json files.
Policy checks were added for all actions on tables in the Identity
Panel only. And the service policy files imported are limited in
this commit to reduce scope of the change.
Additionally, changes were made to the base action class to add
support or setting policy rules and an overridable method for
determining the policy check target. This reduces the need for
redundant code in each action policy check.
Note, the benefit Horizon has is that the underlying APIs will
correct us if we get it wrong, so if a policy file is not found for
a particular service, permission is assumed and the actual API call
to the service will fail if the action isn't authorized for that user.
Finally, adding documentation regarding policy enforcement.
Implements: blueprint rbac
Change-Id: I4a4a71163186b973229a0461b165c16936bc10e5
2013-08-16 17:28:46 -06:00
|
|
|
}
|
|
|
|
|
2013-09-24 11:26:59 -07:00
|
|
|
SECRET_KEY = None
|
2014-01-09 15:35:38 -07:00
|
|
|
LOCAL_PATH = None
|
2013-09-24 11:26:59 -07:00
|
|
|
|
2014-06-24 17:33:26 -05:00
|
|
|
SECURITY_GROUP_RULES = {
|
|
|
|
'all_tcp': {
|
|
|
|
'name': _('All TCP'),
|
|
|
|
'ip_protocol': 'tcp',
|
|
|
|
'from_port': '1',
|
|
|
|
'to_port': '65535',
|
|
|
|
},
|
|
|
|
'all_udp': {
|
|
|
|
'name': _('All UDP'),
|
|
|
|
'ip_protocol': 'udp',
|
|
|
|
'from_port': '1',
|
|
|
|
'to_port': '65535',
|
|
|
|
},
|
|
|
|
'all_icmp': {
|
|
|
|
'name': _('All ICMP'),
|
|
|
|
'ip_protocol': 'icmp',
|
|
|
|
'from_port': '-1',
|
|
|
|
'to_port': '-1',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2014-07-17 17:19:52 +02:00
|
|
|
ADD_INSTALLED_APPS = []
|
2015-02-27 15:50:27 -08:00
|
|
|
|
2015-08-06 14:21:53 -06:00
|
|
|
# directory for custom theme, set as default.
|
2015-02-27 15:50:27 -08:00
|
|
|
# It can be overridden in local_settings.py
|
2015-08-05 12:22:43 -07:00
|
|
|
DEFAULT_THEME_PATH = 'themes/default'
|
|
|
|
CUSTOM_THEME_PATH = DEFAULT_THEME_PATH
|
2015-02-27 15:50:27 -08:00
|
|
|
|
2011-01-12 13:43:31 -08:00
|
|
|
try:
|
2013-07-24 16:27:01 +08:00
|
|
|
from local.local_settings import * # noqa
|
2012-02-28 23:27:46 -08:00
|
|
|
except ImportError:
|
|
|
|
logging.warning("No local_settings file found.")
|
2011-01-12 13:43:31 -08:00
|
|
|
|
2014-04-11 13:50:34 +02:00
|
|
|
if not WEBROOT.endswith('/'):
|
|
|
|
WEBROOT += '/'
|
|
|
|
if LOGIN_URL is None:
|
|
|
|
LOGIN_URL = WEBROOT + 'auth/login/'
|
|
|
|
if LOGOUT_URL is None:
|
|
|
|
LOGOUT_URL = WEBROOT + 'auth/logout/'
|
|
|
|
if LOGIN_REDIRECT_URL is None:
|
|
|
|
LOGIN_REDIRECT_URL = WEBROOT
|
|
|
|
|
2015-03-23 08:26:01 -06:00
|
|
|
MEDIA_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'media'))
|
|
|
|
MEDIA_URL = WEBROOT + 'media/'
|
2015-07-13 11:40:32 -06:00
|
|
|
|
|
|
|
if STATIC_ROOT is None:
|
|
|
|
STATIC_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'static'))
|
|
|
|
|
2015-07-21 11:16:22 -06:00
|
|
|
if STATIC_URL is None:
|
|
|
|
STATIC_URL = WEBROOT + 'static/'
|
|
|
|
|
|
|
|
STATICFILES_DIRS = get_staticfiles_dirs(STATIC_URL)
|
2015-03-23 08:26:01 -06:00
|
|
|
|
|
|
|
CUSTOM_THEME = os.path.join(ROOT_PATH, CUSTOM_THEME_PATH)
|
2015-06-03 12:46:51 -07:00
|
|
|
|
|
|
|
# If a custom template directory exists within our custom theme, then prepend
|
|
|
|
# it to our first-come, first-serve TEMPLATE_DIRS
|
|
|
|
if os.path.exists(os.path.join(CUSTOM_THEME, 'templates')):
|
|
|
|
TEMPLATE_DIRS = \
|
2015-07-27 15:59:14 -07:00
|
|
|
(os.path.join(CUSTOM_THEME, 'templates'),) + TEMPLATE_DIRS
|
2015-06-03 12:46:51 -07:00
|
|
|
|
|
|
|
# Only expose the subdirectory 'static' if it exists from a custom theme,
|
|
|
|
# allowing other logic to live with a theme that we might not want to expose
|
|
|
|
# statically
|
|
|
|
if os.path.exists(os.path.join(CUSTOM_THEME, 'static')):
|
|
|
|
CUSTOM_THEME = os.path.join(CUSTOM_THEME, 'static')
|
|
|
|
|
2015-08-05 12:22:43 -07:00
|
|
|
# Only collect and expose the default theme if the user chose to set a
|
|
|
|
# different theme
|
|
|
|
if DEFAULT_THEME_PATH != CUSTOM_THEME_PATH:
|
|
|
|
STATICFILES_DIRS.append(
|
|
|
|
('themes/default', os.path.join(ROOT_PATH, DEFAULT_THEME_PATH)),
|
|
|
|
)
|
|
|
|
|
2015-03-23 08:26:01 -06:00
|
|
|
STATICFILES_DIRS.append(
|
|
|
|
('custom', CUSTOM_THEME),
|
|
|
|
)
|
2014-04-11 13:50:34 +02:00
|
|
|
|
2015-07-29 11:49:58 -07:00
|
|
|
# Load the subdirectory 'img' of a custom theme if it exists, thereby allowing
|
|
|
|
# very granular theme overrides of all dashboard img files using the first-come
|
|
|
|
# first-serve filesystem loader.
|
|
|
|
if os.path.exists(os.path.join(CUSTOM_THEME, 'img')):
|
|
|
|
STATICFILES_DIRS.insert(0, ('dashboard/img',
|
|
|
|
os.path.join(CUSTOM_THEME, 'img')))
|
|
|
|
|
2015-06-19 18:21:30 -07:00
|
|
|
# populate HORIZON_CONFIG with auto-discovered JavaScript sources, mock files,
|
|
|
|
# specs files and external templates.
|
2015-07-17 15:58:34 +10:00
|
|
|
find_static_files(ROOT_PATH, HORIZON_CONFIG)
|
2015-06-19 18:21:30 -07:00
|
|
|
|
2013-11-14 12:43:05 +01:00
|
|
|
# Load the pluggable dashboard settings
|
|
|
|
import openstack_dashboard.enabled
|
|
|
|
import openstack_dashboard.local.enabled
|
|
|
|
from openstack_dashboard.utils import settings
|
|
|
|
|
|
|
|
INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable
|
2015-03-04 10:38:33 -07:00
|
|
|
settings.update_dashboards(
|
|
|
|
[
|
|
|
|
openstack_dashboard.enabled,
|
|
|
|
openstack_dashboard.local.enabled,
|
|
|
|
],
|
|
|
|
HORIZON_CONFIG,
|
|
|
|
INSTALLED_APPS,
|
|
|
|
)
|
2014-07-17 17:19:52 +02:00
|
|
|
INSTALLED_APPS[0:0] = ADD_INSTALLED_APPS
|
2013-11-14 12:43:05 +01:00
|
|
|
|
2013-09-24 11:26:59 -07:00
|
|
|
# Ensure that we always have a SECRET_KEY set, even when no local_settings.py
|
|
|
|
# file is present. See local_settings.py.example for full documentation on the
|
|
|
|
# horizon.utils.secret_key module and its use.
|
|
|
|
if not SECRET_KEY:
|
2014-01-09 15:35:38 -07:00
|
|
|
if not LOCAL_PATH:
|
|
|
|
LOCAL_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
|
|
|
'local')
|
|
|
|
|
2013-09-24 11:26:59 -07:00
|
|
|
from horizon.utils import secret_key
|
|
|
|
SECRET_KEY = secret_key.generate_or_read_from_file(os.path.join(LOCAL_PATH,
|
|
|
|
'.secret_key_store'))
|
|
|
|
|
2014-11-17 17:05:58 -07:00
|
|
|
from openstack_dashboard import policy_backend
|
|
|
|
POLICY_CHECK_FUNCTION = policy_backend.check
|
Adding RBAC policy system and checks for identity
Adding file based RBAC engine for Horizon using copies of nova and
keystone policy.json files
Policy engine builds on top of oslo incubator policy.py, fileutils
was also pulled from oslo incubator as a dependency of policy.py
When Horizon runs and a policy check is made, a path and mapping of
services to policy files is used to load the rules into the policy
engine. Each check is mapped to a service type and validated. This
extra level of mapping is required because the policy.json files
may each contain a 'default' rule or unqualified (no service name
include) rule. Additionally, maintaining separate policy.json
files per service will allow easier syncing with the service
projects.
The engine allows for compound 'and' checks at this time. E.g.,
the way the Create User action is written, multiple APIs are
called to read data (roles, projects) and more are required to
update data (grants, user).
Other workflows e.g., Edit Project, should have separate save
actions per step as they are unrelated. Only the applicable
policy checks to that step were added. The separating unrelated
steps saves will should be future work.
The underlying engine supports more rule types that are used in the
underlying policy.json files.
Policy checks were added for all actions on tables in the Identity
Panel only. And the service policy files imported are limited in
this commit to reduce scope of the change.
Additionally, changes were made to the base action class to add
support or setting policy rules and an overridable method for
determining the policy check target. This reduces the need for
redundant code in each action policy check.
Note, the benefit Horizon has is that the underlying APIs will
correct us if we get it wrong, so if a policy file is not found for
a particular service, permission is assumed and the actual API call
to the service will fail if the action isn't authorized for that user.
Finally, adding documentation regarding policy enforcement.
Implements: blueprint rbac
Change-Id: I4a4a71163186b973229a0461b165c16936bc10e5
2013-08-16 17:28:46 -06:00
|
|
|
|
2013-01-16 13:39:01 +01:00
|
|
|
# Add HORIZON_CONFIG to the context information for offline compression
|
|
|
|
COMPRESS_OFFLINE_CONTEXT = {
|
2015-07-21 10:45:40 -07:00
|
|
|
'WEBROOT': WEBROOT,
|
2013-01-16 13:39:01 +01:00
|
|
|
'STATIC_URL': STATIC_URL,
|
2015-03-04 10:38:33 -07:00
|
|
|
'HORIZON_CONFIG': HORIZON_CONFIG,
|
2013-01-16 13:39:01 +01:00
|
|
|
}
|
2012-11-20 20:33:09 -08:00
|
|
|
|
2013-02-05 16:04:10 -08:00
|
|
|
if DEBUG:
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
2013-08-15 17:13:22 -06:00
|
|
|
|
|
|
|
# during django reloads and an active user is logged in, the monkey
|
|
|
|
# patch below will not otherwise be applied in time - resulting in developers
|
|
|
|
# appearing to be logged out. In typical production deployments this section
|
2014-05-24 14:42:14 -05:00
|
|
|
# below may be omitted, though it should not be harmful
|
2013-08-15 17:13:22 -06:00
|
|
|
from openstack_auth import utils as auth_utils
|
|
|
|
auth_utils.patch_middleware_get_user()
|