|
| | MbAuth (const MantisBase &app) |
| MbOAuthMgr & | oauth () const |
| MbApiKeyMgr & | apiKey () const |
| std::string | createToken (const json &claims_params, int timeout=-1) const |
| | Create JWT token with custom claims.
|
| int | sessionTimeoutSeconds (const std::string &entity_name, int timeout=-1) const |
| json | verifyToken (const std::string &token) const |
| | Verify a JWT and return claims plus verification metadata.
|
| bool | deleteSession (const std::string &session_id) const |
| json | refreshSession (const std::string &old_session_id, const std::string &entity_name, const std::string &user_id) |
| | Rotate a session: invalidate old_session_id and issue a new JWT.
|
| json | requestLoginOtp (const std::string &entity_name, const std::string &email) const |
| | Email a one-time sign-in code for an auth-entity account.
|
| json | loginWithOtp (const std::string &entity_name, const std::string &email, const std::string &otp) const |
| | Exchange a one-time sign-in code for a session token.
|
| void | rejectUnverifiedLogin (const std::string &entity_name, const json &user) const |
| | Reject login when the entity requires a verified email and the account is not verified.
|
| void | notifyEmailVerification (const std::string &entity_name, const std::string &user_id) const |
| | Email a verification link when SMTP is configured and the account is unverified. Missing SMTP or siteDomain is logged and ignored so registration can still succeed.
|
| json | requestEmailVerification (const std::string &entity_name, const std::string &email, const std::string &request_host) const |
| | Send a verification link for an email address. Unknown addresses return { "sent": true } and send nothing.
|
| json | confirmEmailVerification (const std::string &entity_name, const std::string &token) const |
| | Mark the account verified when token matches a live verification link.
|
| json | requestPasswordReset (const std::string &entity_name, const std::string &email, const std::string &request_host) const |
| | Email a password-reset link for an account. Unknown addresses return { "sent": true } and send nothing.
|
| json | confirmPasswordReset (const std::string &entity_name, const std::string &token, const std::string &new_password) const |
| | Set a new password when token matches a live reset link.
|
JWT token creation and verification utilities.
Provides static methods for generating and validating JWT tokens used for authentication and authorization.
auto& auth = app->auth();
json claims = {{
"id",
"user123"}, {
"table",
"users"}};
std::string token = auth.createToken(claims, 3600);
json result = auth.verifyToken(token);
if (result["verified"].get<bool>()) {
std::string userId = result["id"];
}
auth.apiKey().create("users", "user123", "Mobile app");
auth.oauth().buildAuthorizeUrl("users", "google", redirect_uri);
static std::unique_ptr< MantisBase > create(int argc, char **argv)
Create class instance given cmd args passed in.
Definition mantisbase.cpp:75
nlohmann::json json
Shorten JSON namespace.
Definition api_keys.h:36