44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
#pragma once
|
|
using namespace std;
|
|
#include "AuthModule.h"
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
struct YggdrasilProviderConfig
|
|
{
|
|
wstring name;
|
|
wstring displayName;
|
|
string authUrl;
|
|
string sessionUrl;
|
|
string authenticateUrl() const { return authUrl + "/authenticate"; }
|
|
string validateUrl() const { return authUrl + "/validate"; }
|
|
string refreshUrl() const { return authUrl + "/refresh"; }
|
|
string joinUrl() const { return sessionUrl + "/join"; }
|
|
string hasJoinedUrl() const { return sessionUrl + "/hasJoined"; }
|
|
};
|
|
|
|
class YggdrasilRegistry
|
|
{
|
|
public:
|
|
static void load();
|
|
static const vector<YggdrasilProviderConfig> &providers();
|
|
static const YggdrasilProviderConfig *find(const wstring &name);
|
|
static const YggdrasilProviderConfig &defaultProvider();
|
|
};
|
|
|
|
class SessionAuthModule : public AuthModule
|
|
{
|
|
private:
|
|
const YggdrasilProviderConfig *activeProvider = nullptr;
|
|
wstring activeServerId;
|
|
|
|
bool serverVerify(const YggdrasilProviderConfig &provider, const wstring &username, const wstring &serverId, wstring &outUid, wstring &outUsername);
|
|
|
|
public:
|
|
SessionAuthModule() = default;
|
|
|
|
const wchar_t *schemeName() override;
|
|
vector<wstring> supportedVariations() override;
|
|
vector<pair<wstring, wstring>> getSettings(const wstring &variation) override;
|
|
bool onAuthData(const vector<pair<wstring, wstring>> &fields, wstring &outUid, wstring &outUsername) override;
|
|
};
|