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

Verifies signed bearer tokens against a shared secret. More...

#include <session_auth.hpp>

Public Member Functions

 TokenVerifier (std::string secret, MacFunction mac=hmacSha256)
 Constructs a verifier over secret using mac.
std::expected< SessionToken, AuthError > verify (std::string_view token, int64_t nowMs) const
 Verifies token's signature and expiry and returns its claims.

Detailed Description

Verifies signed bearer tokens against a shared secret.

Definition at line 430 of file session_auth.hpp.

Constructor & Destructor Documentation

◆ TokenVerifier()

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

Constructs a verifier over secret using mac.

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

Definition at line 452 of file session_auth.hpp.

Member Function Documentation

◆ verify()

std::expected< SessionToken, AuthError > morph::session::TokenVerifier::verify ( std::string_view token,
int64_t nowMs ) const
inlinenodiscard

Verifies token's signature and expiry and returns its claims.

The MAC is checked before the payload is parsed, so untrusted JSON is never handed to the parser until authenticity is established.

Parameters
tokenToken string (payload.sig).
nowMsCurrent time (ms since epoch) to check expiry against.
Returns
The verified claims, or an AuthError.

Definition at line 463 of file session_auth.hpp.


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