aboutsummaryrefslogtreecommitdiff
path: root/zenserver/auth/authmgr.h
blob: 0354bdbfa9ffdb46d91ecdca7555e1c14be3bdfb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright Epic Games, Inc. All Rights Reserved.

#include <zencore/crypto.h>
#include <zencore/iobuffer.h>
#include <zencore/string.h>

#include <chrono>
#include <filesystem>
#include <memory>

namespace zen {

struct AuthConfig
{
	std::filesystem::path RootDirectory;
	std::chrono::seconds  UpdateInterval{30};
	AesKey256Bit		  EncryptionKey;
	AesIV128Bit			  EncryptionIV;
};

class AuthMgr
{
public:
	virtual ~AuthMgr() = default;

	struct AddOpenIdProviderParams
	{
		std::string_view Name;
		std::string_view Url;
		std::string_view ClientId;
	};

	virtual void AddOpenIdProvider(const AddOpenIdProviderParams& Params) = 0;

	struct AddOpenIdTokenParams
	{
		std::string_view ProviderName;
		std::string_view RefreshToken;
	};

	virtual bool AddOpenIdToken(const AddOpenIdTokenParams& Params) = 0;

	struct OpenIdAccessToken
	{
		std::string							  AccessToken;
		std::chrono::system_clock::time_point ExpireTime{};
	};

	virtual OpenIdAccessToken GetOpenIdAccessToken(std::string_view ProviderName) = 0;

	static std::unique_ptr<AuthMgr> Create(const AuthConfig& Config);
};

}  // namespace zen