added COOKIE_DOMAIN parameter to settings

This commit is contained in:
Anatoly 2019-11-23 14:58:49 +03:00
parent d9743d8465
commit 9b61ff3114
6 changed files with 14 additions and 33 deletions

View File

@ -70,22 +70,12 @@ class JWTGenericViewMixin:
def _put_cookies_in_response(self, cookies: list, response: Response): def _put_cookies_in_response(self, cookies: list, response: Response):
"""Update COOKIES in response from namedtuple""" """Update COOKIES in response from namedtuple"""
for cookie in cookies: for cookie in cookies:
# todo: remove config for develop response.set_cookie(key=cookie.key,
from os import environ value=cookie.value,
configuration = environ.get('SETTINGS_CONFIGURATION', None) secure=cookie.secure,
if configuration == 'development' or configuration == 'stage': httponly=cookie.http_only,
response.set_cookie(key=cookie.key, max_age=cookie.max_age,
value=cookie.value, domain=settings.COOKIE_DOMAIN)
secure=cookie.secure,
httponly=cookie.http_only,
max_age=cookie.max_age,
domain='.id-east.ru')
else:
response.set_cookie(key=cookie.key,
value=cookie.value,
secure=cookie.secure,
httponly=cookie.http_only,
max_age=cookie.max_age, )
return response return response
def _get_tokens_from_cookies(self, request, cookies: dict = None): def _get_tokens_from_cookies(self, request, cookies: dict = None):

View File

