blob: d1e00a28ebb997626c4084a7378989ea44cb4b30 (
plain) (
blame)
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
46
47
48
49
50
51
|
#pragma once
#include <Access/AuthenticationData.h>
#include <Common/Exception.h>
#include <base/types.h>
namespace DB
{
namespace ErrorCodes
{
extern const int BAD_ARGUMENTS;
}
class Credentials;
class ExternalAuthenticators;
/// TODO: Try to move this checking to Credentials.
struct Authentication
{
/// Checks the credentials (passwords, readiness, etc.)
static bool areCredentialsValid(const Credentials & credentials, const AuthenticationData & auth_data, const ExternalAuthenticators & external_authenticators);
// A signaling class used to communicate requirements for credentials.
template <typename CredentialsType>
class Require : public Exception
{
public:
explicit Require(const String & realm_);
const String & getRealm() const;
private:
const String realm;
};
};
template <typename CredentialsType>
Authentication::Require<CredentialsType>::Require(const String & realm_)
: Exception("Credentials required", ErrorCodes::BAD_ARGUMENTS)
, realm(realm_)
{
}
template <typename CredentialsType>
const String & Authentication::Require<CredentialsType>::getRealm() const
{
return realm;
}
}
|