Skip to content

Commit 7076efa

Browse files
committed
allow builds without jwt
1 parent 8dbee4a commit 7076efa

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

ci/jobs/fast_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def clone_submodules():
5555
"contrib/incbin",
5656
"contrib/yaml-cpp",
5757
"contrib/corrosion",
58-
"contrib/jwt-cpp",
5958
]
6059

6160
res = Shell.check("git submodule sync", verbose=True, strict=True)

src/Access/AuthenticationData.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include <boost/algorithm/hex.hpp>
1515
#include <Poco/SHA1Engine.h>
1616

17-
#include <picojson/picojson.h>
18-
1917
#include "config.h"
2018

2119
#if USE_SSL
@@ -29,6 +27,10 @@
2927
# include <bcrypt.h>
3028
#endif
3129

30+
#if USE_JWT_CPP
31+
#include <picojson/picojson.h>
32+
#endif
33+
3234
namespace DB
3335
{
3436

@@ -658,6 +660,7 @@ AuthenticationData AuthenticationData::fromAST(const ASTAuthenticationData & que
658660
auth_data.setHTTPAuthenticationServerName(server);
659661
auth_data.setHTTPAuthenticationScheme(scheme);
660662
}
663+
#if USE_JWT_CPP
661664
else if (query.type == AuthenticationType::JWT)
662665
{
663666
if (!args.empty())
@@ -672,6 +675,7 @@ AuthenticationData AuthenticationData::fromAST(const ASTAuthenticationData & que
672675
auth_data.setJWTClaims(value);
673676
}
674677
}
678+
#endif
675679
else
676680
{
677681
throw Exception(ErrorCodes::LOGICAL_ERROR, "Unexpected ASTAuthenticationData structure");

src/Access/TokenProcessors.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
#pragma once
22

33
#include <Access/Credentials.h>
4-
#include <Access/Common/JWKSProvider.h>
54
#include <Poco/Util/AbstractConfiguration.h>
65

6+
#if USE_JWT_CPP
7+
#include <Access/Common/JWKSProvider.h>
78
#include <jwt-cpp/jwt.h>
89
#include <jwt-cpp/traits/kazuho-picojson/traits.h>
10+
#endif
911

1012
namespace DB
1113
{
1214

15+
namespace ErrorCodes
16+
{
17+
extern const int NOT_IMPLEMENTED;
18+
}
19+
1320
class ITokenProcessor
1421
{
1522
public:
@@ -20,7 +27,10 @@ class ITokenProcessor
2027
: processor_name(processor_name_), token_cache_lifetime(token_cache_lifetime_), username_claim(username_claim_), groups_claim(groups_claim_) {}
2128
virtual ~ITokenProcessor() = default;
2229

23-
virtual bool resolveAndValidate(TokenCredentials & credentials) const = 0;
30+
virtual bool resolveAndValidate(TokenCredentials &) const
31+
{
32+
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Not implemented for ITokenProcessor interface");
33+
}
2434

2535
virtual bool checkClaims(const TokenCredentials &, const String &) { return true; }
2636

@@ -37,10 +47,9 @@ class ITokenProcessor
3747
const UInt64 token_cache_lifetime;
3848
const String username_claim;
3949
const String groups_claim;
40-
41-
std::set<String> parseGroupsFromJsonArray(picojson::array groups_array) const;
4250
};
4351

52+
#if USE_JWT_CPP
4453
class StaticKeyJwtProcessor : public ITokenProcessor
4554
{
4655
public:
@@ -163,4 +172,6 @@ class OpenIdTokenProcessor : public ITokenProcessor
163172
std::optional<JwksJwtProcessor> jwt_validator = std::nullopt;
164173
};
165174

175+
#endif
176+
166177
}

src/Access/TokenProcessorsJWT.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,21 @@ bool check_claims(const String & claims, const picojson::value::object & payload
157157

158158
}
159159

160-
std::set<String> ITokenProcessor::parseGroupsFromJsonArray(picojson::array groups_array) const
160+
namespace
161+
{
162+
std::set<String> parseGroupsFromJsonArray(picojson::array groups_array)
161163
{
162164
std::set<String> external_groups_names;
163165

164-
for (const auto & group: groups_array)
166+
for (const auto & group : groups_array)
165167
{
166168
if (group.is<std::string>())
167169
external_groups_names.insert(group.get<std::string>());
168170
}
169171

170172
return external_groups_names;
171173
}
174+
}
172175

173176
StaticKeyJwtProcessor::StaticKeyJwtProcessor(const String & processor_name_,
174177
UInt64 token_cache_lifetime_,

0 commit comments

Comments
 (0)