aboutsummaryrefslogtreecommitdiff
path: root/zenserver/auth/oidc.h
blob: 4ed06317b8a3af47b951d6fd3b4037b6f6cb07e9 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright Epic Games, Inc. All Rights Reserved.

#include <zencore/string.h>

#include <vector>

namespace zen {

class OidcClient
{
public:
	struct Options
	{
		std::string_view BaseUrl;
		std::string_view ClientId;
	};

	OidcClient(const Options& Options);
	~OidcClient() = default;

	OidcClient(const OidcClient&) = delete;
	OidcClient& operator=(const OidcClient&) = delete;

	struct Result
	{
		std::string Reason;
		bool		Ok = false;
	};

	using InitResult = Result;

	InitResult Initialize();

	struct RefreshTokenResult
	{
		std::string TokenType;
		std::string AccessToken;
		std::string RefreshToken;
		std::string IdentityToken;
		std::string Scope;
		std::string Reason;
		int64_t		ExpiresInSeconds{};
		bool		Ok = false;
	};

	RefreshTokenResult RefreshToken(std::string_view RefreshToken);

private:
	using StringArray = std::vector<std::string>;

	struct OpenIdConfiguration
	{
		std::string Issuer;
		std::string AuthorizationEndpoint;
		std::string TokenEndpoint;
		std::string UserInfoEndpoint;
		std::string RegistrationEndpoint;
		std::string EndSessionEndpoint;
		std::string DeviceAuthorizationEndpoint;
		std::string JwksUri;
		StringArray SupportedResponseTypes;
		StringArray SupportedResponseModes;
		StringArray SupportedGrantTypes;
		StringArray SupportedScopes;
		StringArray SupportedTokenEndpointAuthMethods;
		StringArray SupportedClaims;
	};

	std::string			m_BaseUrl;
	std::string			m_ClientId;
	OpenIdConfiguration m_Config;
};

}  // namespace zen