@ -521,3 +521,5 @@ NEWS_CHOSEN_TAGS = ['eat', 'drink', 'cook', 'style', 'international', 'event', '
INTERNATIONAL_COUNTRY_CODES = ['www', 'main', 'next'] INTERNATIONAL_COUNTRY_CODES = ['www', 'main', 'next']
THUMBNAIL_ENGINE = 'utils.thumbnail_engine.GMEngine' THUMBNAIL_ENGINE = 'utils.thumbnail_engine.GMEngine'
COOKIE_DOMAIN = None

View File

@ -71,3 +71,5 @@ INSTALLED_APPS.append('transfer.apps.TransferConfig')
BROKER_URL = 'redis://localhost:6379/1' BROKER_URL = 'redis://localhost:6379/1'
CELERY_RESULT_BACKEND = BROKER_URL CELERY_RESULT_BACKEND = BROKER_URL
CELERY_BROKER_URL = BROKER_URL CELERY_BROKER_URL = BROKER_URL
COOKIE_DOMAIN = '.id-east.ru'

View File

@ -5,18 +5,15 @@ import sys
ALLOWED_HOSTS = ['*', ] ALLOWED_HOSTS = ['*', ]
SEND_SMS = False SEND_SMS = False
SMS_CODE_SHOW = True SMS_CODE_SHOW = True
USE_CELERY = True USE_CELERY = True
SCHEMA_URI = 'http' SCHEMA_URI = 'http'
DEFAULT_SUBDOMAIN = 'www' DEFAULT_SUBDOMAIN = 'www'
SITE_DOMAIN_URI = 'testserver.com:8000' SITE_DOMAIN_URI = 'testserver.com:8000'
DOMAIN_URI = '0.0.0.0:8000' DOMAIN_URI = '0.0.0.0:8000'
# CELERY # CELERY
# RabbitMQ # RabbitMQ
# BROKER_URL = 'amqp://rabbitmq:5672' # BROKER_URL = 'amqp://rabbitmq:5672'
@ -25,20 +22,16 @@ BROKER_URL = 'redis://redis:6379/1'
CELERY_RESULT_BACKEND = BROKER_URL CELERY_RESULT_BACKEND = BROKER_URL
CELERY_BROKER_URL = BROKER_URL CELERY_BROKER_URL = BROKER_URL
# MEDIA # MEDIA
MEDIA_URL = f'{SCHEMA_URI}://{DOMAIN_URI}/{MEDIA_LOCATION}/' MEDIA_URL = f'{SCHEMA_URI}://{DOMAIN_URI}/{MEDIA_LOCATION}/'
MEDIA_ROOT = os.path.join(PUBLIC_ROOT, MEDIA_LOCATION) MEDIA_ROOT = os.path.join(PUBLIC_ROOT, MEDIA_LOCATION)
# SORL thumbnails # SORL thumbnails
THUMBNAIL_DEBUG = True THUMBNAIL_DEBUG = True
# ADDED TRANSFER APP # ADDED TRANSFER APP
INSTALLED_APPS.append('transfer.apps.TransferConfig') INSTALLED_APPS.append('transfer.apps.TransferConfig')
# DATABASES # DATABASES
DATABASES.update({ DATABASES.update({
'legacy': { 'legacy': {
@ -88,7 +81,6 @@ LOGGING = {
} }
} }
# ELASTICSEARCH SETTINGS # ELASTICSEARCH SETTINGS
ELASTICSEARCH_DSL = { ELASTICSEARCH_DSL = {
'default': { 'default': {
@ -102,8 +94,7 @@ ELASTICSEARCH_INDEX_NAMES = {
'search_indexes.documents.product': 'local_product', 'search_indexes.documents.product': 'local_product',
} }
TESTING = sys.argv[1:2] == ['test'] TESTING = sys.argv[1:2] == ['test']
if TESTING: if TESTING:
ELASTICSEARCH_INDEX_NAMES = {} ELASTICSEARCH_INDEX_NAMES = {}
ELASTICSEARCH_DSL_AUTOSYNC = False ELASTICSEARCH_DSL_AUTOSYNC = False

View File

@ -20,7 +20,6 @@ DEFAULT_SUBDOMAIN = 'www'
SITE_DOMAIN_URI = 'gaultmillau.com' SITE_DOMAIN_URI = 'gaultmillau.com'
DOMAIN_URI = 'next.gaultmillau.com' DOMAIN_URI = 'next.gaultmillau.com'
# ELASTICSEARCH SETTINGS # ELASTICSEARCH SETTINGS
ELASTICSEARCH_DSL = { ELASTICSEARCH_DSL = {
'default': { 'default': {
@ -28,20 +27,17 @@ ELASTICSEARCH_DSL = {
} }
} }
ELASTICSEARCH_INDEX_NAMES = { ELASTICSEARCH_INDEX_NAMES = {
'search_indexes.documents.news': 'development_news', # temporarily disabled 'search_indexes.documents.news': 'development_news', # temporarily disabled
'search_indexes.documents.establishment': 'development_establishment', 'search_indexes.documents.establishment': 'development_establishment',
'search_indexes.documents.product': 'development_product', 'search_indexes.documents.product': 'development_product',
} }
sentry_sdk.init( sentry_sdk.init(
dsn="https://35d9bb789677410ab84a822831c6314f@sentry.io/1729093", dsn="https://35d9bb789677410ab84a822831c6314f@sentry.io/1729093",
integrations=[DjangoIntegration()] integrations=[DjangoIntegration()]
) )
BROKER_URL = 'redis://redis:6379/1' BROKER_URL = 'redis://redis:6379/1'
CELERY_RESULT_BACKEND = BROKER_URL CELERY_RESULT_BACKEND = BROKER_URL
CELERY_BROKER_URL = BROKER_URL CELERY_BROKER_URL = BROKER_URL
@ -53,4 +49,4 @@ LASTABLE_SERVICE = ''
LASTABLE_TOKEN = '' LASTABLE_TOKEN = ''
LASTABLE_PROXY = '' LASTABLE_PROXY = ''
THUMBNAIL_FORCE_OVERWRITE = True # see: https://github.com/jazzband/sorl-thumbnail/issues/351 COOKIE_DOMAIN = '.gaultmillau.com'

View File

@ -13,7 +13,6 @@ DEFAULT_SUBDOMAIN = 'www'
SITE_DOMAIN_URI = 'id-east.ru' SITE_DOMAIN_URI = 'id-east.ru'
DOMAIN_URI = 'gm-stage.id-east.ru' DOMAIN_URI = 'gm-stage.id-east.ru'
# ELASTICSEARCH SETTINGS # ELASTICSEARCH SETTINGS
ELASTICSEARCH_DSL = { ELASTICSEARCH_DSL = {
'default': { 'default': {
@ -21,8 +20,9 @@ ELASTICSEARCH_DSL = {
} }
} }
ELASTICSEARCH_INDEX_NAMES = { ELASTICSEARCH_INDEX_NAMES = {
# 'search_indexes.documents.news': 'stage_news', #temporarily disabled # 'search_indexes.documents.news': 'stage_news', #temporarily disabled
'search_indexes.documents.establishment': 'stage_establishment', 'search_indexes.documents.establishment': 'stage_establishment',
} }
COOKIE_DOMAIN = '.id-east.ru'