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

Metadata

Release files for nf-ndc-connect-public 0.18.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nf-ndc-connect-public 0.18.1
File Size Uploaded
nf_ndc_connect_public-0.18.1.tar.gz 46.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for nf-ndc-connect-public 0.18.1
File
nf_ndc_connect_public-0.18.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
nf_ndc_connect_public-0.18.1-cp313-cp313-manylinux_2_38_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.38+ x86-64 Details
nf_ndc_connect_public-0.18.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
nf_ndc_connect_public-0.18.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
nf_ndc_connect_public-0.18.1-cp312-cp312-manylinux_2_38_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.38+ x86-64 Details
nf_ndc_connect_public-0.18.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
nf_ndc_connect_public-0.18.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
nf_ndc_connect_public-0.18.1-cp311-cp311-manylinux_2_38_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.38+ x86-64 Details
nf_ndc_connect_public-0.18.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
nf_ndc_connect_public-0.18.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
nf_ndc_connect_public-0.18.1-cp310-cp310-manylinux_2_38_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.38+ x86-64 Details
nf_ndc_connect_public-0.18.1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 33.6 MB

Release files / nf_ndc_connect_public-0.18.1.tar.gz

Download URL nf_ndc_connect_public-0.18.1.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ff831868436c5b1800ec1d4ff8c35d9cb6e2377e5ada4ae52e5a2a0a918931ec
BLAKE2b-256 checksum
How to use checksums
2953464f73c385b5c754edf1cdba192791bbc92310cd334666f3e016e6cffd05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp313-cp313-win_amd64.whl

Download URL nf_ndc_connect_public-0.18.1-cp313-cp313-win_amd64.whl
Size 1.9 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
9790dfeda3e14c6b5fbb2ea5cea61310561365fea6b6c08de509e800700dee41
BLAKE2b-256 checksum
How to use checksums
79c83252319fd8f073529799abfd1fe2e790cb6b89cea56612c1db000bc1f0e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp313-cp313-manylinux_2_38_x86_64.whl

Download URL nf_ndc_connect_public-0.18.1-cp313-cp313-manylinux_2_38_x86_64.whl
Size 4.5 MB
Tags CPython 3.13 Linux glibc 2.38+ x86-64
SHA-256 checksum
How to use checksums
ac98bad91ebc421fe54204db9303fb408d735259a85d559afe0a60d2c0c95d3e
BLAKE2b-256 checksum
How to use checksums
5a303c5692d7398142eee5227c0ae27083e5ed2c359c76a70cd2b96e2269552f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL nf_ndc_connect_public-0.18.1-cp313-cp313-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
14232c01c391acef73d4f79ff653466ba76e6816b356c1cef98a10b59a50c230
BLAKE2b-256 checksum
How to use checksums
d75c27b9c0ab96265fd00865a3c724e51805706dbcb3569987544d35484ba03d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp312-cp312-win_amd64.whl

Download URL nf_ndc_connect_public-0.18.1-cp312-cp312-win_amd64.whl
Size 1.9 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
f498963b1943a8c7b3611a0d02df676e6bc80e444fefb4fe88bdf946622bf12f
BLAKE2b-256 checksum
How to use checksums
0d38acb774b23d0592968051c2395448f6d107bc0e27e4c25b52767239fa7556
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp312-cp312-manylinux_2_38_x86_64.whl

Download URL nf_ndc_connect_public-0.18.1-cp312-cp312-manylinux_2_38_x86_64.whl
Size 4.5 MB
Tags CPython 3.12 Linux glibc 2.38+ x86-64
SHA-256 checksum
How to use checksums
0b75e89662f309db8b7257bd7da4820eac91c3bfdcaaf28da765c6418bf14e66
BLAKE2b-256 checksum
How to use checksums
3b1299d3be7b68e1224bf7271da19144f8fb6d5f15abc093b9c2dd3c23377f0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL nf_ndc_connect_public-0.18.1-cp312-cp312-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aaa676ca814ffaa583124820d4192c4b282dfc3b24e046686b13fee65218da3f
BLAKE2b-256 checksum
How to use checksums
bd6aaa42827a7827aa650e32a97d5e83b4857b998c883398127d112cbf05432b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp311-cp311-win_amd64.whl

Download URL nf_ndc_connect_public-0.18.1-cp311-cp311-win_amd64.whl
Size 1.9 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
82f82353757de733fddd403396de60022120c271efe41b7b9a63ea38c19e2450
BLAKE2b-256 checksum
How to use checksums
4f04b3aad9824178fd717b6a86d1c7d344678896d04a384b1aa0948125132a42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp311-cp311-manylinux_2_38_x86_64.whl

Download URL nf_ndc_connect_public-0.18.1-cp311-cp311-manylinux_2_38_x86_64.whl
Size 4.5 MB
Tags CPython 3.11 Linux glibc 2.38+ x86-64
SHA-256 checksum
How to use checksums
53770836562fc130f1cb4d2588749127d5c0d709c89f06b84319d33997e1bd6c
BLAKE2b-256 checksum
How to use checksums
ea71b68d50b282bd1ffee32b081324e137a6a98c7aa69959ef8fdc0c849a3e2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL nf_ndc_connect_public-0.18.1-cp311-cp311-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
cea718c0624b2a70308610d8da3aaf4bd55cfc50aece8b3806dfaf336036a221
BLAKE2b-256 checksum
How to use checksums
ecad6c1165a7b7aabd184954074b562d48dbc8865debbeeafc4b5e289eb60c49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp310-cp310-win_amd64.whl

Download URL nf_ndc_connect_public-0.18.1-cp310-cp310-win_amd64.whl
Size 1.9 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
1e94b9c98bedf8409b7349cbd8160e6ef8942a8dea4ef02826b14add806a3000
BLAKE2b-256 checksum
How to use checksums
490881ab4d9c8ab50170092f0e59e936499f2ee16c810e574f345ae89438a535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp310-cp310-manylinux_2_38_x86_64.whl

Download URL nf_ndc_connect_public-0.18.1-cp310-cp310-manylinux_2_38_x86_64.whl
Size 4.5 MB
Tags CPython 3.10 Linux glibc 2.38+ x86-64
SHA-256 checksum
How to use checksums
0008ab5a073d4fbfcd512020de02399b41c1490631cd22127caeb100a61c8eb1
BLAKE2b-256 checksum
How to use checksums
42c88768353ecbe91f7b95dca10ae75118aae90d65afdaf5c6a3477b938e8be4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / nf_ndc_connect_public-0.18.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL nf_ndc_connect_public-0.18.1-cp310-cp310-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
95cee2d5045b31971c3a11eda0fca0c133e8fc6c2eb6103a60d470751c3801a0
BLAKE2b-256 checksum
How to use checksums
c5cac0c16221c1d7cc521077240a1d5219875c17c6b1e125c843c4477d0b53d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.18.1 This release

13 release files

0.7.0

4 release files

0.6.4

4 release files

0.6.3

4 release files

0.6.1

4 release files

0.6.0

4 release files

0.5.5

4 release files

0.5.4

4 release files

0.5.3

4 release files

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release 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