63 lines
1.9 KiB
C++
63 lines
1.9 KiB
C++
#pragma once
|
|
using namespace std;
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <utility>
|
|
|
|
class AuthModule
|
|
{
|
|
public:
|
|
virtual ~AuthModule() = default;
|
|
|
|
virtual const wchar_t *schemeName() = 0;
|
|
virtual vector<wstring> supportedVariations() = 0;
|
|
virtual vector<pair<wstring, wstring>> getSettings(const wstring &variation) = 0;
|
|
virtual bool onAuthData(const vector<pair<wstring, wstring>> &fields, wstring &outUid, wstring &outUsername) = 0;
|
|
|
|
bool validate(const wstring &uid, const wstring &username);
|
|
|
|
protected:
|
|
bool extractIdentity(const vector<pair<wstring, wstring>> &fields, wstring &outUid, wstring &outUsername);
|
|
};
|
|
|
|
class ElyByAuthModule : public AuthModule
|
|
{
|
|
protected:
|
|
wstring endpoint;
|
|
|
|
public:
|
|
ElyByAuthModule(const wstring &endpoint = L"https://authserver.ely.by");
|
|
|
|
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;
|
|
};
|
|
|
|
class MojangAuthModule : public ElyByAuthModule
|
|
{
|
|
public:
|
|
MojangAuthModule();
|
|
|
|
const wchar_t *schemeName() override;
|
|
vector<wstring> supportedVariations() override;
|
|
};
|
|
|
|
class KeypairOfflineAuthModule : public AuthModule
|
|
{
|
|
public:
|
|
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;
|
|
};
|
|
|
|
class OfflineAuthModule : public AuthModule
|
|
{
|
|
public:
|
|
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;
|
|
};
|