Glue token validation + user service to provide identity context in FastAPI
Project description
Python Package Template
The template repository for creating python packages, shared across auth-broker.
🦜🕸️
Table of Contents
Introduction
This template repository aims to create a reusable package template which streamlines the creation and publishing of isolated python packages in auth-broker. This is aligned with the engineering vision @ auth-broker for better modularisation and reusability of code.
Quick Start
Since this is just a package, and not a service, there is no real "run" action. But you can run the tests immediately.
Here are a list of available commands via make.
Bare Metal (i.e. your machine)
make install- install the required dependencies.make test- runs the tests.
Docker
make build-docker- build the docker image.make run-docker- run the docker compose services.make test-docker- run the tests in docker.make clean-docker- remove all docker containers etc.
Installation
For Dev work on the repo
Install uv, (if you haven't already)
https://docs.astral.sh/uv/getting-started/installation/#installation-methods
brew install uv
Initialise pre-commit (validates ruff on commit.)
uv run pre-commit install
Install dependencies (including dev dependencies)
uv sync
If you are adding a new dev dependency, please run:
uv add --dev {your-new-package}
Namespaces
Packages all share the same namespace ab_core. To import this package into
your project:
from ab_core.template import placeholder_func
We encourage you to make your package available to all of ab via this
ab_core namespace. The goal is to streamline development, POCs and overall
collaboration.
Usage
Adding the dependency to your project
The library is available on PyPI. You can install it using the following command:
Using pip:
pip install package-identity-context
Using UV
Note: there is currently no nice way like poetry, hence we still needd to provide the full url. https://github.com/astral-sh/uv/issues/10140
Add the dependency
uv add package-identity-context
Using poetry:
Then run the following command to install the package:
poetry add package-identity-context
How tos
Example Usage
# Please update this based on your package!
from ab_core.template import placeholder_func
if __name__ == "__main__":
print("This is a placeholder: ", placeholdder_func())
Formatting and linting
We use Ruff as the formatter and linter. The pre-commit has hooks which runs checking and applies linting automatically. The CI validates the linting, ensuring main is always looking clean.
You can manually use these commands too:
make lint- check for linting issues.make format- fix linting issues.
CICD
Publishing to PyPI
We publish to PyPI using Github releases. Steps are as follows:
- Manually update the version in
pyproject.tomlfile using a PR and merge to main. Useuv version --bump {patch/minor/major}to update the version. - Create a new release in Github with the tag name as the version number. This
will trigger the
publishworkflow. In the Release window, type in the version number and it will prompt to create a new tag. - Verify the release in PyPI
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ab_identity_context-0.2.0.tar.gz.
File metadata
- Download URL: ab_identity_context-0.2.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20684055fb80d55a8de6f3987842c633e359ba8a302900a5f79522b33182df45
|
|
| MD5 |
9e02d7a8a6f65f4373562b4e614d35b4
|
|
| BLAKE2b-256 |
b734850cf7c720363d0dc1d09df66849d5a89431a92665644715aecca0119181
|
File details
Details for the file ab_identity_context-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ab_identity_context-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27f0aca047562cef0113ad347193ae9240a1b6c8e39bd5873afbaf2e8e3bbc65
|
|
| MD5 |
5e30c6a146f401cc2b60331f9cd7d9c5
|
|
| BLAKE2b-256 |
aba48ca470a4236bb58b201476d486a8ec11e48cc99f863a4283a4bfa39b4d23
|