-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuthenticationManager.h
45 lines (38 loc) · 1.27 KB
/
AuthenticationManager.h
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
#ifndef CAVOKE_AUTHENTICATIONMANAGER_H
#define CAVOKE_AUTHENTICATIONMANAGER_H
#include <QOAuth2AuthorizationCodeFlow>
#include <QSettings>
namespace cavoke::auth {
/// Manages all Oauth2 related things. Including code flow itself and storing
/// refresh tokens.
struct AuthenticationManager : public QObject {
Q_OBJECT
public:
AuthenticationManager() = default;
QOAuth2AuthorizationCodeFlow oauth2;
/// Singleton wrapper
static AuthenticationManager &getInstance() {
static AuthenticationManager obj;
return obj;
}
bool checkAuthStatus();
void init();
void relogin();
signals:
void authenticated();
private:
void writeSecurePassword(const QString &profile, const QString &pass);
template <typename L>
void readSecurePassword(const QString &profile, L callback);
void deleteSecurePassword(const QString &profile);
QSettings settings{this}; // FIXME: move to qtkeychain
const static QString authorizationUrl;
const static QString accessTokenUrl;
const static QString logoutUrl;
const static QString clientId;
const static QString scope;
const static QString audience;
const static QString refresh_token_profile;
};
} // namespace cavoke::auth
#endif // CAVOKE_AUTHENTICATIONMANAGER_H