Initial implementation, plus test programs.
This commit is contained in:
1 parent
e559e1dbdb
commit
f09ff2c9f7
12 files changed
+371
-19
No files matched your search
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include <forward_list>
|
||||
#include <string>
|
||||
|
||||
class AuthList
|
||||
{
|
||||
public:
|
||||
AuthList();
|
||||
|
||||
void add(const std::string& username);
|
||||
void remove(const std::string& username);
|
||||
bool confirm(const std::string& username);
|
||||
|
||||
private:
|
||||
std::forward_list<std::string> _allowedUsernames;
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <jwt-cpp/jwt.h>
|
||||
#include <jwp-plugin/AuthList.hpp>
|
||||
#include <optional>
|
||||
|
||||
class Authorizer
|
||||
{
|
||||
public:
|
||||
Authorizer(const std::string& pub_key, const std::string& issuer);
|
||||
static std::optional<std::string> read_key(const std::string& key_file);
|
||||
void add_unknown(const std::string& username);
|
||||
bool is_unknown(const std::string& username);
|
||||
bool add(const std::string& token, const std::string& username);
|
||||
bool can_read(const std::string& username);
|
||||
bool can_write(const std::string& username);
|
||||
void logout(const std::string& username);
|
||||
private:
|
||||
AuthList _writeList;
|
||||
AuthList _readList;
|
||||
AuthList _unknownList;
|
||||
|
||||
std::string _pub_key;
|
||||
std::string _issuer;
|
||||
};
|
||||
Reference in new issue
Block a user