diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..bee434d --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,35 @@ +# Read the Docs configuration file for Sphinx projects +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the OS, Python version and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.12" + # You can also specify other tool versions: + # nodejs: "20" + # rust: "1.70" + # golang: "1.20" + +# Build documentation in the "docs/" directory with Sphinx +sphinx: + configuration: docs/conf.py + # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs + # builder: "dirhtml" + # Fail on all warnings to avoid broken references + # fail_on_warning: true + +# Optionally build your docs in additional formats such as PDF and ePub +formats: + - pdf + - epub + +# Optional but recommended, declare the Python requirements required +# to build your documentation +# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +python: + install: + - requirements: docs/requirements.txt diff --git a/LICENSE.md b/LICENSE.md index 8f2d27a..df313e7 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2011, SD Elements +Copyright (c), SD Elements All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/docs/conf.py b/docs/conf.py index bd66d82..d61589e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,19 +14,19 @@ import os import sys +import django + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.append(os.path.dirname(__file__)) -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings") +django.setup() # -- General configuration ----------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ - "sphinx.ext.autodoc", -] +extensions = ["sphinx.ext.autodoc", "sphinx_rtd_theme"] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] @@ -42,7 +42,7 @@ # General information about the project. project = "django-security" -copyright = "2013, SD Elements" +copyright = "2024, SD Elements" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -95,7 +95,7 @@ # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = "default" +html_theme = "sphinx_rtd_theme" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..0df8acd --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,4 @@ +# Defining the exact version will make sure things don't break +sphinx==5.3.0 +sphinx_rtd_theme==1.1.1 +readthedocs-sphinx-search==0.1.1 diff --git a/security/auth.py b/security/auth.py index 0b42bf1..dcebaaa 100644 --- a/security/auth.py +++ b/security/auth.py @@ -1,5 +1,3 @@ -# Copyright (c) 2011, SD Elements. See LICENSE.txt for details. - from django.core.validators import RegexValidator from django.forms import ValidationError from django.utils.translation import gettext as _ diff --git a/security/auth_throttling/__init__.py b/security/auth_throttling/__init__.py index 8a8869c..a0e3258 100644 --- a/security/auth_throttling/__init__.py +++ b/security/auth_throttling/__init__.py @@ -1,8 +1,6 @@ -# Copyright (c) 2011, SD Elements. See ../LICENSE.txt for details. - import hashlib import logging -import time # Monkeypatched by the tests. +import time from math import ceil from django.contrib.auth import REDIRECT_FIELD_NAME diff --git a/security/auth_throttling/views.py b/security/auth_throttling/views.py index ea283b6..16998e8 100644 --- a/security/auth_throttling/views.py +++ b/security/auth_throttling/views.py @@ -1,5 +1,3 @@ -# Copyright (c) 2011, SD Elements. See ../LICENSE.txt for details. - import logging from django.contrib.auth.models import User diff --git a/security/forms.py b/security/forms.py index 368afd7..269a4d8 100644 --- a/security/forms.py +++ b/security/forms.py @@ -1,5 +1,3 @@ -# Copyright (c) 2011, SD Elements. See LICENSE.txt for details. - import django.contrib.auth.forms from django import forms from django.utils.translation import gettext_lazy as _ diff --git a/security/middleware.py b/security/middleware.py index bf28218..f5289ad 100644 --- a/security/middleware.py +++ b/security/middleware.py @@ -1,5 +1,3 @@ -# Copyright (c) 2011, SD Elements. See LICENSE.txt for details. - import cProfile import importlib import json @@ -1077,20 +1075,19 @@ class ReferrerPolicyMiddleware(BaseMiddleware): Sends Referrer-Policy HTTP header that controls when the browser will set the `Referer` header. Use REFERRER_POLICY option in settings file with the following values: - - - ``no-referrer`` - - ``no-referrer-when-downgrade`` - - ``origin`` - - ``origin-when-cross-origin`` - - ``same-origin`` (*default*) - - ``strict-origin`` - - ``strict-origin-when-cross-origin`` - - ``unsafe-url`` - - ``off`` + - ``no-referrer`` + - ``no-referrer-when-downgrade`` + - ``origin`` + - ``origin-when-cross-origin`` + - ``same-origin`` (*default*) + - ``strict-origin`` + - ``strict-origin-when-cross-origin`` + - ``unsafe-url`` + - ``off`` Reference: - `Referrer-Policy from Mozilla Developer Network - ` + ` """ OPTIONAL_SETTINGS = ("REFERRER_POLICY",) diff --git a/security/models.py b/security/models.py index 9969752..1ac7ad7 100644 --- a/security/models.py +++ b/security/models.py @@ -1,4 +1,3 @@ -# Copyright (c) 2011, SD Elements. See LICENSE.txt for details. from django.conf import settings from django.contrib.auth.models import User from django.db import models diff --git a/security/password_expiry.py b/security/password_expiry.py index 3e2ce29..47cdb67 100644 --- a/security/password_expiry.py +++ b/security/password_expiry.py @@ -1,5 +1,3 @@ -# Copyright (c) 2011, SD Elements. See LICENSE.txt for details. - from django.conf import settings from .models import PasswordExpiry diff --git a/security/views.py b/security/views.py index 8ff6536..cb6fff9 100644 --- a/security/views.py +++ b/security/views.py @@ -1,5 +1,3 @@ -# Copyright (c) 2011, SD Elements. See LICENSE.txt for details. - import json import logging diff --git a/tests/tests.py b/tests/tests.py index 2f249cd..29acd62 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,5 +1,3 @@ -# Copyright (c) 2011, SD Elements. See LICENSE.txt for details. - import datetime import json import time # We monkeypatch this. diff --git a/tests/urls.py b/tests/urls.py index 5c302a2..e418192 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,5 +1,3 @@ -# Copyright (c) 2011, SD Elements. See ../LICENSE.txt for details. - from django.contrib.auth.views import LoginView, PasswordChangeView from django.http import HttpResponse from django.urls import path, re_path