I3DHAuthHandler.h Source File

instant3Dhub: I3DHAuthHandler.h Source File
instant3Dhub
I3DHAuthHandler.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "GameFramework/Actor.h"
9
10#include "I3DHAuthHandler.generated.h"
11
13USTRUCT(BlueprintType)
15{
16 GENERATED_BODY()
17
19 {
20 }
21
22 FI3DHAuthError(const FString& UserMessage)
23 : UserMessage(UserMessage)
24 {
25 }
26
28 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
29 FString UserMessage;
30};
31
33DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FI3DHAuthSuccessDelegate, FString, AccessToken, bool, WasRefresh);
35DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FI3DHAuthFailureDelegate, const FI3DHAuthError&, Error, bool, WasRefresh);
36
37struct FI3DHTokenResponse;
38class FI3DHAuthServer;
39class IHttpRequest;
40
49UCLASS(ClassGroup = "instant3Dhub")
50class INSTANT3DHUB_API AI3DHAuthHandler : public AActor
51{
52 friend class FI3DHAuthServer;
53
54 GENERATED_BODY()
55
57
58public:
59 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
60
61public:
62 // Core API:
63
73 UFUNCTION(BlueprintCallable, Category = "{instant3DhubAuth}")
74 void Init(const FString& ClientId, const FString& Scope, const FString& AuthorizationUrl, const FString& TokenUrl);
75
82 UFUNCTION(BlueprintCallable, Category = "{instant3DhubAuth}")
83 void Start();
84
90 UFUNCTION(BlueprintCallable, Category = "{instant3DhubAuth}")
91 void Reset();
92
93private:
95 void RefreshTimerCallback();
96 void HandleTokenResponse(const FI3DHTokenResponse* TokenResponse, bool WasRefresh);
97
99
100 // Note on thread safety: All variables are intended to be accessed from the
101 // game thread only. Access from other threads will require additional
102 // synchronization.
103
104private:
105 // Basic OAuth 2.0 configuration:
106
107 FString ClientId;
108 FString Scope;
109 FString AuthorizationUrl;
110 FString TokenUrl;
111
112public:
121 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
122 FString SuccessRedirectUrl;
123
125 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
126 FString SuccessHtmlResponse;
127
129 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
130 FString ErrorRedirectUrl;
131
133 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
134 FString ErrorHtmlResponse;
135
138public:
152 UPROPERTY(BlueprintAssignable, Category = "{instant3DhubAuth}")
153 FI3DHAuthSuccessDelegate Succeeded;
154
156 UPROPERTY(BlueprintAssignable, Category = "{instant3DhubAuth}")
157 FI3DHAuthFailureDelegate Failed;
158
161private:
162 // Internal state:
163
164 TSharedPtr<FI3DHAuthServer> Server;
165 TSharedPtr<IHttpRequest> TokenRequest;
166
167 FString RefreshToken;
168 FTimerHandle RefreshTimer;
169};
DECLARE_DYNAMIC_MULTICAST_DELEGATE void FI3DHAuthFailureDelegate(const FI3DHAuthError &Error, bool WasRefresh)
AuthFailure Delegate Type.
DECLARE_DYNAMIC_MULTICAST_DELEGATE void FI3DHAuthSuccessDelegate(FString AccessToken, bool WasRefresh)
AuthSuccess Delegate Type.
@ Error
Indicates a general error that doesn't match any of the specific ones.
Implements OAuth 2.0 authorization including token refresh.
Definition I3DHAuthHandler.h:51
Authentication Error with a UserMessage.
Definition I3DHAuthHandler.h:15