major refactor: auth v3
This commit is contained in:
parent
8a8b4b2573
commit
179d21d7b6
18 changed files with 376 additions and 166 deletions
|
|
@ -1,24 +1,41 @@
|
|||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
#include "AuthModule.h"
|
||||
#include <unordered_map>
|
||||
#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
|
||||
{
|
||||
public:
|
||||
struct EndpointPair {
|
||||
wstring authEndpoint;
|
||||
wstring sessionEndpoint;
|
||||
};
|
||||
|
||||
private:
|
||||
unordered_map<wstring, EndpointPair> endpoints;
|
||||
wstring activeSessionEndpoint;
|
||||
const YggdrasilProviderConfig *activeProvider = nullptr;
|
||||
wstring activeServerId;
|
||||
|
||||
bool serverVerify(const YggdrasilProviderConfig &provider, const wstring &username, const wstring &serverId, wstring &outUid, wstring &outUsername);
|
||||
|
||||
public:
|
||||
SessionAuthModule();
|
||||
SessionAuthModule() = default;
|
||||
|
||||
const wchar_t *schemeName() override;
|
||||
vector<wstring> supportedVariations() override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue