"""Development settings and globals."""


from os.path import join, normpath

from analyticsdataserver.settings.base import *


########## DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = True
########## END DEBUG CONFIGURATION


########## EMAIL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
########## END EMAIL CONFIGURATION


########## DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': normpath(join(DJANGO_ROOT, 'default.db')),
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    },
    'analytics': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': normpath(join(DJANGO_ROOT, 'analytics.db')),
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}
########## END DATABASE CONFIGURATION


########## CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    }
}
########## END CACHE CONFIGURATION


########## ANALYTICS DATA API CONFIGURATION

ANALYTICS_DATABASE = 'analytics'
ENABLE_ADMIN_SITE = True

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

SWAGGER_SETTINGS = {
    'api_key': 'edx'
}

# These two settings are used in generate_fake_course_data.py.
# Replace with correct values to generate local fake video data.
LMS_BASE_URL = 'http://localhost:18000/'  # the base URL for your running local LMS instance
COURSE_BLOCK_API_AUTH_TOKEN = 'paste auth token here'  # see README for instructions on how to configure this value

# In Insights, we run this API as a separate service called "analyticsapi" to run acceptance/integration tests. Docker
# saves the service name as a host in the Insights container so it can reach the API by requesting http://analyticsapi/.
# However, in Django 1.10.3, the HTTP_HOST header of requests started to be checked against the ALLOWED_HOSTS setting
# even in DEBUG=True mode. Here, we add the Docker service name "analyticsapi" to the default set of local allowed
# hosts.
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '::1', 'analyticsapi']

JWT_AUTH.update({
    'JWT_SECRET_KEY': 'lms-secret',
    'JWT_ISSUER': 'http://edx.devstack.lms:18000/oauth2',
    'JWT_AUDIENCE': None,
    'JWT_VERIFY_AUDIENCE': False,
})

CORS_ORIGIN_WHITELIST = (
    'localhost:1991'
)

########## END ANALYTICS DATA API CONFIGURATION

@@ -71,16 +71,97 @@
 rmpath%0A%0A
+from corsheaders.defaults import default_headers as corsheaders_default_headers%0A%0A
 from ana
@@ -2645,58 +2645,635 @@
 se,%0A
-%7D)%0A%0ACORS_ORIGIN_WHITELIST = (%0A    'localhost:1991'
+    'JWT_PUBLIC_SIGNING_JWK_SET': (%0A        '%7B%22keys%22: %5B%7B%22kid%22: %22devstack_key%22, %22e%22: %22AQAB%22, %22kty%22: %22RSA%22, %22n%22: %22smKFSYowG6nNUAdeqH1jQQnH1PmIHphzBmwJ5vRf1vu'%0A        '48BUI5VcVtUWIPqzRK_LDSlZYh9D0YFL0ZTxIrlb6Tn3Xz7pYvpIAeYuQv3_H5p8tbz7Fb8r63c1828wXPITVTv8f7oxx5W3lFFgpFAyYMmROC'%0A        '4Ee9qG5T38LFe8_oAuFCEntimWxN9F3P-FJQy43TL7wG54WodgiM0EgzkeLr5K6cDnyckWjTuZbWI-4ffcTgTZsL_Kq1owa_J2ngEfxMCObnzG'%0A        'y5ZLcTUomo4rZLjghVpq6KZxfS6I1Vz79ZsMVUWEdXOYePCKKsrQG20ogQEkmTf9FT_SouC6jPcHLXw%22%7D%5D%7D'%0A    ),%0A%7D)%0A%0ACORS_ORIGIN_WHITELIST = (%0A    'localhost:1991'%0A)%0ACORS_ALLOW_HEADERS = corsheaders_default_headers + (%0A    'use-jwt-cookie',
 %0A)%0A%0A

Add JWT auth related settings for local development.