Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
JwtAuth.hpp File Reference
#include <orbit/legacy_namespaces.hpp>
#include <orbit/routing/Router.hpp>
#include <chrono>
#include <optional>
#include <string>
#include <orbit/http/json.hpp>
Include dependency graph for JwtAuth.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  orbit::middleware::JwtOptions
 Verification settings for jwt_auth(). Configure at least one key: secret, public_key_pem or jwks_url (several may be combined). More...
 
struct  orbit::jwt::SigningKey
 The key a token is signed with. Set exactly one of secret and private_key_pem. More...
 
struct  orbit::jwt::SignOptions
 Registered claims sign() adds. Claims already present in the payload win. More...
 

Namespaces

namespace  orbit
 
namespace  orbit::middleware
 
namespace  orbit::jwt
 

Functions

routing::Middleware orbit::middleware::jwt_auth (JwtOptions options)
 Verifies an Authorization: Bearer JWT and stores its claims in req.user.
 
routing::Middleware orbit::middleware::jwt_auth (const std::string &secret_key)
 Shorthand for an HS256-only jwt_auth() with this secret.
 
std::string orbit::jwt::sign (nlohmann::json claims, const SigningKey &key, const SignOptions &options={})
 Issues a signed JWT (JWS compact serialisation) that jwt_auth() with the matching secret or public key accepts.
 
template<typename T >
std::optional< T > orbit::jwt::claim (const nlohmann::json &claims, const std::string &name)
 A claim from verified claims (req.user), if present with that type: jwt::claim<std::string>(req.user, "sub"), claim<int64_t>(req.user, "exp").