Commit 94191af0 authored by Daniela Daniel's avatar Daniela Daniel
Browse files

Add new file

parent d9680f0a
"""
Django settings for ftp_site project.
Generated by 'django-admin startproject' using Django 2.2.10.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from datetime import timedelta
import logging.config
import djcelery
import ldap
from django_auth_ldap.config import LDAPSearch, PosixGroupType
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ')nfe1e=$ox$@1rx$-7^q*pa=k9q4lw#90#ig9@-=(v6=4w_vx2'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
TEMPLATE_DEBUG = False
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ftp_manager',
'sekizai',
'biohpc_accounts',
'widget_tweaks',
'crispy_forms',
]
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
]
ROOT_URLCONF = 'ftp_site.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'sekizai.context_processors.sekizai',
],
},
},
]
WSGI_APPLICATION = 'ftp_site.wsgi.application'
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/Chicago'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
# ----------------------------------------------------------------------------
# LOCAL SETTINGS
# ----------------------------------------------------------------------------
# Customize for your installation.
STATIC_ROOT = '/devel/ftp_project/staticfiles/'
LOGIN_REDIRECT_URL = "/manage/main"
# ----------------------------------------------------------------------------
# DATABASES
# ----------------------------------------------------------------------------
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'vsftpd',
'USER': 'vsftpd',
'PASSWORD': 'vsftpd',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
'OPTIONS': { # skip django_mysql.W002
'init_command': 'SET sql_mode=STRICT_TRANS_TABLES',
},
}
}
# ----------------------------------------------------------------------------
# MESSAGE QUEUE / CELERY
# ----------------------------------------------------------------------------
# RabbitMQ backend URL for Celery task Scheduler
BROKER_URL = 'amqp://guest:guest@localhost//'
# Restricting to JSON (no pickle) is nice to do
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend'
djcelery.setup_loader()
# ----------------------------------------------------------------------------
# LDAP SERVER AUTH CONFIG
# ----------------------------------------------------------------------------
AUTH_LDAP_SERVER_URI = ''
# Can leave blank if anonymous binding is sufficient
AUTH_LDAP_BIND_DN = ''
AUTH_LDAP_BIND_PASSWORD = ''
# Any user account that has valid auth credentials can login
AUTH_LDAP_USER_SEARCH = LDAPSearch('',
ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
AUTH_LDAP_GROUP_SEARCH = LDAPSearch('',
ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)")
AUTH_LDAP_GROUP_TYPE = PosixGroupType()
# Populate the Django user from the LDAP directory.
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
# Map LDAP group membership into Django admin flags
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_staff": '',
"is_superuser": ''
}
# This is the default, but I like to be explicit.
AUTH_LDAP_ALWAYS_UPDATE_USER = True
# Use LDAP group membership to calculate group permissions.
AUTH_LDAP_FIND_GROUP_PERMS = True
# Cache group memberships for an hour to minimize LDAP traffic
AUTH_LDAP_CACHE_GROUPS = True
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
# ----------------------------------------------------------------------------
# USE LDAP BACKEND FOR AUTHENTICATION
# ----------------------------------------------------------------------------
AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)
# ----------------------------------------------------------------------------
# ACCOUNT SETTINGS FOR biohpc_accounts APP
# ----------------------------------------------------------------------------
# LDAP URI, user and password for BioHPC Directory (read/write)
BIOHPC_ACCOUNTS_LDAP_URI = ''
BIOHPC_ACCOUNTS_LDAP_USER = ''
BIOHPC_ACCOUNTS_LDAP_PASSWORD = ''
# Default primary GID for newly created users
BIOHPC_ACCOUNTS_DEFAULT_GID = ''
# Samba Domain Name
BIOHPC_ACCOUNTS_SAMBA_DOMAIN = ''
# Samba Domain SID
BIOHPC_ACCOUNTS_SAMBA_SID = ''
# LDAP Base DN to check for users/groups anywhere in the tree
BIOHPC_ACCOUNTS_BASE_DN = ''
# LDAP suffix for new users added to directory, but not enabled for services
# Have portal access only
BIOHPC_ACCOUNTS_NEW_USER_SUFFIX = ''
# LDAP suffix for active users in directory
BIOHPC_ACCOUNTS_ACTIVE_USER_SUFFIX = ''
# LDAP Suffix for group search
BIOHPC_ACCOUNTS_GROUP_SUFFIX = ''
# Permitted domains for users email at registration
BIOHPC_ACCOUNTS_GOOD_EMAIL_DOMAINS = ['', '']
# ----------------------------------------------------------------------------
# LOGGING
# ----------------------------------------------------------------------------
LOGGING_CONFIG = None
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(asctime)s %(message)s'
},
},
'handlers': {
'file': {
'level': 'INFO',
'class': 'logging.FileHandler',
'formatter' : 'simple',
'filename': '/var/log/ftp_project.log',
},
'console': {
'class': 'logging.StreamHandler',
'formatter': 'verbose',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'INFO',
'propagate': True,
},
'django_auth_ldap': {
'level': 'DEBUG',
'handlers': ['console'],
},
},
}
logging.config.dictConfig(LOGGING)
# ----------------------------------------------------------------------------
# ftp_manager app
# ----------------------------------------------------------------------------
# Days account will be valid after password is renewed
VALID_DAYS = 3
# FTP user root directory
FTP_DIRECTORY = '/project/ftp_public'
# Secondary user config directory
VSFTPD_USER_CONF_DIR = '/project/vsftpd_user_conf'
VSFTPD_USER_CONF_SKEL = '/project/vsftpd_user_conf/single_user_conf'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
MAX_GUEST_COUNT = 20
# FTP local configuration
FTP_HOSTNAME = 'localhost'
FTP_IPADDRESS = '127.0.0.1'
FTP_SERVICE_USER = 'vsftpd-guest'
FTP_SECRETE = ''
FROM_EMAIL = ''
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment