Skip to content

Commit 51a9611

Browse files
committed
Require alien token for all https URLs and for alice-ccdb.cern.ch, throw fatal if not present
1 parent 53d8cbf commit 51a9611

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

CCDB/src/CcdbApi.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ void CcdbApi::init(std::string const& host)
119119
snapshotReport += ')';
120120
}
121121

122-
mNeedAlienToken = host != "http://o2-ccdb.internal" && host != "http://localhost:8084" && host != "http://127.0.0.1:8084";
122+
const std::string httpsprefix = "https://";
123+
mNeedAlienToken = host.substr(0, httpsprefix.size()) == httpsprefix) || host == "http://alice-ccdb.cern.ch";
123124

124125
LOGP(info, "Init CcdApi with UserAgentID: {}, Host: {}{}", mUniqueAgentID, host,
125126
mInSnapshotMode ? "(snapshot readonly mode)" : snapshotReport.c_str());
@@ -756,7 +757,12 @@ bool CcdbApi::initTGrid() const
756757
mAlienInstance = TGrid::Connect("alien");
757758
static bool errorShown = false;
758759
if (!mAlienInstance && errorShown == false) {
759-
LOG(error) << "TGrid::Connect returned nullptr. May be due to missing alien token";
760+
bool allowNoToken = getenv("O2_CCDB_ALLOW_NO_TOKEN") && atoi(getenv("O2_CCDB_ALLOW_NO_TOKEN"));
761+
if (allowNoToken) {
762+
LOG(error) << "TGrid::Connect returned nullptr. May be due to missing alien token";
763+
} else {
764+
LOG(fatal) << "TGrid::Connect returned nullptr. May be due to missing alien token";
765+
}
760766
errorShown = true;
761767
}
762768
}

0 commit comments

Comments
 (0)