Skip to main content

Lock-Nessie provides a client and server pair for authentication to Nessie with OpenID.

Project description

Lock Nessie

logo

Quickly and simply add OpenID auth to your Iceberg Nessie stack.

Installation

  • pip install locknessie
  • uv add locknessie

Or use the docker image (primarily intended for server):

docker run --rm --env-file .env -p 8080:8080 ghcr.io/pirate-baby/lock-nessie:latest # starts the server at http://localhost:8080

OpenID auth requires a server that can facilitiate the login flow, and a client that can store (and re-request as needed) the resulting bearer token once that flow has been completed. lock-nessie provides both of those for nessie-compatible Iceberg REST clients.

Server

This component facilitiates your OpenID Oauth2 login flow.

Envars:

Required for all providers:

  • LOCKNESSIE_ENVIRONMENT: 'production' for released code, 'development' for local development
  • LOCKNESSIE_REDIRECT_BASE: The base URL for redirects
  • LOCKNESSIE_OPENID_ISSUER: The issuer of the OpenID client, one of:
    • microsoft # entra
    • keycloak
  • LOCKNESSIE_OPENID_CLIENT_ID: The client ID of the OpenID client
  • LOCKNESSIE_OPENID_CLIENT_SECRET: The client secret of the OpenID client
  • LOCKNESSIE_SECRET_PROVIDER: The provider where the secret is stored, one of:
    • aws_secrets_manager
    • hachicorp_vault

Required for microsoft:

  • LOCKNESSIE_OPENID_TENANT: The tenant of the OpenID client (required for Microsoft)

Required for keycloak:

  • LOCKNESSIE_OPENID_REALM: The realm of the OpenID client (required for Keycloak)
  • LOCKNESSIE_OPENID_URL: The URL of the OpenID provider

Required for aws: note: lock-nessie uses the standard boto3 credentials order. For lock-nessie to leverage AWS Secrets Manager, credentials must be provided that have:

    "secretsmanager:CreateSecret",       // Create a new secret
    "secretsmanager:GetSecretValue",     // Read the secret value
    "secretsmanager:DescribeSecret",     // Read secret metadata
    "secretsmanager:PutSecretValue"      // Write/update secret value

Optional:

  • LOCKNESSIE_MAX_AGE: The maximum age of the cookie in seconds (default: 31536000 - 1 year). Note this is not the same as the token age for the OpenID auth.

Modifying the home template

The home.html template is used for the root path ("/") for both authed and unauthed users. It is a standard Jinja2 template with the following context variables passed to it:

  • request: The FastAPI request object, where login cookies have been assigned.
  • user: The username of the logged-in user (None if not logged in)
  • is_logged_in: Boolean indicating if a user is logged in
  • expires: Datetime object of when the session expires (None if not logged in)
  • time_until_expiry: Human-readable string of time until session expires (None if not logged in)
  • aws_secret_arn: Optional AWS secret ARN if provided as a get param (from a successful login)

You can create a different template that matches your company/use case and set LOCKNESSIE_TEMPLATES_DIR_PATH to override the location.

![WARNING] The template file must be named home.html to override the default template.

Client:

Required for all providers:

  • LOCKNESSIE_SECRET_PROVIDER: The provider where the secret is stored, one of:
    • aws_secrets_manager
    • hachicorp_vault
  • LOCKNESSIE_SECRET_IDENTIFIER: The resource id for the secret, like an arn in aws.

Optional:

  • LOCKNESSIE_CACHE_PATH: Where to store the cached OpenID token.
  • LOCKNESSIE_SERVER_URL: If provided, the client will attempt to pop open a login window when the token has expired.

Client integrations

PyIceberg

from locknessie.client.pyiceberg import load_catalog

catalog = load_catalog("nessie", uri="http://nessie:19120/iceberg/main/")

note: There is a bunch of auth bits in pyiceberg that indicate better integration may be possible, but it is non-obvious how a web-based login flow, refresh token etc would work in practice. TODO see if this can be refined.

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

locknessie-0.0.3.tar.gz (391.8 kB view details)

Uploaded Source

Built Distribution

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

locknessie-0.0.3-py3-none-any.whl (368.6 kB view details)

Uploaded Python 3

File details

Details for the file locknessie-0.0.3.tar.gz.

File metadata

  • Download URL: locknessie-0.0.3.tar.gz
  • Upload date:
  • Size: 391.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for locknessie-0.0.3.tar.gz
Algorithm Hash digest
SHA256 825c63157473d3547096efcb80404b7b0dd9e908a9a8c7581c3070c17ba2d1d2
MD5 cf06ad8cebbdb026f940a4df59c9dcba
BLAKE2b-256 040df2ff30631cb6c9d07d8c442ece12f8a694901d6f3ee9016faaff3c51b5de

See more details on using hashes here.

Provenance

The following attestation bundles were made for locknessie-0.0.3.tar.gz:

Publisher: publish.yml on pirate-baby/lock-nessie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file locknessie-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: locknessie-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 368.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for locknessie-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c9acf20e016c9fa8dd7d064f0da53d3c803a16acb8b4566da9e821d8ac58a462
MD5 074200b1d2516c4f8c31a3d204866a65
BLAKE2b-256 76a6d64ba3a2e88ae63d8483d63475d867097233518fa325906df29c69b464f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for locknessie-0.0.3-py3-none-any.whl:

Publisher: publish.yml on pirate-baby/lock-nessie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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