settings.py 10.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# Copyright 2012, 2013 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
#   1. Redistributions of source code must retain the above
#      copyright notice, this list of conditions and the following
#      disclaimer.
#
#   2. Redistributions in binary form must reproduce the above
#      copyright notice, this list of conditions and the following
#      disclaimer in the documentation and/or other materials
#      provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
34
from django.conf import settings
35
from synnefo_branding import settings as synnefo_settings
36
from synnefo.lib import parse_base_url
37
from astakos.api.services import astakos_services as vanilla_astakos_services
38
from synnefo.lib import join_urls
39 40 41
from synnefo.lib.services import fill_endpoints

from copy import deepcopy
42

43 44 45 46 47 48 49

BASE_URL = getattr(settings, 'ASTAKOS_BASE_URL',
                   'https://accounts.example.synnefo.org')


BASE_HOST, BASE_PATH = parse_base_url(BASE_URL)

50 51
astakos_services = deepcopy(vanilla_astakos_services)
fill_endpoints(astakos_services, BASE_URL)
52 53 54 55 56
ACCOUNTS_PREFIX = astakos_services['astakos_account']['prefix']
VIEWS_PREFIX = astakos_services['astakos_ui']['prefix']
KEYSTONE_PREFIX = astakos_services['astakos_identity']['prefix']
WEBLOGIN_PREFIX = astakos_services['astakos_weblogin']['prefix']
ADMIN_PREFIX = astakos_services['astakos_admin']['prefix']
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
57 58 59 60 61 62 63 64

# Set the expiration time of newly created auth tokens
# to be this many hours after their creation time.
AUTH_TOKEN_DURATION = getattr(settings, 'ASTAKOS_AUTH_TOKEN_DURATION', 30 * 24)

DEFAULT_USER_LEVEL = getattr(settings, 'ASTAKOS_DEFAULT_USER_LEVEL', 4)

INVITATIONS_PER_LEVEL = getattr(settings, 'ASTAKOS_INVITATIONS_PER_LEVEL', {
65 66 67 68 69
    0: 100,
    1: 2,
    2: 0,
    3: 0,
    4: 0
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
70 71
})

72 73 74
ADMINS = tuple(getattr(settings, 'ADMINS', ()))
MANAGERS = tuple(getattr(settings, 'MANAGERS', ()))
HELPDESK = tuple(getattr(settings, 'HELPDESK', ()))
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
75

76 77
CONTACT_EMAIL = settings.CONTACT_EMAIL
SERVER_EMAIL = settings.SERVER_EMAIL
78 79
SECRET_KEY = settings.SECRET_KEY
SESSION_ENGINE = settings.SESSION_ENGINE
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
80

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
81
# Identity Management enabled modules
82 83
# Supported modules are: 'local', 'twitter' and 'shibboleth'
IM_MODULES = getattr(settings, 'ASTAKOS_IM_MODULES', ['local'])
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
84 85

# Force user profile verification
86
FORCE_PROFILE_UPDATE = getattr(settings, 'ASTAKOS_FORCE_PROFILE_UPDATE', False)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
87 88

#Enable invitations
89
INVITATIONS_ENABLED = getattr(settings, 'ASTAKOS_INVITATIONS_ENABLED', False)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
90 91 92

COOKIE_NAME = getattr(settings, 'ASTAKOS_COOKIE_NAME', '_pithos2_a')
COOKIE_DOMAIN = getattr(settings, 'ASTAKOS_COOKIE_DOMAIN', None)
93
COOKIE_SECURE = getattr(settings, 'ASTAKOS_COOKIE_SECURE', True)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
94

95
IM_STATIC_URL = getattr(settings, 'ASTAKOS_IM_STATIC_URL', '/static/im/')
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
96

97 98
# If set to False and invitations not enabled newly created user
# will be automatically accepted
99 100
MODERATION_ENABLED = getattr(settings, 'ASTAKOS_MODERATION_ENABLED', True)

101
# Set service name
102
SITENAME = getattr(settings, 'ASTAKOS_SITENAME', synnefo_settings.SERVICE_NAME)
103

104 105 106
# Set recaptcha keys
RECAPTCHA_PUBLIC_KEY = getattr(settings, 'ASTAKOS_RECAPTCHA_PUBLIC_KEY', '')
RECAPTCHA_PRIVATE_KEY = getattr(settings, 'ASTAKOS_RECAPTCHA_PRIVATE_KEY', '')
107
RECAPTCHA_OPTIONS = getattr(settings, 'ASTAKOS_RECAPTCHA_OPTIONS',
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
108 109
                            {'theme': 'custom',
                             'custom_theme_widget': 'okeanos_recaptcha'})
