settings.py 15.8 KB
Newer Older
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
1 2 3 4 5 6 7 8 9
from django.conf import settings

# 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', {
10 11 12 13 14
    0: 100,
    1: 2,
    2: 0,
    3: 0,
    4: 0
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
15 16 17
})

# Address to use for outgoing emails
18
DEFAULT_CONTACT_EMAIL = getattr(
19
    settings, 'ASTAKOS_DEFAULT_CONTACT_EMAIL', 'support@example.synnefo.org')
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
20

Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
21 22 23
SERVER_EMAIL = getattr(settings, 'SERVER_EMAIL', None)
ADMINS = getattr(settings, 'ADMINS', None)

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
24
# Identity Management enabled modules
25 26
# Supported modules are: 'local', 'twitter' and 'shibboleth'
IM_MODULES = getattr(settings, 'ASTAKOS_IM_MODULES', ['local'])
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
27 28 29 30 31

# Force user profile verification
FORCE_PROFILE_UPDATE = getattr(settings, 'ASTAKOS_FORCE_PROFILE_UPDATE', True)

#Enable invitations
32
INVITATIONS_ENABLED = getattr(settings, 'ASTAKOS_INVITATIONS_ENABLED', False)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
33 34 35

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

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

40 41 42
# If set to False and invitations not enabled newly created user will be automatically accepted
MODERATION_ENABLED = getattr(settings, 'ASTAKOS_MODERATION_ENABLED', True)

43
# Set baseurl
44
BASEURL = getattr(settings, 'ASTAKOS_BASEURL', 'https://accounts.example.synnefo.org')
45 46

# Set service name
47
SITENAME = getattr(settings, 'ASTAKOS_SITENAME', 'Synnefo Cloud')
48

49 50 51
# Set recaptcha keys
RECAPTCHA_PUBLIC_KEY = getattr(settings, 'ASTAKOS_RECAPTCHA_PUBLIC_KEY', '')
RECAPTCHA_PRIVATE_KEY = getattr(settings, 'ASTAKOS_RECAPTCHA_PRIVATE_KEY', '')
52 53
RECAPTCHA_OPTIONS = getattr(settings, 'ASTAKOS_RECAPTCHA_OPTIONS',
                            {'theme': 'custom', 'custom_theme_widget': 'okeanos_recaptcha'})
54
RECAPTCHA_USE_SSL = getattr(settings, 'ASTAKOS_RECAPTCHA_USE_SSL', True)
55
RECAPTCHA_ENABLED = getattr(settings, 'ASTAKOS_RECAPTCHA_ENABLED', False)
56

57
# set AstakosUser fields to propagate in the billing system
58
BILLING_FIELDS = getattr(settings, 'ASTAKOS_BILLING_FIELDS', ['is_active'])
59 60

# Queue for billing.
61
QUEUE_CONNECTION = getattr(settings, 'ASTAKOS_QUEUE_CONNECTION', None)  # Example: 'rabbitmq://guest:guest@localhost:5672/astakos'
62 63

# Set where the user should be redirected after logout
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
64 65 66
LOGOUT_NEXT = getattr(settings, 'ASTAKOS_LOGOUT_NEXT', '')

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

70 71
# Messages to display on login page header
# e.g. {'warning': 'This warning message will be displayed on the top of login page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
72
LOGIN_MESSAGES = getattr(settings, 'ASTAKOS_LOGIN_MESSAGES', [])
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
73

74 75
# Messages to display on login page header
# e.g. {'warning': 'This warning message will be displayed on the top of signup page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
76
SIGNUP_MESSAGES = getattr(settings, 'ASTAKOS_SIGNUP_MESSAGES', [])
77 78 79

# Messages to display on login page header
# e.g. {'warning': 'This warning message will be displayed on the top of profile page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
80
PROFILE_MESSAGES = getattr(settings, 'ASTAKOS_PROFILE_MESSAGES', [])
81 82 83

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

