Release v1.0.0

This commit is contained in:
2024-01-04 20:30:54 +01:00
commit 19c8d10645
45 changed files with 3745 additions and 0 deletions

20
docs/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

36
docs/source/api.rst Normal file
View File

@@ -0,0 +1,36 @@
API Documentation
=================
.. module:: keep_it_secret
This section provides the API documentation for Keep It Secret.
The Secrets Class
-----------------
.. autoclass:: Secrets
:members:
Base Field
----------
.. autoclass:: Field
:members:
:special-members: __call__
Concrete Fields
---------------
.. autoclass:: AbstractField
:members:
.. autoclass:: EnvField
:members:
.. autoclass:: LiteralField
:members:
.. autoclass:: SecretsField
:members:

34
docs/source/conf.py Normal file
View File

@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# type: ignore
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'Keep It Secret'
copyright = '2023-present Tomek Wójcik'
author = 'Tomek Wójcik'
version = '1.0.0'
# The full version, including alpha/beta/rc tags
release = '1.0.0'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'sphinx.ext.autodoc',
]
templates_path = ['_templates']
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

31
docs/source/ext.rst Normal file
View File

@@ -0,0 +1,31 @@
Extensions
==========
.. module:: keep_it_secret.ext
This section provides documentation for built-in extensions for Keep It Secret.
AWS Secrets Manager Wrapper
---------------------------
**Installation**
Since AWS extension has external dependencies it needs to be explicitly named
to be installed:
.. code-block:: shell
$ pip install keep_it_secret[aws]
**API**
.. autoclass:: keep_it_secret.ext.aws.AWSSecrets
:members:
.. autoclass:: keep_it_secret.ext.aws.AWSSecretsManagerField
:members:
Basic secrets loader
--------------------
.. autofunction:: keep_it_secret.ext.loader.load_secrets

16
docs/source/index.rst Normal file
View File

@@ -0,0 +1,16 @@
Keep It Secret by BTHLabs
=========================
Keep It Secret is a small Python library for declarative management
of app secrets.
.. toctree::
:maxdepth: 2
overview
.. toctree::
:maxdepth: 2
api
ext

80
docs/source/overview.rst Normal file
View File

@@ -0,0 +1,80 @@
Overview
========
This section provides the general overview of Keep It Secret.
Installation
------------
.. code-block:: shell
$ pip install keep_it_secret
Usage
-----
Keep It Secret gives a developer API needed to declare secrets used
by the app and access them in a secure, uniform manner.
Consider the following example:
.. code-block:: python
from secrets_manager import (
AbstractField, EnvField, LiteralField, Secrets, SecretsField,
)
from secrets_manager.ext.aws import AWSSecrets, AWSSecretsManagerField
class AppSecrets(Secrets):
secret_key: str = AbstractField.new()
db_password: str = EnvField.new('APP_DB_PASSWORD', required=True)
pbkdf2_iterations_count: int = EnvField(
'APP_PBKDF2_ITERATIONS_COUNT',
default=16384,
required=False,
as_type=int,
)
class DevelopmentSecrets(AppSecrets):
secret_key: str = LiteralField.new('thisisntsecure')
class ProductionSecrets(AppSecrets):
aws: AWSSecrets = SecretsField.new(AWSSecrets)
secret_key: str = AWSSecretsManagerField(
'app/production/secret_key', required=True,
)
db_password: str = AWSSecretsManagerField(
'app/production/db_password', required=True,
)
The ``AppSecrets`` class serves as base class for environment specific classes.
The environment specific classes can overload any field, add new fields and
extend the base class to provide custom behaviour.
The ``DevelopmentSecrets`` class uses environment variables and literal values
to provide secrets suitable for the development environment:
.. code-block:: pycon
>>> development_secrets = DevelopmentSecrets()
>>> development_secrets.secret_key
'thisisntsecure'
>>> development_secrets.db_password
'spam'
>>> development_secrets.pbkdf2_iterations_count
1024
The ``ProductionSecrets`` class uses environment variables and AWS Secrets
Manager to provide secrets suitable for the development environment:
.. code-block:: pycon
>>> production_secrets = ProductionSecrets()
>>> production_secrets.aws.access_key_id
'anawsaccesskey'
>>> production_secrets.secret_key
'asecuresecretkey'
>>> production_secrets.db_password
'asecuredbpassword'
>>> production_secrets.pbkdf2_iterations_count
16384