ace.core.jwt_user
- class ace.core.jwt_user.JwtUser(payload: dict)[source]
Bases:
objectRepresents the authenticated user extracted from a decoded JWT Bearer token.
All standard claims from the Equisoft/Centralize token are exposed as typed properties. Any extra or custom claim is also accessible via
get()or the subscript operator, so the class stays useful even when the token schema evolves.Typical usage inside a script (
selfis anyBaseRulesubclass):user = self.jwt_user if user is None: # Request was made without a Bearer token ... # Typed shorthand properties print(user.application_user_id) # int – applicationUserId claim print(user.user_id) # int – userId claim print(user.email) # str – email claim print(user.name) # str – name claim print(user.org) # str – org claim print(user.roles) # list – roles claim print(user.divisions) # list – divisions claim print(user.language_id) # int – languageId claim print(user.application_uuid) # str – applicationUUID claim print(user.subject) # str – sub claim print(user.is_carbon) # bool – isCarbon claim # Access any claim by its original JWT key name value = user.get("someCustomClaim", default="fallback") # Dict-style access value = user["someCustomClaim"] # Membership test if "someCustomClaim" in user: ... # Full payload as a plain dict payload = user.as_dict()
- __init__(payload: dict)[source]
- Parameters:
payload – The decoded JWT payload dict (as returned by
jwt.decode()).
- property application_user_id: int | None
applicationUserIdclaim – primary user identifier used by ACE scripts.
- property user_id: int | None
userIdclaim.
- property name: str | None
nameclaim – display name of the authenticated user.
- property email: str | None
emailclaim.
- property org: str | None
orgclaim – organisation name.
- property roles: List[Any]
rolesclaim – list of role identifiers assigned to the user.
- property divisions: List[str]
divisionsclaim – list of division names the user belongs to.
- property language_id: int | None
languageIdclaim.
- property application_uuid: str | None
applicationUUIDclaim.
- property is_carbon: bool
isCarbonclaim.
- property is_commission: bool
isCommissionclaim.
- property audience: list
audclaim – list of intended audiences for this token.
- property subject: str | None
subclaim – UUID that uniquely identifies the user in the IdP.
- property issuer: str | None
issclaim – token issuer URL.
- property issued_at: int | None
iatclaim – Unix timestamp when the token was issued.
- property expires_at: int | None
expclaim – Unix timestamp when the token expires.
- property not_before: int | None
nbfclaim – Unix timestamp before which the token is not valid.
- property jwt_id: str | None
jticlaim – unique identifier for this specific token.
- get(claim: str, default: Any = None) Any[source]
Return the value of any claim by its original JWT key name.
- Parameters:
claim – The raw claim key as it appears in the JWT payload (e.g.
"applicationUserId","someCustomClaim").default – Value to return when the claim is absent.
- __getitem__(claim: str) Any[source]
Allow dict-style access:
user["applicationUserId"].
- __contains__(claim: str) bool[source]
Support
"claim" in usermembership checks.
- as_dict() dict[source]
Return a copy of the full decoded JWT payload.
- classmethod from_token(token: str) JwtUser | None[source]
Decode a raw JWT string (without signature verification) and return a
JwtUserinstance, orNoneif decoding fails.- Parameters:
token – The raw Bearer token string (without the ``Bearer `` prefix).
- classmethod from_payload(payload: dict) JwtUser[source]
Build a
JwtUserdirectly from an already-decoded payload dict.