86 87 88 89
# messages to display as extra actions in account forms
# e.g. {'https://cms.okeanos.grnet.gr/': 'Back to ~okeanos'}
PROFILE_EXTRA_LINKS = getattr(settings, 'ASTAKOS_PROFILE_EXTRA_LINKS', {})

90
# The number of unsuccessful login requests per minute allowed for a specific user
91 92
RATELIMIT_RETRIES_ALLOWED = getattr(
    settings, 'ASTAKOS_RATELIMIT_RETRIES_ALLOWED', 3)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
93

94 95 96 97
# 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
98 99
EMAILCHANGE_ACTIVATION_DAYS = getattr(
    settings, 'ASTAKOS_EMAILCHANGE_ACTIVATION_DAYS', 10)
100

101
# Set the astakos main functions logging severity (None to disable)
102
from logging import INFO
103
LOGGING_LEVEL = getattr(settings, 'ASTAKOS_LOGGING_LEVEL', INFO)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
104

105
# Configurable email subjects
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
106 107 108
INVITATION_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_INVITATION_EMAIL_SUBJECT',
    'Invitation to %s alpha2 testing' % SITENAME)
109
GREETING_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_GREETING_EMAIL_SUBJECT',
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
110
                                 'Welcome to %s alpha2 testing' % SITENAME)
111
FEEDBACK_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_FEEDBACK_EMAIL_SUBJECT',
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
112 113 114 115 116 117 118
                                 'Feedback from %s alpha2 testing' % SITENAME)
VERIFICATION_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_VERIFICATION_EMAIL_SUBJECT',
    '%s alpha2 testing account activation is needed' % SITENAME)
ACCOUNT_CREATION_SUBJECT = getattr(
    settings, 'ASTAKOS_ACCOUNT_CREATION_SUBJECT',
    '%s alpha2 testing account created (%%(user)s)' % SITENAME)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
119 120 121
GROUP_CREATION_SUBJECT = getattr(
    settings, 'ASTAKOS_GROUP_CREATION_SUBJECT',
    '%s alpha2 testing group created (%%(group)s)' % SITENAME)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
122 123 124 125 126 127 128 129 130
HELPDESK_NOTIFICATION_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT',
    '%s alpha2 testing account activated (%%(user)s)' % SITENAME)
EMAIL_CHANGE_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_EMAIL_CHANGE_EMAIL_SUBJECT',
    'Email change on %s alpha2 testing' % SITENAME)
PASSWORD_RESET_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT',
    'Password reset on %s alpha2 testing' % SITENAME)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
131 132 133 134 135 136
PROJECT_CREATION_SUBJECT = getattr(
    settings, 'ASTAKOS_PROJECT_CREATION_SUBJECT',
    '%s alpha2 testing project application created (%%(name)s)' % SITENAME)
PROJECT_APPROVED_SUBJECT = getattr(
    settings, 'ASTAKOS_PROJECT_APPROVED_SUBJECT',
    '%s alpha2 testing project application approved (%%(name)s)' % SITENAME)
137 138 139
PROJECT_DENIED_SUBJECT = getattr(
    settings, 'ASTAKOS_PROJECT_DENIED_SUBJECT',
    '%s alpha2 testing project application denied (%%(name)s)' % SITENAME)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
140 141 142 143 144 145 146 147 148
PROJECT_TERMINATION_SUBJECT = getattr(
    settings, 'ASTAKOS_PROJECT_TERMINATION_SUBJECT',
    '%s alpha2 testing project terminated (%%(name)s)' % SITENAME)
PROJECT_SUSPENSION_SUBJECT = getattr(
    settings, 'ASTAKOS_PROJECT_SUSPENSION_SUBJECT',
    '%s alpha2 testing project suspended (%%(name)s)' % SITENAME)
PROJECT_MEMBERSHIP_CHANGE_SUBJECT = getattr(
    settings, 'ASTAKOS_PROJECT_MEMBERSHIP_CHANGE_SUBJECT',
    '%s alpha2 testing project membership changed (%%(name)s)' % SITENAME)