110
RECAPTCHA_USE_SSL = getattr(settings, 'ASTAKOS_RECAPTCHA_USE_SSL', True)
111
RECAPTCHA_ENABLED = getattr(settings, 'ASTAKOS_RECAPTCHA_ENABLED', False)
112

113
# Set where the user should be redirected after logout
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
114 115 116
LOGOUT_NEXT = getattr(settings, 'ASTAKOS_LOGOUT_NEXT', '')

# Set user email patterns that are automatically activated
117 118
RE_USER_EMAIL_PATTERNS = getattr(
    settings, 'ASTAKOS_RE_USER_EMAIL_PATTERNS', [])
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
119

120
# Messages to display on login page header
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
121 122
# e.g. {'warning':
#       'This warning message will be displayed on the top of login page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
123
LOGIN_MESSAGES = getattr(settings, 'ASTAKOS_LOGIN_MESSAGES', [])
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
124

125
# Messages to display on login page header
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
126 127
# e.g. {'warning':
#       'This warning message will be displayed on the top of signup page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
128
SIGNUP_MESSAGES = getattr(settings, 'ASTAKOS_SIGNUP_MESSAGES', [])
129 130

# Messages to display on login page header
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
131 132
# e.g. {'warning':
#       'This warning message will be displayed on the top of profile page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
133
PROFILE_MESSAGES = getattr(settings, 'ASTAKOS_PROFILE_MESSAGES', [])
134 135

# Messages to display on all pages
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
136 137
# e.g. {'warning':
#       'This warning message will be displayed on the top of every page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
138
GLOBAL_MESSAGES = getattr(settings, 'ASTAKOS_GLOBAL_MESSAGES', [])
139

140
# messages to display as extra actions in account forms
141
# e.g. {'https://www.myhomepage.com': 'Back to <service_name>'}
142 143
PROFILE_EXTRA_LINKS = getattr(settings, 'ASTAKOS_PROFILE_EXTRA_LINKS', {})

Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
144 145
# The number of unsuccessful login requests per minute allowed
# for a specific user
146 147
RATELIMIT_RETRIES_ALLOWED = getattr(
    settings, 'ASTAKOS_RATELIMIT_RETRIES_ALLOWED', 3)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
148

149 150 151 152
# If False the email change mechanism is disabled
EMAILCHANGE_ENABLED = getattr(settings, 'ASTAKOS_EMAILCHANGE_ENABLED', False)

# Set the expiration time (in days) of email change requests
153 154
EMAILCHANGE_ACTIVATION_DAYS = getattr(
    settings, 'ASTAKOS_EMAILCHANGE_ACTIVATION_DAYS', 10)
155

156
# Set the astakos main functions logging severity (None to disable)
157
from logging import INFO
158
LOGGING_LEVEL = getattr(settings, 'ASTAKOS_LOGGING_LEVEL', INFO)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
159

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
160
# Set how many objects should be displayed per page
161
PAGINATE_BY = getattr(settings, 'ASTAKOS_PAGINATE_BY', 50)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
162

163
# Set how many objects should be displayed per page in show all projects page
164
PAGINATE_BY_ALL = getattr(settings, 'ASTAKOS_PAGINATE_BY_ALL', 50)
Olga Brani's avatar
Fixes  
Olga Brani committed
165

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
166 167
# Enforce token renewal on password change/reset
NEWPASSWD_INVALIDATE_TOKEN = getattr(
root's avatar
root committed
168
    settings, 'ASTAKOS_NEWPASSWD_INVALIDATE_TOKEN', True)
Olga Brani's avatar
Olga Brani committed
169

170 171 172 173
# Interval at which to update the user's available quota in astakos usage
# profile view
USAGE_UPDATE_INTERVAL = getattr(settings, 'ASTAKOS_USAGE_UPDATE_INTERVAL',
                                5000)
Olga Brani's avatar
Olga Brani committed
174

175
# Permit local account migration
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
176 177
ENABLE_LOCAL_ACCOUNT_MIGRATION = getattr(
    settings, 'ASTAKOS_ENABLE_LOCAL_ACCOUNT_MIGRATION', True)
178

179 180 181 182
# Migrate eppn identifiers to remote id
SHIBBOLETH_MIGRATE_EPPN = getattr(settings, 'ASTAKOS_SHIBBOLETH_MIGRATE_EPPN',
                                  False)

