Prepare for public deployment

This commit is contained in:
R. Miles McCain 2020-04-14 15:18:45 -04:00
parent e04fbb3505
commit 73b8fc96d4
No known key found for this signature in database
GPG Key ID: 91CB47BDDF2671A5
6 changed files with 52 additions and 9 deletions

View File

@ -19,6 +19,7 @@ user-agents = "*"
emoji-country-flag = "*"
rules = "*"
gunicorn = "*"
psycopg2 = "*"
[requires]
python_version = "3.6"

21
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "c1d7cd1455c79f65e139ba93673e58446c8094311b329be28d44d23fd5510462"
"sha256": "11fb482879db5415b0e23111fa01c485ef40663567bb5837fe02d9c2dbf0e337"
},
"pipfile-spec": 6,
"requires": {
@ -147,6 +147,25 @@
],
"version": "==3.1.0"
},
"psycopg2": {
"hashes": [
"sha256:132efc7ee46a763e68a815f4d26223d9c679953cd190f1f218187cb60decf535",
"sha256:2327bf42c1744a434ed8ed0bbaa9168cac7ee5a22a9001f6fc85c33b8a4a14b7",
"sha256:27c633f2d5db0fc27b51f1b08f410715b59fa3802987aec91aeb8f562724e95c",
"sha256:2c0afb40cfb4d53487ee2ebe128649028c9a78d2476d14a67781e45dc287f080",
"sha256:2df2bf1b87305bd95eb3ac666ee1f00a9c83d10927b8144e8e39644218f4cf81",
"sha256:440a3ea2c955e89321a138eb7582aa1d22fe286c7d65e26a2c5411af0a88ae72",
"sha256:6a471d4d2a6f14c97a882e8d3124869bc623f3df6177eefe02994ea41fd45b52",
"sha256:6b306dae53ec7f4f67a10942cf8ac85de930ea90e9903e2df4001f69b7833f7e",
"sha256:a0984ff49e176062fcdc8a5a2a670c9bb1704a2f69548bce8f8a7bad41c661bf",
"sha256:ac5b23d0199c012ad91ed1bbb971b7666da651c6371529b1be8cbe2a7bf3c3a9",
"sha256:acf56d564e443e3dea152efe972b1434058244298a94348fc518d6dd6a9fb0bb",
"sha256:d3b29d717d39d3580efd760a9a46a7418408acebbb784717c90d708c9ed5f055",
"sha256:f7d46240f7a1ae1dd95aab38bd74f7428d46531f69219954266d669da60c0818"
],
"index": "pypi",
"version": "==2.8.5"
},
"python3-openid": {
"hashes": [
"sha256:0086da6b6ef3161cfe50fb1ee5cceaf2cda1700019fda03c2c5c440ca6abe4fa",

View File

@ -8,6 +8,7 @@ stringData:
DEBUG: "False"
ALLOWED_HOSTS: "*" # For better security, set this to your deployment's domain. Comma separated.
DJANGO_SECRET_KEY: ""
SIGNUPS_ENABLED: "False"
# Redis configuration (if you use the default Kubernetes config, this will work)
REDIS_CACHE_LOCATION: "redis://redis.default.svc.cluster.local/0"

View File

@ -1,5 +1,11 @@
from django.apps import AppConfig
from django.conf import settings
class DashboardConfig(AppConfig):
name = 'dashboard'
def ready(self):
if not settings.ACCOUNT_SIGNUPS_ENABLED:
# Normally you'd do this in settings.py, but this must be done _after_ apps are enabled
from allauth.account.adapter import DefaultAccountAdapter
DefaultAccountAdapter.is_open_for_signup = lambda k, v: False

View File

@ -8,6 +8,9 @@
{% block card %}
<form class="login" method="POST" action="{% url 'account_login' %}">
<aside class="aside ~info mb-4">
<p>Welcome to Shynet, a self-hosted analytics tool that's open source and privacy conscious. View the <a href="https://github.com/milesmcc/shynet">source code</a>.</p>
</aside>
{% csrf_token %}
{{ form|a17t }}
{% if redirect_field_value %}

View File

@ -45,7 +45,7 @@ INSTALLED_APPS = [
"rules.apps.AutodiscoverRulesConfig",
"a17t",
"core",
"dashboard",
"dashboard.apps.DashboardConfig",
"analytics",
"allauth",
"allauth.account",
@ -87,12 +87,24 @@ WSGI_APPLICATION = "shynet.wsgi.application"
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
if os.getenv("SQLITE", "False") == "True":
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": os.environ.get("DB_NAME"),
"USER": os.environ.get("DB_USER"),
"PASSWORD": os.environ.get("DB_PASSWORD"),
"HOST": os.environ.get("DB_HOST"),
"PORT": os.environ.get("DB_PORT"),
}
}
}
# Password validation
@ -147,8 +159,9 @@ ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_EMAIL_SUBJECT_PREFIX = ""
ACCOUNT_USER_DISPLAY = lambda k: k.email
ACCOUNT_SIGNUPS_ENABLED = os.getenv("SIGNUPS_ENABLED", "False") == True
LOGIN_REDIRECT_URL = "/dash"
LOGIN_REDIRECT_URL = "/"
SITE_ID = 1