149 150 151
PROJECT_MEMBERSHIP_ENROLL_SUBJECT = getattr(
    settings, 'ASTAKOS_PROJECT_MEMBERSHIP_ENROLL_SUBJECT',
    '%s alpha2 testing project enrollment (%%(name)s)' % SITENAME)
152 153 154 155 156 157
PROJECT_MEMBERSHIP_REQUEST_SUBJECT = getattr(
    settings, 'ASTAKOS_PROJECT_MEMBERSHIP_REQUEST_SUBJECT',
    '%s alpha2 testing project membership request (%%(name)s)' % SITENAME)
PROJECT_MEMBERSHIP_LEAVE_REQUEST_SUBJECT = getattr(
    settings, 'ASTAKOS_PROJECT_MEMBERSHIP_LEAVE_REQUEST_SUBJECT',
    '%s alpha2 testing project membership leave request (%%(name)s)' % SITENAME)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
158

159
# Set the quota holder component URI
160
QUOTAHOLDER_URL = getattr(settings, 'ASTAKOS_QUOTAHOLDER_URL', '')
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
161
QUOTAHOLDER_TOKEN = getattr(settings, 'ASTAKOS_QUOTAHOLDER_TOKEN', '')
162
QUOTAHOLDER_POOLSIZE = getattr(settings, 'ASTAKOS_QUOTAHOLDER_POOLSIZE', 50)
163 164

# Set the cloud service properties
root's avatar
root committed
165
SERVICES = getattr(settings, 'ASTAKOS_SERVICES', {
166
    'cyclades': {
167 168
#        # Specifying the key 'url' will overwrite it.
#        # Use this to (re)set service URL.
169
#        'url': 'https://cyclades.example.synnefo.org/ui/',
170 171
#        # order services in listings, cloudbar, etc.
#        'order' : 1
172
        'resources': [{
173 174 175 176
            'name': 'disk',
            'group': 'compute',
            'uplimit': 30*1024*1024*1024,
            'unit': 'bytes',
177
            'desc': 'Virtual machine disk size'
178 179 180 181
            }, {
            'name': 'cpu',
            'group': 'compute',
            'uplimit': 6,
182
            'desc': 'Number of virtual machine processors'
183 184 185 186 187
            }, {
            'name': 'ram',
            'group': 'compute',
            'uplimit': 6*1024*1024*1024,
            'unit': 'bytes',
188
            'desc': 'Virtual machines'
189 190 191 192
            }, {
            'name': 'vm',
            'group': 'compute',
            'uplimit': 2,
193
            'desc': 'Number of virtual machines'
194 195 196 197
            }, {
            'name': 'network.private',
            'group': 'network',
            'uplimit': 1,
198 199 200
            'desc': 'Private networks'
            }
        ]
201 202
    },
    'pithos+': {
203
#        # Use this to (re)set service URL.
204
#        'url': 'https://pithos.example.synnefo.org/ui/',
205 206
#        # order services in listings, cloudbar, etc.
#        'order' : 2
207
        'resources':[{
208 209 210 211
            'name': 'diskspace',
            'group': 'storage',
            'uplimit': 5*1024*1024*1024,
            'unit': 'bytes',
212 213 214 215
            'desc': 'Pithos account diskspace'
            }]
    }
})
216 217 218 219

# Set the billing URI
AQUARIUM_URL = getattr(settings, 'ASTAKOS_AQUARIUM_URL', '')

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
220
# Set how many objects should be displayed per page
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
221 222
PAGINATE_BY = getattr(settings, 'ASTAKOS_PAGINATE_BY', 8)

223
# Set how many objects should be displayed per page in show all projects page
Olga Brani's avatar
Fixes  
Olga Brani committed
224 225
PAGINATE_BY_ALL = getattr(settings, 'ASTAKOS_PAGINATE_BY_ALL', 15)

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
226 227
# Enforce token renewal on password change/reset
NEWPASSWD_INVALIDATE_TOKEN = getattr(
root's avatar
root committed
228
    settings, 'ASTAKOS_NEWPASSWD_INVALIDATE_TOKEN', True)
Olga Brani's avatar
Olga Brani committed
229

