Skip to content

Commit cdbd3d5

Browse files
authored
Feature/access token (#21650)
1 parent f07b691 commit cdbd3d5

22 files changed

+1160
-371
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ devel
1010
* Fix vector index comparison in maintenance, which causes loop with agency and
1111
dbservers.
1212

13+
* Added support for access tokens. Access token can be used instead of
14+
a password. However, the recommended way is to generate a JWT token
15+
using /_open/auth.
16+
1317
* Fix a bug in the index API /_api/index?withHidden=true, which can lead to
1418
two problems: (1) A newly created index is potentially not shown in
1519
the very moment when it is finished. (2) A newly created index is

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,6 @@ add_subdirectory(3rdParty/faiss EXCLUDE_FROM_ALL)
10811081

10821082
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_ORIG}")
10831083

1084-
10851084
# ------------------------------------------------------------------------------
10861085
# RocksDB
10871086
# ------------------------------------------------------------------------------

arangod/Auth/TokenCache.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ auth::TokenCache::Entry auth::TokenCache::checkAuthenticationBasic(
158158
std::string up;
159159
absl::Base64Unescape(secret, &up);
160160
std::string::size_type n = up.find(':', 0);
161-
if (n == std::string::npos || n == 0 || n + 1 > up.size()) {
161+
// if password is an access token then username might be empty
162+
if (n == std::string::npos || /* n == 0 || */ n + 1 > up.size()) {
162163
LOG_TOPIC("2a529", TRACE, arangodb::Logger::AUTHENTICATION)
163164
<< "invalid authentication data found, cannot extract "
164165
"username/password";
@@ -167,8 +168,13 @@ auth::TokenCache::Entry auth::TokenCache::checkAuthenticationBasic(
167168

168169
std::string username = up.substr(0, n);
169170
std::string password = up.substr(n + 1);
171+
std::string un;
172+
bool authorized = _userManager->checkCredentials(username, password, un);
173+
174+
if (authorized) {
175+
username = un;
176+
}
170177

171-
bool authorized = _userManager->checkPassword(username, password);
172178
double expiry = _authTimeout;
173179
if (expiry > 0) {
174180
expiry += TRI_microtime();

0 commit comments

Comments
 (0)