morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::session::TokenIssuer Class Reference

Mints signed bearer tokens from claims using a shared secret. More...

#include <session_auth.hpp>

Public Member Functions

 TokenIssuer (std::string secret, MacFunction mac=hmacSha256)
 Constructs an issuer over secret using mac.
std::string issue (const SessionToken &claims) const
 Serialises claims and returns a signed token string.

Detailed Description

Mints signed bearer tokens from claims using a shared secret.

Wire format: base64url(claimsJson) "." base64url(mac(secret, payload)).

Definition at line 379 of file session_auth.hpp.

Constructor & Destructor Documentation

◆ TokenIssuer()

morph::session::TokenIssuer::TokenIssuer ( std::string secret,
MacFunction mac = hmacSha256 )
inlineexplicit

Constructs an issuer over secret using mac.

Parameters
secretShared secret (same value the verifier uses).
macMAC primitive; defaults to hmacSha256. Stored and invoked for this issuer's whole lifetime, so anything the callable refers to must outlive the issuer.

Definition at line 401 of file session_auth.hpp.

Member Function Documentation

◆ issue()

std::string morph::session::TokenIssuer::issue ( const SessionToken & claims) const
inlinenodiscard

Serialises claims and returns a signed token string.

Writes with detail::EscapingWriteOpts so a raw ASCII control byte in principal/roles round-trips through TokenVerifier::verify instead of producing invalid JSON (or, alongside an escaped \\endiskip/", silently corrupted JSON) — see that struct's doc comment.

Parameters
claimsClaims to embed and sign.
Returns
The signed payload.sig token.
Exceptions
TokenIssuanceErroron encode failure (see detail::throwOnGlazeError for why this is not realistically reachable for SessionToken).

Definition at line 415 of file session_auth.hpp.


The documentation for this class was generated from the following file: