1#ifndef DITTO_IDENTITY_H
2#define DITTO_IDENTITY_H
4#include "AuthenticationCallback.hpp"
23 ONLINE_WITH_AUTHENTICATION,
58class DITTO_DEPRECATED_BECAUSE(
"Identity types are removed in SDK 5.0. "
59 "Use DittoConfig with Ditto::open(config) "
60 "instead. See https://docs.ditto.live for "
63 friend class ManualIdentity;
64 friend class OfflinePlaygroundIdentity;
65 friend class OnlineWithAuthenticationIdentity;
66 friend class OnlinePlaygroundIdentity;
67 friend class SharedKeyIdentity;
83 static std::shared_ptr<OfflinePlaygroundIdentity> DITTO_DEPRECATED_BECAUSE(
84 "Use DittoConfig with Ditto::open(config) instead. "
85 "Identity types will be removed in SDK 5.0. "
86 "See https://docs.ditto.live for migration guide.")
103 static std::shared_ptr<OfflinePlaygroundIdentity> DITTO_DEPRECATED_BECAUSE(
104 "Use the OfflinePlayground() function that does not specify a `site_id` "
105 "instead. Use `peer_key` to uniquely identify a peer")
122 static std::shared_ptr<OnlineWithAuthenticationIdentity>
123 DITTO_DEPRECATED_BECAUSE(
124 "Use DittoConfig with Ditto::open(config) instead. "
125 "Identity types will be removed in SDK 5.0. "
126 "See https://docs.ditto.live for migration guide.")
130 bool enable_ditto_cloud_sync = true,
131 std::
string custom_auth_url =
"");
149 static std::shared_ptr<OnlinePlaygroundIdentity> DITTO_DEPRECATED_BECAUSE(
150 "Use DittoConfig with Ditto::open(config) instead. "
151 "Identity types will be removed in SDK 5.0. "
152 "See https://docs.ditto.live for migration guide.")
154 bool enable_ditto_cloud_sync = true,
155 std::
string custom_auth_url =
"");
167 static std::shared_ptr<SharedKeyIdentity> DITTO_DEPRECATED_BECAUSE(
168 "Use DittoConfig with Ditto::open(config) instead. "
169 "Identity types will be removed in SDK 5.0. "
170 "See https://docs.ditto.live for migration guide.")
187 static std::shared_ptr<SharedKeyIdentity> DITTO_DEPRECATED_BECAUSE(
188 "Use the SharedKey() function that does not specify a `site_id` "
189 "instead. Use `peer_key` to uniquely identify a peer")
190 SharedKey(std::
string app_id, std::
string shared_key, uint64_t site_id);
201 static std::shared_ptr<ManualIdentity> DITTO_DEPRECATED_BECAUSE(
202 "Use DittoConfig with Ditto::open(config) instead. "
203 "Identity types will be removed in SDK 5.0. "
204 "See https://docs.ditto.live for migration guide.")
208 virtual std::
string get_app_id() const;
209 virtual
bool get_enable_ditto_cloud_sync() const;
210 virtual
bool requires_offline_license_token() const;
215 virtual CIdentityConfig_t *build_identity_config() = 0;
223class OfflinePlaygroundIdentity : public Identity {
224 friend class Identity;
232 DITTO_DEPRECATED_BECAUSE(
"Use `peer_key` instead to uniquely identify a peer")
236 OfflinePlaygroundIdentity(std::
string app_id);
243 DITTO_DEPRECATED_BECAUSE(
244 "Use the OfflinePlaygroundIdentity constructor that does not specify a "
245 "`site_id`. Use `peer_key` instead to uniquely identify a peer.")
246 OfflinePlaygroundIdentity(std::
string app_id, uint64_t
site_id);
249 std::
string get_app_id() const override;
250 bool requires_offline_license_token() const override;
251 CIdentityConfig_t *build_identity_config() override;
274class OnlineWithAuthenticationIdentity : public Identity {
276 friend class Identity;
293 OnlineWithAuthenticationIdentity(
294 std::string app_id, std::shared_ptr<AuthenticationCallback> callback,
298 std::shared_ptr<AuthenticationCallback> callback;
299 std::string get_app_id()
const override;
300 bool get_enable_ditto_cloud_sync()
const override;
301 bool requires_offline_license_token()
const override;
302 CIdentityConfig_t *build_identity_config()
override;
310class OnlinePlaygroundIdentity :
public Identity {
311 friend class Identity;
335 OnlinePlaygroundIdentity(std::string app_id, std::string
token,
340 std::string get_app_id()
const override;
341 std::string get_token()
const;
342 bool get_enable_ditto_cloud_sync()
const override;
343 bool requires_offline_license_token()
const override;
344 CIdentityConfig_t *build_identity_config()
override;
353class SharedKeyIdentity :
public Identity {
354 friend class Identity;
368 DITTO_DEPRECATED_BECAUSE(
369 "Use `peer_key` instead to uniquely identify a peer.")
373 SharedKeyIdentity(std::
string app_id, std::
string shared_key);
379 DITTO_DEPRECATED_BECAUSE(
380 "Use the @ref SharedKeyIdentity constructor that does not specify a "
381 "`site_id` instead. Use `peer_key` to uniquely identify a peer.")
382 SharedKeyIdentity(std::
string app_id, std::
string shared_key,
386 std::
string get_app_id() const override;
387 bool requires_offline_license_token() const override;
388 CIdentityConfig_t *build_identity_config() override;
395class ManualIdentity : public Identity {
396 friend class Identity;
407 bool requires_offline_license_token()
const override;
408 CIdentityConfig_t *build_identity_config()
override;
Provides feedback to the developer about Ditto authentication status.
Definition AuthenticationCallback.hpp:13
The various identity configurations that you can use when initializing a Ditto instance.
Definition Identity.hpp:61
static std::shared_ptr< ManualIdentity > Manual(std::string certificate_config)
Construct a new ManualIdentity.
static std::shared_ptr< OnlineWithAuthenticationIdentity > OnlineWithAuthentication(std::string app_id, std::shared_ptr< AuthenticationCallback > callback, bool enable_ditto_cloud_sync=true, std::string custom_auth_url="")
Construct a new OnlineWithAuthenticationIdentity.
static std::shared_ptr< OfflinePlaygroundIdentity > OfflinePlayground(std::string app_id="")
Construct a new OfflinePlaygroundIdentity.
static std::shared_ptr< SharedKeyIdentity > SharedKey(std::string app_id, std::string shared_key)
Construct a new SharedKeyIdentity.
static std::shared_ptr< OnlinePlaygroundIdentity > OnlinePlayground(std::string app_id, std::string token, bool enable_ditto_cloud_sync=true, std::string custom_auth_url="")
Construct a new OnlinePlaygroundIdentity.
A manually-provided certificate identity. This accepts a base64-encoded bundle.
Definition Identity.hpp:395
std::string certificate_config
Definition Identity.hpp:403
Develop peer-to-peer apps with no cloud connection. This mode offers no security and must only be use...
Definition Identity.hpp:223
uint64_t site_id
Definition Identity.hpp:233
Test a Ditto Cloud app with weak shared token authentication ("Playground mode"). This is not secure ...
Definition Identity.hpp:310
std::string custom_auth_url
Definition Identity.hpp:332
std::string token
Definition Identity.hpp:319
bool enable_ditto_cloud_sync
Definition Identity.hpp:325
Run Ditto in secure production mode, logging on to Ditto Cloud or on on-premises authentication serve...
Definition Identity.hpp:274
std::string custom_auth_url
Definition Identity.hpp:290
bool enable_ditto_cloud_sync
Definition Identity.hpp:283
A mode where any device is trusted provided they know the secret key. This is a simplistic authentica...
Definition Identity.hpp:353
std::string shared_key
Definition Identity.hpp:361
uint64_t site_id
Definition Identity.hpp:370
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
IdentityType
The different types of Identity that can be used with Ditto.
Definition Identity.hpp:21
std::string default_auth_url(std::string app_id)
Helper function to compute the default auth URL.