Skip to main content

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

Project description

Lock Nessie

Easily integrate OpenID authentication and authorization into your Nessie and Apache Iceberg projects.

Lock Nessie is a drop-in tool that handles OpenID RBAC for you, so you don't have to roll your own. It works for both interactive users (scripts, Jupyter notebooks) and service accounts (ETL, headless/daemon jobs), making it simple to get and refresh tokens for your Nessie metadata server.


Features

  • Drop-in OpenID Auth for Nessie/Iceberg: No need to implement RBAC yourself.
  • CLI and Python Module: Use from the command line or directly in your code.
  • Supports User and Daemon Auth: Interactive browser login or headless service account flows.
  • Easy Configuration: One-time setup, then use everywhere.

Installation

You can install Lock Nessie using either pip or uv:

# With pip
pip install locknessie[microsoft]

# Or with uv (faster alternative to pip)
uv pip install locknessie[microsoft]

# For other providers in the future
# pip install locknessie[keycloak]
# uv pip install locknessie[keycloak]

Quickstart

1. Configure Lock Nessie

Run the following to set up your config file (by default at ~/.locknessie/config.json):

locknessie config init

You'll be prompted for your OpenID provider and credentials (e.g., Microsoft client ID, secret & tenant for daemon auth).

You can update settings later if needed:

locknessie config set <key> <value>

or by editing the file directly.


2. Get a Token (CLI)

Get a valid OpenID bearer token for your Nessie server:

locknessie token show
  • The first time, you'll be prompted to log in via browser (for user auth).
  • For daemon/service accounts, set up your secret and tenant during config.

This is all the setup you need. The refresh token is stored locally, and the cycle can now run as long as the provider's refresh token is valid. When the refresh token expires you will be prompted to log in via browser again.

[!Note] If you are running locknessie in a container, the url for the browser login will be printed into the container logs. Make sure the auth_callback_port is exposed or locknessie will not be able to complete the auth flow and log you in.


3. Use in Python Scripts

from locknessie.main import LockNessie

# Get a valid token (auto-refreshes as needed)
token = LockNessie().get_token()

# Use with your Nessie/Iceberg client
from pyiceberg.catalog import load_catalog

catalog = load_catalog(
    "nessie",
    uri="https://your-nessie-instance.com/iceberg/main/",
    token=token
)

4. Headless/Daemon Auth

To use Lock Nessie in headless or daemon mode (for service accounts, ETL jobs, CI/CD, etc.), you must provide an OpenID secret from your authentication provider (such as Microsoft or Keycloak). This secret is required for non-interactive authentication and can be set in any of the following ways:

  • CLI: During locknessie config init or with locknessie config set openid_secret <your-secret>
  • Config file: Add "openid_secret": "<your-secret>" to your config JSON
  • Environment variable: Set LOCKNESSIE_OPENID_SECRET=<your-secret>

You will also need to provide any other required settings for your provider (e.g., LOCKNESSIE_OPENID_TENANT for Microsoft).

Once configured, you can use the CLI or Python module as shown above, and Lock Nessie will use the daemon/service account flow to obtain tokens without requiring browser interaction.


Configuration & Environment Variables

You can set any Lock Nessie configuration value in three ways:

  1. CLI Argument: Pass as a command-line argument (e.g., --auth-callback-port 4321).
  2. Environment Variable: Set with the LOCKNESSIE_ prefix (e.g., LOCKNESSIE_AUTH_CALLBACK_PORT=4321).
  3. Config File: Edit the config file directly (default: ~/.locknessie/config.json) or use the CLI tool (e.g., locknessie config set auth_callback_port 4321).

Order of evaluation (highest priority first):

  1. CLI argument (e.g., locknessie token show --auth-callback-port 4321)
  2. Environment variable (e.g., LOCKNESSIE_AUTH_CALLBACK_PORT=4321 locknessie token show)
  3. Config file (manually edit or use locknessie config set)

All config values can be set using any of these methods, and Lock Nessie will use the highest-priority value found.

Required for all providers:

  • LOCKNESSIE_OPENID_ISSUER: The OpenID provider (microsoft, keycloak)
  • LOCKNESSIE_OPENID_CLIENT_ID: The client/application ID

Microsoft-specific:

  • LOCKNESSIE_OPENID_TENANT: Tenant ID (required for daemon/service auth)
  • LOCKNESSIE_OPENID_SECRET: Application secret (required for daemon/service auth)

Keycloak (future):

  • LOCKNESSIE_OPENID_REALM: Keycloak realm
  • LOCKNESSIE_OPENID_URL: Keycloak server URL

Other settings:

  • LOCKNESSIE_CONFIG_PATH: Path to config file (default: ~/.locknessie/config.json)
  • LOCKNESSIE_AUTH_CALLBACK_PORT: Port for browser-based auth (default: 1234)
  • LOCKNESSIE_IMPERSONATION_PORT: Port for Vault impersonation service (default: 8200)
  • LOCKNESSIE_AUTH_CALLBACK_HOST: Host for callback server (default: 0.0.0.0)

CLI Reference

  • locknessie config init — Initialize config file
  • locknessie config set <key> <value> — Set a config value
  • locknessie token show — Print a valid OpenID token

Use Cases

  • Jupyter notebooks: Authenticate and use Nessie/Iceberg with one line.
  • ETL/Service jobs: Headless daemon/service account auth with environment variables.

Provider Support

  • Microsoft Entra/Azure AD: Supported (user and daemon/service flows)
  • Keycloak: Coming soon

Contributing

PRs and issues welcome!


License

MIT

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-1.1.0.tar.gz (55.5 kB view details)

Uploaded Source

Built Distribution

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

locknessie-1.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for locknessie-1.1.0.tar.gz
Algorithm Hash digest
SHA256 821ffb439e0242fd4c7b28f45d1aa77426b880e4bed9ef544da93ffb081dc87c
MD5 e69ffa801da547fa9879ce59aa6c06e9
BLAKE2b-256 6309a4c2eb93175f6ae94ad3fe753168d4ffadaa504cdda60d0ce7bae76149ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for locknessie-1.1.0.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-1.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for locknessie-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbeae5f840087db9a03114d2d536850bf1e083e06fdcc3e64839ef30f482d562
MD5 28c2e4962137762614cc35b58eaade0a
BLAKE2b-256 3bcbfc49fc82f5910853eae6116defd6dcef8257a666f36d1b06f094c728e889

See more details on using hashes here.

Provenance

The following attestation bundles were made for locknessie-1.1.0-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