Skip to main content

nf_ndc_connect_public

One Logic, Three Platforms. This library provides a unified, secure, and high-performance Identity Provider (IDP) Claims & Authorization helper. It is written in Rust and compiled for:

  • Rust (Native Crate)
  • Python (via PyO3)
  • Node.js / Web (via Wasm-Pack)

It handles JWT validation, Role-Based Access Control (RBAC) checks, and parsing of complex IDP organization trees efficiently by parsing the token once into a context object.


📦 Installation

🦀 Rust

cargo add nf_ndc_connect_public

🐍 Python

pip install nf_ndc_connect_public

📦 Node.js (npm)

npm install @dhilipsiva/nf_ndc_connect_public

🔑 Organization Context & Auto-Resolution

The library uses a Context Object Pattern. You validate the JWT once to get a User object, which holds the parsed state including pre-computed group summaries.

Each summary contains:

  • org_short_code — The short name of the group (the part after / in a fully-qualified group name like owner/group_name).
  • role — The role the user holds in that group.
  • permissions — Permissions scoped to that role.

When checking roles or permissions on this User object:

  • Explicit Context: If you provide a group_name (the org_short_code), checks are performed strictly against that group's summary.
  • Auto-Resolution: If you omit group_name (pass None / null):
    • If the user belongs to exactly one group, that group is used automatically.
    • If the user belongs to multiple groups (or zero), the function returns an Error (Ambiguous Context).

🚀 Usage

🐍 Python Example

In Python, helper.validate(jwt) returns a CasdoorUser object. All checks are performed on this object.

from nf_ndc_connect_public import IdpAuthHelper
import json

# 1. Initialize
with open("cert.pem", "r") as f:
    public_key = f.read()

helper = IdpAuthHelper(public_key)
raw_jwt = "eyJhbGciOiJ..."

# 2. Parse User Context
try:
    user = helper.validate(raw_jwt)
except ValueError as e:
    print(f"❌ Validation failed: {e}")
    exit(1)

# 3. Check Single Role/Permission (Explicit Context)
# NOTE: Use the org_short_code, not the fully-qualified group name
group_name = "nf-apex"
if user.has_role("nf-apex-adm", group_name):
    print("User is Admin!")

# 4. Check Multiple Permissions
# has_permissions = ALL must match (AND)
if user.has_permissions(["read", "write"], group_name):
    print("User has full R/W access")

# has_permissions_any = AT LEAST ONE must match (OR)
if user.has_permissions_any(["edit", "admin"], group_name):
    print("User has elevated privileges")

# 5. Get full authorization tree
print(json.loads(user.get_auth_summary()))

# 6. Convenience getters
print(user.username)          # User's name
print(user.email)             # User's email
print(user.dj_id)             # User's id_card
print(user.org_short_codes)   # All org short codes

📦 Node.js / Web Example

In JavaScript/TypeScript, helper.validate(jwt) returns a CasdoorUser object.

import { IdpAuthHelper } from "@dhilipsiva/nf_ndc_connect_public";

const helper = new IdpAuthHelper(publicKey);
const user = helper.validate(rawJwt);

// NOTE: Use the org_short_code, not the fully-qualified group name
const groupName = "nf-apex";

// 1. Single Check
if (user.hasPermission("write", groupName)) {
    console.log("Can write!");
}

// 2. Multiple Permissions (Exhaustive - AND)
// Returns true only if user has BOTH "read" AND "write"
if (user.hasPermissions(["read", "write"], groupName)) {
    console.log("Full Access");
}

// 3. Multiple Permissions (Iterative - OR)
// Returns true if user has EITHER "edit" OR "delete"
if (user.hasPermissionsAny(["edit", "delete"], groupName)) {
    console.log("Can modify content");
}

// 4. Auto-Resolution (Pass null for group)
try {
    user.hasPermissionsAny(["read"], null);
} catch (e) {
    console.error("Ambiguous Context:", e.message);
}

// 5. Convenience getters
console.log(user.username);
console.log(user.email);
console.log(user.isAdmin);