230
USAGE_UPDATE_INTERVAL = getattr(settings, 'ASTAKOS_USAGE_UPDATE_INTERVAL', 5000)
Olga Brani's avatar
Olga Brani committed
231 232 233 234 235

RESOURCES_PRESENTATION_DATA = getattr(
    settings, 'ASTAKOS_RESOURCES_PRESENTATION_DATA', {
        'groups': {
             'compute': {
Olga Brani's avatar
Olga Brani committed
236
                'help_text':'Compute resources (amount of VMs, CPUs, RAM, System disk) ',
Olga Brani's avatar
Olga Brani committed
237 238
                'is_abbreviation':False,
                'report_desc':'',
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
239
                 'verbose_name':'compute',
Olga Brani's avatar
Olga Brani committed
240 241
            },
            'storage': {
Olga Brani's avatar
Olga Brani committed
242
                'help_text':'Storage resources (amount of space to store files on Pithos) ',
Olga Brani's avatar
Olga Brani committed
243 244
                'is_abbreviation':False,
                'report_desc':'',
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
245
                 'verbose_name':'storage',
Olga Brani's avatar
Olga Brani committed
246
            },
Olga Brani's avatar
Olga Brani committed
247
            'network': {
248
                'help_text':' Network resources (number of Private Networks)  ',
Olga Brani's avatar
Olga Brani committed
249 250 251 252
                'is_abbreviation':False,
                'report_desc':'',
                'verbose_name':'network',
            },
Olga Brani's avatar
Olga Brani committed
253 254 255
        },
        'resources': {
            'pithos+.diskspace': {
Olga Brani's avatar
Olga Brani committed
256 257
                'help_text':'This is the space on Pithos for storing files and VM Images. ',
                'help_text_input_each':'This is the total amount of space on Pithos that will be granted to each user of this Project ',
Olga Brani's avatar
Olga Brani committed
258
                'is_abbreviation':False,
Olga Brani's avatar
Olga Brani committed
259
                'report_desc':'Storage Space',
Olga Brani's avatar
Olga Brani committed
260
                'placeholder':'eg. 10GB',
Olga Brani's avatar
Olga Brani committed
261
                'verbose_name':'Storage Space',
Olga Brani's avatar
Olga Brani committed
262 263
            },
            'cyclades.disk': {
Olga Brani's avatar
Olga Brani committed
264 265
                'help_text':'This is the System Disk that the VMs have that run the OS ',
                'help_text_input_each':"This is the total amount of System Disk that will be granted to each user of this Project (this refers to the total System Disk of all VMs, not each VM's System Disk)  ",
Olga Brani's avatar
Olga Brani committed
266
                'is_abbreviation':False,
Olga Brani's avatar
Olga Brani committed
267
                'report_desc':'System Disk',
Olga Brani's avatar
Olga Brani committed
268
                'placeholder':'eg. 5GB, 2GB etc',
Olga Brani's avatar
Olga Brani committed
269
                'verbose_name':'System Disk'
Olga Brani's avatar
Olga Brani committed
270 271
            },
            'cyclades.ram': {
Olga Brani's avatar
Olga Brani committed
272 273
                'help_text':'RAM used by VMs ',
                'help_text_input_each':'This is the total amount of RAM that will be granted to each user of this Project (on all VMs)  ',
Olga Brani's avatar
Olga Brani committed
274 275 276 277 278 279
                'is_abbreviation':True,
                'report_desc':'RAM',
                'placeholder':'eg. 4GB',
                'verbose_name':'ram'
            },
            'cyclades.cpu': {
Olga Brani's avatar
Olga Brani committed
280 281
                'help_text':'CPUs used by VMs ',
                'help_text_input_each':'This is the total number of CPUs that will be granted to each user of this Project (on all VMs)  ',
Olga Brani's avatar
Olga Brani committed
282 283 284 285 286
                'is_abbreviation':True,
                'report_desc':'CPUs',
                'placeholder':'eg. 1',
                'verbose_name':'cpu'
            },
287 288 289 290 291 292 293 294
            'cyclades.vm': {
                'help_text':'These are the VMs one can create on the Cyclades UI ',
                'help_text_input_each':'This is the total number of VMs that will be granted to each user of this Project ',
                'is_abbreviation':True,
                'report_desc':'Virtual Machines',
                'placeholder':'eg. 2',
                'verbose_name':'vm',
            },
Olga Brani's avatar
Olga Brani committed
295
            'cyclades.network.private': {
Olga Brani's avatar
Olga Brani committed
296 297
                'help_text':'These are the Private Networks one can create on the Cyclades UI. ',
                'help_text_input_each':'This is the total number of Private Networks that will be granted to each user of this Project ',
Olga Brani's avatar
Olga Brani committed
298
                'is_abbreviation':False,
Olga Brani's avatar
Olga Brani committed
299
                'report_desc':'Private Networks',
Olga Brani's avatar
Olga Brani committed
300 301 302
                'placeholder':'eg. 1',
                'verbose_name':'private network'
            }
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
303

304 305 306 307 308 309
        },

        'groups_order': ['storage', 'compute', 'network'],
        'resources_order': ['pithos+.diskspace', 'cyclades.disk',
                            'cyclades.cpu', 'cyclades.ram', 'cyclades.vm',
                            'cyclades.network.private']
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
310

Olga Brani's avatar
Olga Brani committed
311
    })
