Skip to main content

secretauth is a secure, unified solution for generating and validating tokens using secret from multiple cloud platforms.

Project description

secretauth

secretauth is a secure, unified solution for generating and validating authentication tokens using secret from multiple cloud platforms.

Features

  • Standardizes authentication with a consistent interface for token management and authentication.
  • Simplifies secret key retrieval from AWS Secrets Manager. Azure Key Vault, GCP Secret Manager and more coming soon.
  • Enhances security by eliminating manual credential handling.
  • Provided option to encrypt more information using auth_id and set token expiry using expiry_seconds.
  • Reduces boilerplate code with easy-to-use methods for token generation and validation.

Requirements

Python 3.9+

Installallation

$ pip install secretauth

Usage

You can use the secretauth package in your Python code to generate authentication token using cloud provider of your choice for accessing the secret.

Example 1 - using secret key stored in aws secret manager

It uses your local aws credentials and configs from ~/.aws see Using Boto3. Only key stored as plaintext will work.

from secretauth import SecretProvider, Auth

secret_name = "secret_name_in_your_aws_secret_manager"
_auth = Auth.use_hmac256_token(secret_name=secret_name, secret_provider=SecretProvider.AWS) # initializes the auth module
token = _auth.generate_token() # generates your token
valid, auth_id, msg = _auth.validate_token(token) # validates your token

Example 2 - using secret key stored in environment variable

from secretauth import SecretProvider, Auth

secret_name = "secret_name_in_your_enviroment"
_auth = Auth.use_hmac256_token(secret_name=secret_name, secret_provider=SecretProvider.LOCAL) # initializes the auth module
token = _auth.generate_token() # generates your token
valid, auth_id, msg = _auth.validate_token(token) # validates your token

Example 3 - using secret key directly

from secretauth import SecretProvider, Auth

secret_key = "any_secret_key_can_be_used"
_auth = Auth.use_hmac256_token(secret_key=secret_key) # initializes the auth module
token = _auth.generate_token() # generates your token
valid, auth_id, msg = _auth.validate_token(token) # validates your token

Example 4 - using token expiry_seconds and auth_id

By default the token expiry time set to 1 hour. You can encrypt any useful information using auth_id.

from secretauth import SecretProvider, Auth

secret_name = "secret_name_in_your_enviroment"
authid = "userid_etc"
expiry = 60 # 1 minute
_auth = Auth.use_hmac256_token(secret_name=secret_name, secret_provider=SecretProvider.LOCAL) # initializes the auth module
token = _auth.generate_token(auth_id=authid, expiry_seconds=expiry) # generates your token
valid, auth_id, msg = _auth.validate_token(token) # validates your token

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

secretauth-1.0.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

secretauth-1.0.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file secretauth-1.0.0.tar.gz.

File metadata

  • Download URL: secretauth-1.0.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for secretauth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e7692b86e402a0185c09da637ad29380d5f9dc8c346fcd5ff968f2525b021b17
MD5 b997dbf70816a59eaab595b11e1cb40f
BLAKE2b-256 b559f2549085b42a3398d00c6e49d6ec4bbca9dad7249b0706545f70f27a879d

See more details on using hashes here.

File details

Details for the file secretauth-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: secretauth-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for secretauth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1b9cd89d6ca60c4ff3f07426dffafee6b02f6e8e0fbb31be2264363daff91eb
MD5 144cd768a7cc26b0686204117aeb7d8e
BLAKE2b-256 8dc822a0d0d8fc5921e46dd79c296cdd8bf8900dc5076e3d87824ce3fb131b30

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