🦀 Rust Example

In Rust, helper.parse_user(jwt) returns a CasdoorUser struct.

use nf_ndc_connect_public::AuthHelper;

fn main() {
    let helper = AuthHelper::new(public_key).unwrap();
    let user = helper.parse_user(jwt).unwrap();

    // NOTE: Use the org_short_code, not the fully-qualified group name
    let group = Some("nf-apex");

    // 1. Single Check
    if user.has_permission("read", group).unwrap() {
        println!("Can read");
    }

    // 2. Multiple Checks (Vec<String>)
    let required = vec!["read".to_string(), "write".to_string()];

    // Check ALL
    if user.has_permissions(&required, group).unwrap() {
        println!("Has all permissions");
    }

    // Check ANY
    if user.has_permissions_any(&required, group).unwrap() {
        println!("Has at least one permission");
    }

    // 3. Convenience accessors
    println!("{}", user.username());
    println!("{:?}", user.email());
    println!("{}", user.get_org_count());
}

🛠️ Development

This project uses Nix for a reproducible environment and Just for command automation.

Prerequisites

  1. Install Nix.
  2. Enable flakes.

Setup

nix develop

Build Commands (via just)

Command Description
just py-dev Build Python wheel in debug mode & install to venv
just py-build Build Python wheel for release
just wasm Build the Wasm package for Node.js/Web
just test Run standard Cargo tests

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nf_ndc_connect_public-0.18.1.tar.gz (46.5 kB view details)

Uploaded Source

Built Distributions

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

nf_ndc_connect_public-0.18.1-cp313-cp313-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.13Windows x86-64

nf_ndc_connect_public-0.18.1-cp313-cp313-manylinux_2_38_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

nf_ndc_connect_public-0.18.1-cp313-cp313-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

nf_ndc_connect_public-0.18.1-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12Windows x86-64

nf_ndc_connect_public-0.18.1-cp312-cp312-manylinux_2_38_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

nf_ndc_connect_public-0.18.1-cp312-cp312-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

nf_ndc_connect_public-0.18.1-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11Windows x86-64

nf_ndc_connect_public-0.18.1-cp311-cp311-manylinux_2_38_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ x86-64

nf_ndc_connect_public-0.18.1-cp311-cp311-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

nf_ndc_connect_public-0.18.1-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10Windows x86-64

nf_ndc_connect_public-0.18.1-cp310-cp310-manylinux_2_38_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.38+ x86-64

nf_ndc_connect_public-0.18.1-cp310-cp310-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file nf_ndc_connect_public-0.18.1.tar.gz.

File metadata

  • Download URL: nf_ndc_connect_public-0.18.1.tar.gz
  • Upload date:
  • Size: 46.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for nf_ndc_connect_public-0.18.1.tar.gz