312 313

# Permit local account migration
314
ENABLE_LOCAL_ACCOUNT_MIGRATION = getattr(settings, 'ASTAKOS_ENABLE_LOCAL_ACCOUNT_MIGRATION', True)
315 316 317 318 319

# Strict shibboleth usage
SHIBBOLETH_REQUIRE_NAME_INFO = getattr(settings,
                                       'ASTAKOS_SHIBBOLETH_REQUIRE_NAME_INFO',
                                       False)
320 321 322

PROJECT_MEMBER_JOIN_POLICIES = getattr(settings,
                                'ASTAKOS_PROJECT_MEMBER_JOIN_POLICIES',
323 324 325
                                {'1':'automatically accepted',
                                 '2':'owner accepts',
                                 '3':'closed'})
326 327 328

PROJECT_MEMBER_LEAVE_POLICIES = getattr(settings,
                                'ASTAKOS_PROJECT_MEMBER_LEAVE_POLICIES',
329 330 331
                                {'1':'automatically accepted',
                                 '2':'owner accepts',
                                 '3':'closed'})
332 333 334

ACTIVATION_REDIRECT_URL = getattr(settings,
                                  'ASTAKOS_ACTIVATION_REDIRECT_URL',
335
                                  "/im/landing")
336

337

338 339 340 341
# If true, this enables a ui compatibility layer for the introduction of UUIDs
# in identity management. WARNING: Setting to True will break your installation.
TRANSLATE_UUIDS = getattr(settings, 'ASTAKOS_TRANSLATE_UUIDS', False)

342 343
# Users that can approve or deny project applications from the web.
PROJECT_ADMINS = getattr(settings, 'ASTAKOS_PROJECT_ADMINS', set())
344

345 346 347 348 349 350
# Maximum pending project applications per applicant.
# This is to reduce the volume of applications
# in case users abuse the mechanism.
PENDING_APPLICATION_LIMIT = getattr(settings,
                                    'ASTAKOS_PENDING_APPLICATION_LIMIT', 1)

351 352 353 354 355 356 357 358 359 360 361 362 363
# OAuth2 Twitter credentials.
TWITTER_TOKEN = getattr(settings, 'ASTAKOS_TWITTER_TOKEN', '')
TWITTER_SECRET = getattr(settings, 'ASTAKOS_TWITTER_SECRET', '')
TWITTER_AUTH_FORCE_LOGIN = getattr(settings, 'ASTAKOS_TWITTER_AUTH_FORCE_LOGIN',
                                  False)

# 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', '')
364

365
# URL to redirect the user after successful login when no next parameter is set
366 367
LOGIN_SUCCESS_URL = getattr(settings, 'ASTAKOS_LOGIN_SUCCESS_URL',
                            '/im/landing')
368 369 370

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