Base pix360 app - current status
This commit is contained in:
commit
e5788fa925
9 changed files with 331 additions and 0 deletions
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
db.sqlite3
|
||||||
|
settings.ini
|
||||||
|
*.pyc
|
||||||
|
__pycache__/
|
||||||
|
venv/
|
||||||
|
.vscode/
|
||||||
|
media/
|
22
manage.py
Executable file
22
manage.py
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
"""Django's command-line utility for administrative tasks."""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Run administrative tasks."""
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pix360.settings')
|
||||||
|
try:
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
except ImportError as exc:
|
||||||
|
raise ImportError(
|
||||||
|
"Couldn't import Django. Are you sure it's installed and "
|
||||||
|
"available on your PYTHONPATH environment variable? Did you "
|
||||||
|
"forget to activate a virtual environment?"
|
||||||
|
) from exc
|
||||||
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
0
pix360/__init__.py
Normal file
0
pix360/__init__.py
Normal file
16
pix360/asgi.py
Normal file
16
pix360/asgi.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
ASGI config for pix360 project.
|
||||||
|
|
||||||
|
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pix360.settings')
|
||||||
|
|
||||||
|
application = get_asgi_application()
|
206
pix360/settings.py
Normal file
206
pix360/settings.py
Normal file
|
@ -0,0 +1,206 @@
|
||||||
|
"""
|
||||||
|
Django settings for pix360 project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 4.2.6.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/4.2/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/4.2/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
from django.urls import reverse_lazy
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from autosecretkey import AutoSecretKey
|
||||||
|
|
||||||
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
ASK = AutoSecretKey(BASE_DIR / "settings.ini", template=BASE_DIR / "settings.dist.ini")
|
||||||
|
CONFIG = ASK.config
|
||||||
|
|
||||||
|
SECRET_KEY = ASK.secret_key
|
||||||
|
DEBUG = CONFIG.getboolean("PIX360", "Debug", fallback=False)
|
||||||
|
ALLOWED_HOSTS = [h.strip() for h in CONFIG.get("PIX360", "Hosts", fallback="localhost").split(",")]
|
||||||
|
CSRF_TRUSTED_ORIGINS = [f"https://{h}" for h in ALLOWED_HOSTS]
|
||||||
|
|
||||||
|
SECURE_PROXY_SSL_HEADER_NAME = CONFIG.get("KEYLOG", "SSLHeaderName", fallback="HTTP_X_FORWARDED_PROTO")
|
||||||
|
SECURE_PROXY_SSL_HEADER_VALUE = CONFIG.get("KEYLOG", "SSLHeaderValue", fallback="https")
|
||||||
|
SECURE_PROXY_SSL_HEADER = (SECURE_PROXY_SSL_HEADER_NAME, SECURE_PROXY_SSL_HEADER_VALUE)
|
||||||
|
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
"django.contrib.admin",
|
||||||
|
"django.contrib.auth",
|
||||||
|
"django.contrib.contenttypes",
|
||||||
|
"django.contrib.sessions",
|
||||||
|
"django.contrib.messages",
|
||||||
|
"django.contrib.staticfiles",
|
||||||
|
|
||||||
|
"pix360core",
|
||||||
|
]
|
||||||
|
|
||||||
|
MIDDLEWARE = [
|
||||||
|
"django.middleware.security.SecurityMiddleware",
|
||||||
|
"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",
|
||||||
|
]
|
||||||
|
|
||||||
|
ROOT_URLCONF = "pix360.urls"
|
||||||
|
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||||
|
"DIRS": [],
|
||||||
|
"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",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
WSGI_APPLICATION = "pix360.wsgi.application"
|
||||||
|
|
||||||
|
|
||||||
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
||||||
|
|
||||||
|
if (dbtype := "MySQL") in CONFIG or (dbtype := "MariaDB") in CONFIG:
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
|
'NAME': CONFIG.get(dbtype, "Database"),
|
||||||
|
'USER': CONFIG.get(dbtype, "Username"),
|
||||||
|
'PASSWORD': CONFIG.get(dbtype, "Password"),
|
||||||
|
'HOST': CONFIG.get(dbtype, "Host", fallback="localhost"),
|
||||||
|
'PORT': CONFIG.getint(dbtype, "Port", fallback=3306)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else:
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
AUTH_USER_MODEL = "pix360core.User"
|
||||||
|
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
if "OIDC" in CONFIG:
|
||||||
|
AUTHENTICATION_BACKENDS = [
|
||||||
|
'pix360core.backends.OIDCBackend',
|
||||||
|
]
|
||||||
|
|
||||||
|
LOGIN_URL = reverse_lazy("oidc_authentication_init")
|
||||||
|
|
||||||
|
OIDC_NAME = CONFIG.get("OIDC", "Name", fallback="OIDC")
|
||||||
|
OIDC_RP_CLIENT_ID = CONFIG["OIDC"]["ClientID"]
|
||||||
|
OIDC_RP_CLIENT_SECRET = CONFIG["OIDC"]["ClientSecret"]
|
||||||
|
OIDC_OP_JWKS_ENDPOINT = CONFIG["OIDC"]["JWKS"]
|
||||||
|
OIDC_OP_AUTHORIZATION_ENDPOINT = CONFIG["OIDC"]["Authorization"]
|
||||||
|
OIDC_OP_TOKEN_ENDPOINT = CONFIG["OIDC"]["Token"]
|
||||||
|
OIDC_OP_USER_ENDPOINT = CONFIG["OIDC"]["UserInfo"]
|
||||||
|
OIDC_CREATE_USER = CONFIG.getboolean("OIDC", "CreateUsers", fallback=False)
|
||||||
|
OIDC_RP_SIGN_ALGO = CONFIG.get("OIDC", "Algorithm", fallback="RS256")
|
||||||
|
|
||||||
|
MIDDLEWARE.append("mozilla_django_oidc.middleware.SessionRefresh")
|
||||||
|
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
PASSWORD_HASHERS = [
|
||||||
|
"django.contrib.auth.hashers.Argon2PasswordHasher",
|
||||||
|
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
|
||||||
|
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
|
||||||
|
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
|
||||||
|
"django.contrib.auth.hashers.ScryptPasswordHasher",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# Internationalization
|
||||||
|
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
||||||
|
|
||||||
|
LANGUAGE_CODE = "en-us"
|
||||||
|
|
||||||
|
TIME_ZONE = "UTC"
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
||||||
|
|
||||||
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
STATIC_ROOT = None if DEBUG else CONFIG.get(
|
||||||
|
"PIX360", "StaticRoot", fallback=None)
|
||||||
|
|
||||||
|
STATICFILES_DIRS = [
|
||||||
|
BASE_DIR / "static",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Settings for uploaded files
|
||||||
|
|
||||||
|
MEDIA_URL = "/media/"
|
||||||
|
MEDIA_ROOT = CONFIG.get("PIX360", "MediaRoot", fallback=BASE_DIR / "media")
|
||||||
|
|
||||||
|
if "S3" in CONFIG:
|
||||||
|
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||||
|
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3StaticStorage'
|
||||||
|
AWS_ACCESS_KEY_ID = CONFIG.get("S3", "AccessKey")
|
||||||
|
AWS_SECRET_ACCESS_KEY = CONFIG.get("S3", "SecretKey")
|
||||||
|
AWS_STORAGE_BUCKET_NAME = CONFIG.get("S3", "Bucket")
|
||||||
|
AWS_S3_ENDPOINT_URL = CONFIG.get("S3", "Endpoint")
|
||||||
|
|
||||||
|
# Default primary key field type
|
||||||
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
24
pix360/urls.py
Normal file
24
pix360/urls.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
"""
|
||||||
|
URL configuration for pix360 project.
|
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
|
https://docs.djangoproject.com/en/4.2/topics/http/urls/
|
||||||
|
Examples:
|
||||||
|
Function views
|
||||||
|
1. Add an import: from my_app import views
|
||||||
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||||
|
Class-based views
|
||||||
|
1. Add an import: from other_app.views import Home
|
||||||
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||||
|
Including another URLconf
|
||||||
|
1. Import the include() function: from django.urls import include, path
|
||||||
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
|
"""
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.urls import path, include
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('admin/', admin.site.urls),
|
||||||
|
path('oidc/', include('mozilla_django_oidc.urls')),
|
||||||
|
path('', include('pix360core.urls')),
|
||||||
|
]
|
16
pix360/wsgi.py
Normal file
16
pix360/wsgi.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
WSGI config for pix360 project.
|
||||||
|
|
||||||
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pix360.settings')
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
11
requirements.txt
Normal file
11
requirements.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Django
|
||||||
|
mysqlclient
|
||||||
|
django-storages
|
||||||
|
boto3
|
||||||
|
mozilla-django-oidc
|
||||||
|
argon2-cffi
|
||||||
|
|
||||||
|
django-autosecretkey
|
||||||
|
|
||||||
|
git+https://kumig.it/kumisystems/pix360core.git
|
||||||
|
git+https://kumig.it/kumisystems/pix360_krpano.git
|
29
settings.dist.ini
Normal file
29
settings.dist.ini
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
[PIX360]
|
||||||
|
Debug = 0
|
||||||
|
Hosts = pix360.local
|
||||||
|
|
||||||
|
[OIDC]
|
||||||
|
Name = KumiDC
|
||||||
|
CreateUsers = 0
|
||||||
|
|
||||||
|
ClientID = 123456789
|
||||||
|
ClientSecret = thisverysecretsecret!
|
||||||
|
Algorithm = RS256
|
||||||
|
|
||||||
|
JWKS = https://kumidc/openid/jwks
|
||||||
|
Authorization = https://kumidc/openid/authorize
|
||||||
|
Token = https://kumidc/openid/token
|
||||||
|
UserInfo = https://kumidc/openid/userinfo
|
||||||
|
|
||||||
|
[MySQL]
|
||||||
|
database = keylog
|
||||||
|
username = keylog
|
||||||
|
password = passwords_are_very_important!
|
||||||
|
host = localhost
|
||||||
|
port = 3306
|
||||||
|
|
||||||
|
[S3]
|
||||||
|
endpoint = http://minio.local
|
||||||
|
accesskey = pix360
|
||||||
|
secretkey = secret!
|
||||||
|
bucket = pix360
|
Loading…
Reference in a new issue