Authentication
Custom UI Integration
In a C++ backend with a series of pass through [UFUNCTIONS]
setup similarly to [SequenceBackendManager.h/.cpp]
. Each of these calls are implemented in [UAuthenticator]
you just need to pass through the data with YOUR UAuthenticator UObject
//This call is platform dependent on windows & mac this is required for SSO WIP
UFUNCTION(BlueprintCallable, CATEGORY = "Login")
FString GetLoginURL(const ESocialSigninType& Type);
//This Call is made after you've collected the ID_Token (Mac & Windows only) WIP
UFUNCTION(BlueprintCallable, CATEGORY = "Login")
void SocialLogin(const FString& IDTokenIn);
//This Call is made after you've collected the email address from the Users in the UI
UFUNCTION(BlueprintCallable, CATEGORY = "Login")
void EmailLogin(const FString& EmailIn);
//This is call is made after the Delegate `[AuthRequiresCode]` is fired
UFUNCTION(BlueprintCallable, CATEGORY = "Login")
void EmailCode(const FString& CodeIn);
//Optional call used to check if the credentials on disk are valid or not//
UFUNCTION(BlueprintCallable, Category = "Login")
bool StoredCredentialsValid();
To start you'll want to create a [UAuthenticator]
UObject like so [UAuthenticator + Auth = NewObject<UAuthenticator>()]
, this UObject manages the authentication side of Sequence.
Be sure to bind to the Delegates for [AuthSuccess]
, [AuthFailure]
, [AuthRequiresCode]
prior to making any signin calls You can bind to these delegates like so:
this->authenticator->AuthRequiresCode.AddDynamic(this, &AYourClass::YourCallReadyToReceiveCode);
this->authenticator->AuthFailure.AddDynamic(this, &AYourClass::YourCallShowAuthFailureScreen);
In the case of [AuthSuccess]
since a parameter is also passed we bind to it like this
FScriptDelegate del;
del.BindUFunction(this, "CallShowAuthSuccessScreen");
this->authenticator->AuthSuccess.Add(del);
Where [CallShowAuthSuccessScreen]
is defined in SequenceBackendManager.h
like so:
UFUNCTION()
void CallShowAuthSuccessScreen(const FCredentials_BE& CredentialsIn);
And in SequenceBackendManager.cpp
like so:
void ASequenceBackendManager::CallShowAuthSuccessScreen(const FCredentials_BE& CredentialsIn)
{
this->Credentials = CredentialsIn;
if (this->ShowAuthSuccessDelegate.IsBound())
this->ShowAuthSuccessDelegate.Broadcast(Credentials);
else
UE_LOG(LogTemp, Error, TEXT("`[Nothing bound to: ShowAuthSuccessDelegate]`"));
}
Email based Authentication
-
To start email based authentication you'll start it with this call
[EmailLogin(const FString& EmailIn)]
, supplying an email you've collected from the User in your GUI. -
Next
[AuthRequiresCode]
will fire when the backend is ready to receive the Code from your UI. Collect this code from your GUI and send it to the authenticator using[EmailCode(CodeIn)]
. -
Finally
[AuthSuccess]
will fire with a Credentials_BE struct as a parameter. This is your non registered credentials from EmailAuth. You are done Email Based Auth.
Social Signin based Authentication on Desktop
-
To start SSO based authentication with desktop you can either use your own implementation to get the necessary id_token or you can make use of Unreal's web browser plugin.
-
With whatever implementation you chose you can forward the colleted id_token to the UAuthenticator object with
[SocialLogin(const FString& IDTokenIn)]
, after which[AuthSuccess]
will fire and you're done desktop based SSO.
Social Signin based Authentication on Mobile
WIP