1#ifndef _DITTO_AUTHENTICATOR_
2#define _DITTO_AUTHENTICATOR_
6#include "AuthenticationCallback.hpp"
7#include "AuthenticationStatus.hpp"
10#include "dittoffi.hpp"
19class AuthenticationStatusObserver;
26class Authenticator :
public std::enable_shared_from_this<Authenticator> {
31 friend class LoginProvider;
33 friend class ValidityListener;
50 std::string token, std::string provider,
51 std::function<
void(std::unique_ptr<DittoError>)> login_handler)
const;
65 std::string username, std::string password, std::string provider,
66 std::function<
void(std::unique_ptr<DittoError>)> login_handler)
const;
87 std::shared_ptr<Observer>
113 std::shared_ptr<CAuthClient_t> auth_client;
114 std::weak_ptr<Ditto::Fields> weak_ditto_fields;
115 std::weak_ptr<AuthenticationCallback> callback;
116 std::vector<std::weak_ptr<AuthenticationStatusObserver>> status_observers;
119 std::shared_ptr<AuthenticationCallback> callback);
121 void set_weak_ditto_fields(std::weak_ptr<Ditto::Fields> weak_ditto_fields);
122 void stop_status_observer(
123 std::shared_ptr<AuthenticationStatusObserver> status_observer);
124 void validity_updated(
bool web_valid,
bool x509_valid);
125 void authentication_expiring(uint32_t time_remaining);
126 void update_and_notify(
bool shouldNotify);
Definition: AuthenticationStatusObserver.hpp:15
Provides access to authentication information and methods for logging on to Ditto Cloud....
Definition: Authenticator.hpp:26
std::string user_id() const
Definition: Authenticator.cpp:81
std::shared_ptr< Observer > observe_status(std::function< void(AuthenticationStatus status)> callback)
Definition: Authenticator.cpp:69
void logout(std::function< void(Ditto)> cleanup=[](Ditto ditto) {}) const
Log out of Ditto.
Definition: Authenticator.cpp:56
void login_with_token(std::string token, std::string provider, std::function< void(std::unique_ptr< DittoError >)> login_handler) const
Log in to Ditto with a third-party token.
Definition: Authenticator.cpp:28
AuthenticationStatus get_status() const
Definition: Authenticator.cpp:26
bool is_authenticated() const
Definition: Authenticator.cpp:77
void login_with_credentials(std::string username, std::string password, std::string provider, std::function< void(std::unique_ptr< DittoError >)> login_handler) const
Log in to Ditto with a username and password.
Definition: Authenticator.cpp:42
The entrypoint to the Ditto SDK.
Definition: Ditto.hpp:22
Run Ditto in secure production mode, logging on to Ditto Cloud or on on-premises authentication serve...
Definition: Identity.hpp:302
Test a Ditto Cloud app with weak shared token authentication ("Playground mode"). This is not secure ...
Definition: Identity.hpp:422
Run Ditto in secure production mode, logging on to Ditto Cloud or on on-premises authentication serve...
Definition: Identity.hpp:356
Provides info about the authentication status.
Definition: AuthenticationStatus.hpp:10