Algorithm Hash digest
SHA256 ff831868436c5b1800ec1d4ff8c35d9cb6e2377e5ada4ae52e5a2a0a918931ec
MD5 03311571cdf7f23c9a363487df8bcfb7
BLAKE2b-256 2953464f73c385b5c754edf1cdba192791bbc92310cd334666f3e016e6cffd05

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1.tar.gz:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9790dfeda3e14c6b5fbb2ea5cea61310561365fea6b6c08de509e800700dee41
MD5 9ffbe4c0b628ed5c8d9417390d44f3d0
BLAKE2b-256 79c83252319fd8f073529799abfd1fe2e790cb6b89cea56612c1db000bc1f0e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp313-cp313-win_amd64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 ac98bad91ebc421fe54204db9303fb408d735259a85d559afe0a60d2c0c95d3e
MD5 d9e86416696e32690ae3924f1f268e6f
BLAKE2b-256 5a303c5692d7398142eee5227c0ae27083e5ed2c359c76a70cd2b96e2269552f

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp313-cp313-manylinux_2_38_x86_64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14232c01c391acef73d4f79ff653466ba76e6816b356c1cef98a10b59a50c230
MD5 2e147f0d9c28bc27ed92177fbda73db4
BLAKE2b-256 d75c27b9c0ab96265fd00865a3c724e51805706dbcb3569987544d35484ba03d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f498963b1943a8c7b3611a0d02df676e6bc80e444fefb4fe88bdf946622bf12f
MD5 a6cd7861c163d4a412e8144e7d1b2272
BLAKE2b-256 0d38acb774b23d0592968051c2395448f6d107bc0e27e4c25b52767239fa7556

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp312-cp312-win_amd64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 0b75e89662f309db8b7257bd7da4820eac91c3bfdcaaf28da765c6418bf14e66
MD5 cd417e913248bf25ae4b193bbe8aa64a
BLAKE2b-256 3b1299d3be7b68e1224bf7271da19144f8fb6d5f15abc093b9c2dd3c23377f0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp312-cp312-manylinux_2_38_x86_64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aaa676ca814ffaa583124820d4192c4b282dfc3b24e046686b13fee65218da3f
MD5 34d37a0f5206b1870f22e7004966e6f6
BLAKE2b-256 bd6aaa42827a7827aa650e32a97d5e83b4857b998c883398127d112cbf05432b

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 82f82353757de733fddd403396de60022120c271efe41b7b9a63ea38c19e2450
MD5 f99dd68084d4909157effd9332631550
BLAKE2b-256 4f04b3aad9824178fd717b6a86d1c7d344678896d04a384b1aa0948125132a42

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp311-cp311-win_amd64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp311-cp311-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 53770836562fc130f1cb4d2588749127d5c0d709c89f06b84319d33997e1bd6c
MD5 aa6fbbf1f6d91c99c02388df1f9dbfb8
BLAKE2b-256 ea71b68d50b282bd1ffee32b081324e137a6a98c7aa69959ef8fdc0c849a3e2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp311-cp311-manylinux_2_38_x86_64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cea718c0624b2a70308610d8da3aaf4bd55cfc50aece8b3806dfaf336036a221
MD5 62c308f6091d5635cbc6b78f4d9c6894
BLAKE2b-256 ecad6c1165a7b7aabd184954074b562d48dbc8865debbeeafc4b5e289eb60c49

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1e94b9c98bedf8409b7349cbd8160e6ef8942a8dea4ef02826b14add806a3000
MD5 edbafcbca9f52cd51ccbad8e3e9f8d25
BLAKE2b-256 490881ab4d9c8ab50170092f0e59e936499f2ee16c810e574f345ae89438a535

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp310-cp310-win_amd64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp310-cp310-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 0008ab5a073d4fbfcd512020de02399b41c1490631cd22127caeb100a61c8eb1
MD5 81cda53184ac4b98bc251fa4fc72a8a2
BLAKE2b-256 42c88768353ecbe91f7b95dca10ae75118aae90d65afdaf5c6a3477b938e8be4

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp310-cp310-manylinux_2_38_x86_64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

File details

Details for the file nf_ndc_connect_public-0.18.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95cee2d5045b31971c3a11eda0fca0c133e8fc6c2eb6103a60d470751c3801a0
MD5 f1b8ccfe46c46016d765b33cb7f38fcc
BLAKE2b-256 c5cac0c16221c1d7cc521077240a1d5219875c17c6b1e125c843c4477d0b53d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on NuFlights/nf_ndc_connect_public

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

Release history Release notifications | RSS feed

This release

0.18.1 This release

13 files

0.18.0

13 files

0.17.0

13 files

0.16.0

13 files

0.15.0

13 files

0.14.0

13 files

0.13.0

13 files

0.12.0

11 files

0.11.0

3 files

0.10.1

3 files

0.10.0

3 files

0.7.0

4 files

0.6.4

4 files

0.6.3

4 files

0.6.1

4 files

0.6.0

4 files

0.5.5

4 files

0.5.4

4 files

0.5.3

4 files

0.5.2

1 file

0.5.1

1 file

0.5.0

1 file

0.4.1

1 file

0.4.0

1 file

0.3.3

1 file

0.3.2

1 file

0.3.1

1 file

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page