soul-auth 0.1.0

Framework-agnostic JWT claims and auth error primitives for the Soul platform.
Documentation
  • Coverage
  • 2.44%
    1 out of 41 items documented1 out of 7 items with examples
  • Size
  • Source code size: 23.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 823.82 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • RcityAGI

soul-auth

Framework-agnostic JWT claims and auth error primitives for the Soul platform.

Extracted from the Rainbow-Auth service. This crate keeps only the framework-independent core (JWT encode/decode + a unified AuthError), so it can be reused from any HTTP framework, database, or runtime.

Add to your project

[dependencies]
soul-auth = "0.1"

Usage

use soul_auth::{Claims, SubjectType, encode_token, decode_token};

let secret = b"my-secret-key";

let claims = Claims {
    sub: "user:42".into(),
    exp: 9_999_999_999,
    iat: 1_700_000_000,
    session_id: Some("session:1".into()),
    subject_type: Some(SubjectType::Human),
};

let token   = encode_token(&claims, secret).unwrap();
let decoded = decode_token(&token, secret).unwrap();
assert_eq!(decoded.sub, "user:42");

What's included

Item Purpose
AuthError Unified auth-flow error enum (thiserror-derived)
Result<T> Alias for Result<T, AuthError>
Claims JWT claims (sub, exp, iat, session_id, ...)
SubjectType Human / Agent discriminator
encode_token HS256 sign helper
decode_token HS256 verify helper

License

MIT