Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from corsheaders.defaults import default_headers
- # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
- 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.0/howto/deployment/checklist/
- # SECURITY WARNING: keep the secret key used in production secret!
- SECRET_KEY = '+vh@!2sdmh70%6y@)yjo62rv3j#)k4p6#50#bzp-)to#%a)!68'
- # SECURITY WARNING: don't run with debug turned on in production!
- DEBUG = True
- # SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
- # CSRF_COOKIE_SECURE = True
- # SESSION_COOKIE_SECURE = True
- # Look into http strict transport security, django to avoid MITM attacks
- ALLOWED_HOSTS = ['localhost', 'localtunnel.me', 'lvh.me']
- # Application definition
- INSTALLED_APPS = [
- 'adaptilab.apps.AdaptilabConfig',
- 'rest_framework',
- 'rest_framework_api_key',
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'social_django',
- 'corsheaders',
- ]
- MIDDLEWARE = [
- 'django.middleware.security.SecurityMiddleware',
- 'corsheaders.middleware.CorsMiddleware',
- # 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django_session_header.middleware.SessionMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- 'social_django.middleware.SocialAuthExceptionMiddleware',
- ]
- CORS_ORIGIN_REGEX_WHITELIST = [
- r"(http(s)?://)?localhost:\d+",
- r"(http(s)?://)?lvh.me:\d+",
- r"(^.)*.localtunnel.me",
- ]
- #
- # CSRF_TRUSTED_ORIGINS = [
- # 'localhost:3000',
- # 'lvh.me',
- # 'localtunnel.me',
- # ]
- CORS_ALLOW_CREDENTIALS = True
- CORS_ALLOW_HEADERS = list(default_headers) + [
- 'x-csrftoken',
- 'x-csrf-token',
- 'content-type',
- 'x-session-id',
- 'x-sessionid',
- 'X-SessionID'
- ]
- CORS_EXPOSE_HEADERS = [
- 'x-sessionid',
- 'x-csrftoken',
- 'x-csrf-token',
- ]
- CSRF_USE_SESSIONS = True
- SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
- ROOT_URLCONF = 'mysite.urls'
- TEMPLATES = [
- {
- 'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [
- # os.path.join(BASE_DIR, 'adaptilab/client', 'build'),
- os.path.join(BASE_DIR, 'adaptilab/web', 'build'),
- BASE_DIR + '/adaptilab/web/build',
- # BASE_DIR + '/adaptilab/client/build',
- os.path.join(BASE_DIR, 'adaptilab/templates'),
- BASE_DIR + '/adaptilab/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',
- 'social_django.context_processors.backends',
- 'social_django.context_processors.login_redirect',
- ],
- },
- },
- ]
- WSGI_APPLICATION = 'mysite.wsgi.application'
- # For migration, do python manage.py migrate --database=db_name
- # To use non-default database is shell, use 'using' function: e.g. MyModel.objects.using('production').all()
- # Use the 'db_manager' function for create_user, e.g. Candidate.objects.db_manager(db).create_user(...)
- DATABASES = {
- # https://docs.djangoproject.com/en/2.2/topics/db/multi-db/
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
- },
- 'production': {
- 'ENGINE': 'django.db.backends.postgresql',
- 'NAME': 'userdb',
- 'USER': 'adaptilabdb',
- 'PASSWORD': 'Newport123!', # Move to different file
- 'HOST': 'userdbinstance.cve6j5b9okqz.us-west-2.rds.amazonaws.com', # Store as environment variable
- 'PORT': '5432',
- },
- 'qa': {
- 'ENGINE': 'django.db.backends.postgresql',
- 'NAME': 'qadb',
- 'USER': 'qauser',
- 'PASSWORD': 'IndianapolisColts12!', # Move to different file
- 'HOST': 'adaptilabdb-qa.cve6j5b9okqz.us-west-2.rds.amazonaws.com', # Store as environment variable
- 'PORT': '5432',
- }
- }
- # https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#changing-to-a-custom-user-model-mid-project
- AUTH_USER_MODEL = 'adaptilab.AdaptiLabUser'
- # List of Authentication Backends for authenticating user
- AUTHENTICATION_BACKENDS = [
- 'social_core.backends.linkedin.LinkedinOAuth2',
- 'social_core.backends.google.GoogleOAuth2',
- 'social_core.backends.facebook.FacebookOAuth2',
- 'social_core.backends.github.GithubOAuth2',
- 'django.contrib.auth.backends.ModelBackend',
- ]
- # Social Auth Pipeline
- SOCIAL_AUTH_PIPELINE = (
- 'social_core.pipeline.social_auth.social_details',
- 'social_core.pipeline.social_auth.social_uid',
- 'social_core.pipeline.social_auth.auth_allowed',
- 'social_core.pipeline.social_auth.social_user',
- 'social_core.pipeline.user.get_username',
- 'social_core.pipeline.social_auth.associate_by_email', # Merge duplicate emails
- 'social_core.pipeline.user.create_user',
- 'social_core.pipeline.social_auth.associate_user',
- 'social_core.pipeline.social_auth.load_extra_data',
- 'social_core.pipeline.user.user_details',
- )
- # Social Auth Config
- SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL = True
- SOCIAL_AUTH_LOGIN_REDIRECT_URL = 'adaptilab:candidate_oauth'
- SOCIAL_AUTH_LOGIN_URL = 'adaptilab:candidate_signin'
- SOCIAL_AUTH_LOGIN_ERROR_URL = '/candidate/signin/?error=oauth-login'
- SOCIAL_AUTH_POSTGRES_JSONFIELD = True
- SOCIAL_AUTH_URL_NAMESPACE = 'social'
- SOCIAL_AUTH_USER_MODEL = 'adaptilab.Candidate'
- # LinkedIn OAuth2.0
- SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY = '78bgbpvwv2rbvs'
- SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET = 'wl0CP8CxMKA8mhxG'
- SOCIAL_AUTH_LINKEDIN_OAUTH2_SCOPE = ['r_basicprofile', 'r_emailaddress']
- SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS = ['emailAddress', 'formattedName', 'publicProfileUrl', 'pictureUrl']
- SOCIAL_AUTH_LINKEDIN_OAUTH2_EXTRA_DATA = [
- ('id', 'id'),
- ('formattedName', 'name'),
- ('emailAddress', 'email_address'),
- ('pictureUrl', 'picture_url'),
- ('publicProfileUrl', 'profile_url'),
- ]
- # Facebook OAuth2.0
- SOCIAL_AUTH_FACEBOOK_KEY = '1242811182568511'
- SOCIAL_AUTH_FACEBOOK_SECRET = 'b7b2ed3bca67e54d9471d7da7ad7bc88'
- SOCIAL_AUTH_FACEBOOK_API_VERSION = '4.0'
- SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
- SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
- 'fields': 'id, name, email'
- }
- # Google OAuth2.0
- SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '580400534713-dhu025b8srieueh93emvglpgl9ng4dnd.apps.googleusercontent.com'
- SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'woEL_kMrdxqJvV7K3zMdtrpu'
- SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = ['email']
- # GitHub OAuth2.0
- SOCIAL_AUTH_GITHUB_KEY = 'b794b5cbc8edb33792b3'
- SOCIAL_AUTH_GITHUB_SECRET = 'fa5f384a59d5b2e1df23648d3c006b642360c75c'
- SOCIAL_AUTH_GITHUB_SCOPE = ['user']
- # Password validation
- # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
- AUTH_PASSWORD_VALIDATORS = [
- {
- 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
- },
- {
- 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
- },
- ]
- # Sending confirmation and password emails
- EMAIL_HOST = 'email-smtp.us-west-2.amazonaws.com'
- EMAIL_PORT = 587
- EMAIL_HOST_USER = 'AKIAIKLTUJRROVZYCDXA' # Move the strings to environment variables
- EMAIL_HOST_PASSWORD = 'At2m5eIuCMDY59PCmuCLe2I21bQkyCGTY3LBviCg/7VC'
- EMAIL_USE_TLS = True
- DEFAULT_FROM_EMAIL = 'AdaptiLab <do-not-reply@adaptilab.com>'
- # AWS credentials for web app
- AWS_ACCESS_KEY_ID = 'AKIAUKC6I3KAGNXJ6MOQ'
- AWS_SECRET_ACCESS_KEY = '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'
- # Stripe API keys
- STRIPE_PUBLISHABLE_KEY = 'pk_test_s8dGcN2X0iCgtjZSxXm9mXRo'
- STRIPE_SECRET_KEY = 'sk_test_tJbJpkF1wtff0LjgpwjZ85l6'
- # REST API settings
- REST_FRAMEWORK = {
- 'DEFAULT_AUTHENTICATION_CLASSES': [],
- 'DEFAULT_PERMISSION_CLASSES': [
- 'adaptilab.api_permissions.HasBasicAuthenticationAPIKey',
- ],
- 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
- 'PAGE_SIZE': 10,
- }
- # Mixpanel token
- MIXPANEL_TOKEN = 'd113ca12d25df81ce9e906562c3313da'
- # Internationalization
- # https://docs.djangoproject.com/en/2.0/topics/i18n/
- LANGUAGE_CODE = 'en-us'
- TIME_ZONE = 'America/Los_Angeles'
- USE_I18N = True
- USE_L10N = True
- USE_TZ = True
- # Static files (CSS, JavaScript, Images)
- # https://docs.djangoproject.com/en/2.0/howto/static-files/
- STATIC_URL = '/static/'
- STATICFILES_DIRS = [
- os.path.join(BASE_DIR, 'static'),
- os.path.join(BASE_DIR, 'adaptilab', 'web', 'build', 'static'),
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement