Skip to main content

Easy manipulation of RFC8959 secret-token URIs

Project description

secret-token

This is a utility library for working with RFC8959 secret-token URIs.

It provides 3 functions:

  • encode - Encodes a generated secret into a URI
  • decode - Decodes a URI for passing secrets to systems that do not support URI data
  • validate - Checks if a secret-token URI is conforms to the spec

There are two main expected use cases for this library:

  1. Creating a service that generates and validates user secrets such as an API server. As per the RFC all secrets should be stored at rest encoded as URIs, so the encode function is used immediately after generating tokens and the validate function is called when recieving tokens from users.
  2. Use in a service that talks to external services that do not support RFC8959 but where you would like to store all your secrets using it. For example, in an environment with an appropriate secret token present:
export API_TOKEN='secret-token:E92FB7EB-D882-47A4-A265-A0B6135DC842%20foo'

The decoding code will look like this:

import os

import secret_token

API_TOKEN = secret_token.decode(os.environ.get["API_TOKEN"])
print(API_TOKEN)

The code prints

E92FB7EB-D882-47A4-A265-A0B6135DC842 foo

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

secret_token-1.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secret_token-1.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file secret_token-1.1.0.tar.gz.

File metadata

  • Download URL: secret_token-1.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for secret_token-1.1.0.tar.gz
Algorithm Hash digest
SHA256 bc60c5a6a25f3d1c4cc2285c1ac85ce68288b8e9a5a57a870e2d162db674a8b0
MD5 1f745619443ed62b7ba2948ad0572159
BLAKE2b-256 83b70f35440b30dbf06919fd6ac779a45f892f78ab989e1f19e1f93ab97677d8

See more details on using hashes here.

File details

Details for the file secret_token-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: secret_token-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for secret_token-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57aa6b5d9f363746ec10e67772171c7406dbc064fdc9d8f166325aaa6c063b6f
MD5 28c0a51de585ab27139b8128f351f301
BLAKE2b-256 383af25a3261d3a574612793d6e8ded73c7f7efe493c96e3f33d4a600fab56c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page