Skip to main content

Django Secret Sharing

Version CI

A secure sharing app for Django.

Features

  • Keep sensitive information out of your chat logs and email via a secure sharing protocol
  • REST API
  • One time secrets
  • Expiry dates
  • Create random passwords
  • Secure S3 presigned file transfers

Requirements

  • Python >=3.11
  • Django >= 5.2

Installation

Install the package

pip install django-secret-sharing

If you use file trasfers with AWS S3, install the package with pip install django-secret-sharing[aws].

Add django_secret_sharing to your INSTALLED_APPS

INSTALLED_APPS = [
    ...
    "django_secret_sharing",
]

Add the urls (api_urls not needed when you don't use file transfers or any other API features)

urlpatterns = [
  ...
  path("secrets/", include("django_secret_sharing.urls"),),
  path("api/secrets/", include("django_secret_sharing.api_urls"),),
]

Run migrate

manage.py migrate

Templates

Override the default templates with your own

django_secret_sharing/create.html

{% if secret_url %}
    <p>{{ secret_url }}</p>
    <a href="{% url 'django_secret_sharing:create' %}">Create</a>
{% else %}
  <form action="{% url 'django_secret_sharing:create' %}" method="post">
      {% csrf_token %}
      {{ form }}
      <input type="submit" value="Submit">
      <a href="{% url 'django_secret_sharing:generate-password' %}">Generate password</a>
  </form>
{% endif %}

{% block scripts %}
{% include "django_secret_sharing/file_transfer_simple.html" %}
{% include "django_secret_sharing/file_transfer_scripts.html" %}
{% endblock %}

django_secret_sharing/retrieve.html

<a href="{% url 'django_secret_sharing:view' url_part %}">View</a>

django_secret_sharing/view.html

<textarea disabled>{{ value }}</textarea>
{% if secret.files.all %}
<ul>
    {% for file in secret.files.all %}
    <li>
        <a href="{{ file.download_url }}" target="_blank" ref="noopener noreferrer">{{ file.filename }}</a>
    </li>
    {% endfor %}
</ul>
{% endif %}
<a href="{% url 'django_secret_sharing:create' %}">Create</a>

File transfers

File transfers are supported out of the box in this app.

Key is the value of the hidden input file_refs. If any file should be send along with the sercret to be created, make sure it's uploaded via a secure upload url (retrieved via the API). The uploaded file ref (commonly the path to the uploaded file) should be appended to the file_refs value (comma-separated for multiple files).

Important to know is that the upload path is generated via the backend and it's unique. This way we prevent the user can overwrite/see files, in any way, from other users.

Make sure before submitting the form the files are uploaded (e.g. show a user friendly progress bar during this process).

In order to provide a interface for uploading files and put the value in the file_refs input JavaScript is needed. As this implementation is very client specific, it's up to to build that part of the code. Although, for the very minimalistic implementation (and example), we offer a default JavaScript implementation; see django_secret_sharing/file_transfer_simple.html. We do recommend build your own with e.g. a proper drag & drop interface.

You can also only include the uploadFile JavaScript method by including django_secret_sharing/file_transfer_scripts.html into your template and use it with your bespoke JavaScript implementation.

Note: make sure your AWS S3 bucket is set to private and CORS permissions are setup correctly (advice is to keep the rules as strict as possible for best security measurements).

file_transfer_scripts.html

window.handleSecretFileUploaded

This method can optionally be defined in your JavaScript in order to handle successfull file upload (tip: use it for setting the file_refs value).

Example:

const fileRefsInput = document.getElementById('id_file_refs');

window.handleSecretFileUploaded = (fileRef, file) => {
  fileRefsInput.value = fileRefsInput.value.split(",").concat(fileRef).join(",")
};

Commands

delete_expired_files

Deletes expired and unfinished files. It's recommended to run this command at least once a day in order to minimize storage limitations (or increase costs optimizations).

Troubleshooting

botocore.exceptions.ClientError: An error occurred (400) when calling the HeadObject operation: Bad Request

Add the AWS_DEFAULT_REGION environment variable, e.g. with eu-west-1.

My files are publicly available in AWS S3

Bad thing! Make sure your bucket permissions are set to private (default).

Metadata

Release files for django-secret-sharing 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-secret-sharing 0.8.1
File Size Uploaded Provenance Actions
django_secret_sharing-0.8.1.tar.gz 18.6 kB With provenance Details for django_secret_sharing-0.8.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-secret-sharing 0.8.1
File Interpreter ABI Platform Actions
django_secret_sharing-0.8.1-py3-none-any.whl Python 3 none any Details for django_secret_sharing-0.8.1-py3-none-any.whl

Total release size: 42.3 kB

Release files / django_secret_sharing-0.8.1.tar.gz

Download URL django_secret_sharing-0.8.1.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fcf5fb7be6eb81f003b0fbfaa0b59769a6bd879f993d4af8dc08603bf6f9da42
BLAKE2b-256 checksum
How to use checksums
f5cf5351bc346abd43ae65824f809f02c032c319d2ec438a9c5c3390a75f922d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Release files / django_secret_sharing-0.8.1-py3-none-any.whl

Download URL django_secret_sharing-0.8.1-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
305fd590af9825ede16c8c68019d2ef881437d90ea00caf6559ea57b47ebe0ea
BLAKE2b-256 checksum
How to use checksums
ecc86e02def64be9e9162b330481a59eee3131d40e467090851e09a8b6a44fa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Security for django-secret-sharing 0.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_secret_sharing-0.8.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page