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.0.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.0-cp313-cp313-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.13Windows x86-64

nf_ndc_connect_public-0.18.0-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.0-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.0-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12Windows x86-64

nf_ndc_connect_public-0.18.0-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.0-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.0-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11Windows x86-64

nf_ndc_connect_public-0.18.0-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.0-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.0-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10Windows x86-64

nf_ndc_connect_public-0.18.0-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.0-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.0.tar.gz.

File metadata

  • Download URL: nf_ndc_connect_public-0.18.0.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.0.tar.gz
Algorithm Hash digest
SHA256 38fb8f43ec7b46c13c0a3b9e71719404742ac0fbd7785f5377141e3b8c940916
MD5 eb6a78772385d7dfe9d0fab68579daa2
BLAKE2b-256 ad842765fdcf37bb364397383ba9c38751d612db3dd662b3ee39fceccf4368ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0.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.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6865c73db4766063acb01429e7a9fbf270f5f50fda4cda93dc8b418b8600b58e
MD5 98a604a257eb0ee26a73ab1e515cbb37
BLAKE2b-256 27409000db69fe934b43020caa85f9599682d4c95ddb57e19c930a4a52f5c893

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 6eabef12fdb3825e1f5996e1da0f18e5ed6dabe0f5598afe8c87dbbb40a2dfb2
MD5 5543780008e257f3a7c71859209f227d
BLAKE2b-256 810d8877077d8c7437fdcf05d7d87e50f4ba560c04963fa6a0f8435996d04233

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 86872ae1d53c8ef55ab9ef244e0dc532305b2cc58a0fbdab0196f1b23a743668
MD5 62f6b214902a6a28fba3d308cbc7fe0c
BLAKE2b-256 45935b179bf7d00c49d1740fcc4a7801e2a71565874337c3809e3e606ab66f94

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3225e5e37dece0de687617d717506743a389e9cab00b7269f04a0048c33ddf44
MD5 93ad45c8b0da808a28d334182b824332
BLAKE2b-256 46df13a06dd5967d1a74c323df89d93eebf53c0fa6ddf615c6dd5f9dd0faebd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 8e7e8b3725875e5c465b43aefa8d4cc9c25f31e10313ba0064d3a5ff41d20163
MD5 cf2af5202c53c868332c5f88e096e681
BLAKE2b-256 5fc291186445455525e45b53532b001b8ee58e4d356a873a71053a4859ccdba3

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e39800672c770f1d3b32e5722787fac81e7c8cd81b85f1c3b749b878957f1a83
MD5 81f9b2011a2046bba95724b47bffe602
BLAKE2b-256 b0f7fb0dcf415527808c528fd4904d500e4e082c7212702010788978a0f4a896

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1cacb51b24a470912d222e7513f23b8a4df7874147af6732732aff62aae0ac3f
MD5 eebecaa80a0ea15ce87113781fd693fb
BLAKE2b-256 3fc2736331913ff1b69ec7c8534aaf910dcc4df06863d51cb7dff42b70d7376a

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp311-cp311-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 f0964f834b596b4331c641d80771cc8a0b6d5fabd7dbeeabe07b2c1e6f0152c7
MD5 6ef969bf18dd5ccbf0f71ed7d1b2eaa5
BLAKE2b-256 4113fccfe2092b73cbf89c5a2df367da92ed5c818d7aaf4c2875e8b62f764a06

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95d036f285f13c218dbe7e2b58fbcc38a1c3628155060c0089b751797a36b633
MD5 897988e511e85ff29634cc95dc192d4e
BLAKE2b-256 05d0c47b070efe95b439de90a917614620a2cc0c61c395f7374cf05df3f4a1c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 10e8b5971ba545a55f9b8fa4283bec05cbc54a9853d9a684f9fb845e252f1c5f
MD5 91384869b505ff9fe3e7ad6f8d80a685
BLAKE2b-256 43495da92a23bb92a8996762ff44d3ffd8c2fd2fc3d4c7f09c6d6b985cac675a

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp310-cp310-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 7d3dc8c86c8af941904a47e767afeaa4acc710cfcb831989820dde597c02394f
MD5 8aa9b9aa8319c94ea787a781977efc76
BLAKE2b-256 99a6e8146eb5752f5fda241f8f819ef54f0a245601478b8c26adfa6811a8c916

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nf_ndc_connect_public-0.18.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 83c4b6eb718acd8ae95b8533a34b273897fb907efd12cdd19b97810a01b83454
MD5 6315cf71bb7ee3bc5c553eabd6b4f744
BLAKE2b-256 056985c0712b00e9cd9075aee29348e5564ad6d676fb83a240a20e33dcf90ce4

See more details on using hashes here.

Provenance

The following attestation bundles were made for nf_ndc_connect_public-0.18.0-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

0.18.1

13 files

This release

0.18.0 This release

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