183 184 185 186
# Migrate eppn identifiers to remote id
SHIBBOLETH_MIGRATE_EPPN = getattr(settings, 'ASTAKOS_SHIBBOLETH_MIGRATE_EPPN',
                                  False)

187 188 189 190
# Strict shibboleth usage
SHIBBOLETH_REQUIRE_NAME_INFO = getattr(settings,
                                       'ASTAKOS_SHIBBOLETH_REQUIRE_NAME_INFO',
                                       False)
191

192 193
default_activation_redirect_url = join_urls('/', BASE_PATH, VIEWS_PREFIX,
                                            "landing")
194
ACTIVATION_REDIRECT_URL = getattr(settings, 'ASTAKOS_ACTIVATION_REDIRECT_URL',
195
                                  default_activation_redirect_url)
196

197
# If true, this enables a ui compatibility layer for the introduction of UUIDs
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
198
# in identity management. WARNING: Setting to True will break your installation
199 200
TRANSLATE_UUIDS = getattr(settings, 'ASTAKOS_TRANSLATE_UUIDS', False)

201 202
# Users that can approve or deny project applications from the web.
PROJECT_ADMINS = getattr(settings, 'ASTAKOS_PROJECT_ADMINS', set())
203 204 205 206

# OAuth2 Twitter credentials.
TWITTER_TOKEN = getattr(settings, 'ASTAKOS_TWITTER_TOKEN', '')
TWITTER_SECRET = getattr(settings, 'ASTAKOS_TWITTER_SECRET', '')
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
207 208
TWITTER_AUTH_FORCE_LOGIN = getattr(
    settings, 'ASTAKOS_TWITTER_AUTH_FORCE_LOGIN', False)
209 210 211 212 213 214 215 216

# OAuth2 Google credentials.
GOOGLE_CLIENT_ID = getattr(settings, 'ASTAKOS_GOOGLE_CLIENT_ID', '')
GOOGLE_SECRET = getattr(settings, 'ASTAKOS_GOOGLE_SECRET', '')

# OAuth2 LinkedIn credentials.
LINKEDIN_TOKEN = getattr(settings, 'ASTAKOS_LINKEDIN_TOKEN', '')
LINKEDIN_SECRET = getattr(settings, 'ASTAKOS_LINKEDIN_SECRET', '')
217

218
# URL to redirect the user after successful login when no next parameter is set
219
default_success_url = join_urls('/', BASE_PATH, VIEWS_PREFIX, "landing")
220
LOGIN_SUCCESS_URL = getattr(settings, 'ASTAKOS_LOGIN_SUCCESS_URL',
221
                            default_success_url)
222 223 224

# Whether or not to display projects in astakos menu
PROJECTS_VISIBLE = getattr(settings, 'ASTAKOS_PROJECTS_VISIBLE', False)
225

226 227
# A way to extend the components presentation metadata
COMPONENTS_META = getattr(settings, 'ASTAKOS_COMPONENTS_META', {})
228 229 230

# A way to extend the resources presentation metadata
RESOURCES_META = getattr(settings, 'ASTAKOS_RESOURCES_META', {})
231 232 233 234

# Do not require email verification for new users
SKIP_EMAIL_VERIFICATION = getattr(settings,
                                  'ASTAKOS_SKIP_EMAIL_VERIFICATION', False)
235 236 237 238

# Kamaki download url. Displayed in api access view
API_CLIENT_URL = getattr(settings, 'ASTAKOS_API_CLIENT_URL',
                         'https://pypi.python.org/pypi/kamaki')
239 240 241 242

KAMAKI_CONFIG_CLOUD_NAME = getattr(settings,
                                   'ASTAKOS_KAMAKI_CONFIG_CLOUD_NAME',
                                   None)
243 244 245

REDIRECT_ALLOWED_SCHEMES = getattr(settings,
                                   'ASTAKOS_REDIRECT_ALLOWED_SCHEMES',
246
                                   ('pithos', 'pithosdev'))
247 248 249 250

ADMIN_STATS_PERMITTED_GROUPS = getattr(settings,
                                       'ASTAKOS_ADMIN_STATS_PERMITTED_GROUPS',
                                       ['admin-stats'])
251 252 253 254

ENDPOINT_CACHE_TIMEOUT = getattr(settings,
                                 'ASTAKOS_ENDPOINT_CACHE_TIMEOUT',
                                 60)
255 256 257 258

RESOURCE_CACHE_TIMEOUT = getattr(settings,
                                 'ASTAKOS_RESOURCE_CACHE_TIMEOUT',
                                 60)