Skip to content

sha3sha3/UE-EasyJWT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is no longer maintained on GitHub, but you may obtain the latest maintained version on Unreal Marketplace.


EasyKafakLogo
Json Web Tokens for Unreal Engine 4/5

EasyJwt subsystem

EasyJwt is a JSON web tokens engine sub-system for Unreal Engine 4/5, that provides a c and bluprint interface to Generate, Sign, Verify and manage claims of JWT.

Supported Platforms

  • Windows x86_64
  • Hololens 2 (Windows ARM64)
  • Linux x86_64
  • Linux ARM64

C Modules Link

Link the plugin modules to your project through <YourModule>.build.cs:

bEnableExceptions = true;//we are using exceptions

 PrivateDependencyModuleNames.AddRange( new string[]
{
    "EasyJwt",
    "JwtCpp",
    "JwtVerifier",
    "JwtGenerator"
});

JWT Generator Basic Usage

C

Initialize the Generator

#include "EasyJwtSubsystem.h"

TSharedPtr<FEasyJwtModule> EasyJwt = GEngine->GetEngineSubsystem<UEasyJwtSubsystem>()->GetEasyJwt();
EasyJwt->GetGenerator()->InitGenerator(`<SIGNING_KEY>`, EGeneratorAlgorithm::HS256);

Generate Signed Token Basic Example:

#include "EasyJwtSubsystem.h"

TSharedPtr<FEasyJwtModule> EasyJwt = GEngine->GetEngineSubsystem<UEasyJwtSubsystem>()->GetEasyJwt();

TMap<FString, FString> Claims =
{
	{"Claim1","34235"},
	{"Claim2","dfgds"}
};

TMap<FString, FString> HeaderClaims =
{
	{"HeaderClaim1","345343"},
	{"HeaderClaim2","jhgfdrtt"}
};
/*
Valid since generating it and for 900sec with the givem claims.
*/
FString JwtToken = EasyJwt->GetGenerator()->GenerateJwtToken(true, 0, 900, Claims, HeaderClaims);

Blueprint

Initialize the Generator

InitGenerator

Generate Signed Toker

GenerateToken

Blueprint API

GeneratorBp

JWT Verifier Basic Usage

C

Initialize the Verifier

#include "EasyJwtSubsystem.h"

TSharedPtr<FEasyJwtModule> EasyJwt = GEngine->GetEngineSubsystem<UEasyJwtSubsystem>()->GetEasyJwt();

EasyJwt->GetVerifier()->InitVerifier(`<SIGNING_KEY>`, EVerifierAlgorithm::HS256);

Verify a Token

#include "EasyJwtSubsystem.h"

TSharedPtr<FEasyJwtModule> EasyJwt = GEngine->GetEngineSubsystem<UEasyJwtSubsystem>()->GetEasyJwt();

bool bValid = EasyJwt->GetVerifier()->VerifyJWT(`<TOKEN_TO_VERIFY>`);

Get Claims From JWT

#include "EasyJwtSubsystem.h"

TSharedPtr<FEasyJwtModule> EasyJwt = GEngine->GetEngineSubsystem<UEasyJwtSubsystem>()->GetEasyJwt();

TMap<FString, FString> Claims = EasyJwt->GetVerifier()->GetClaims(`<JWT>`);

Blueprint

Initialize the Verifier

InitVerifier

Verify a Token

GenerateToken

Extract Claims From a JWT

Claims

Blueprint API

VerifierBp

Supported Algorithms

More to come soon!!

Find it helpful?

Give us a ⭐️!