Skip to content

Commit 9dcc769

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 1c00d53 + 8865f06 commit 9dcc769

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/scitokens.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int scitoken_set_claim_string(SciToken token, const char *key, const char *value
5656
return -1;
5757
}
5858
try {
59-
real_token->set_claim(key, std::string(value));
59+
real_token->set_claim(key, jwt::claim(std::string(value)));
6060
} catch (std::exception &exc) {
6161
if (err_msg) {
6262
*err_msg = strdup(exc.what());

src/scitokens_cache.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
#include <cstdint>
33
#include <string>
4-
#include <vector>
4+
#include <memory>
55

66
#include <pwd.h>
77
#include <stdlib.h>
@@ -11,7 +11,7 @@
1111
#ifndef PICOJSON_USE_INT64
1212
#define PICOJSON_USE_INT64
1313
#endif
14-
#include <jwt-cpp/picojson.h>
14+
#include <picojson/picojson.h>
1515
#include <sqlite3.h>
1616

1717
#include "scitokens_internal.h"
@@ -54,12 +54,11 @@ get_cache_file() {
5454
auto bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
5555
bufsize = (bufsize == -1) ? 16384 : bufsize;
5656

57-
std::vector<char> buf;
58-
buf.reserve(bufsize);
57+
std::unique_ptr<char[]> buf(new char[bufsize]);
5958

6059
std::string home_dir;
6160
struct passwd pwd, *result = NULL;
62-
getpwuid_r(geteuid(), &pwd, &buf[0], bufsize, &result);
61+
getpwuid_r(geteuid(), &pwd, buf.get(), bufsize, &result);
6362
if (result && result->pw_dir) {
6463
home_dir = result->pw_dir;
6564
home_dir += "/.cache";

src/scitokens_internal.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

22
#include <memory>
33
#include <sstream>
4+
#include <functional>
45

56
#include <curl/curl.h>
67
#include <jwt-cpp/base.h>
78
#include <jwt-cpp/jwt.h>
8-
#include <jwt-cpp/picojson.h>
9+
#include <picojson/picojson.h>
910
#include <openssl/bn.h>
1011
#include <openssl/ec.h>
1112

@@ -100,7 +101,7 @@ parse_url(const std::string &url, std::string &schema, std::string &netloc,
100101
schema.reserve(distance(url.begin(), prot_iter));
101102
std::transform(url.begin(), prot_iter,
102103
std::back_inserter(schema),
103-
std::ptr_fun<int,int>(tolower));
104+
std::function<int(int)>(tolower));
104105
if (prot_iter == url.end() )
105106
{
106107
throw InvalidIssuerException("Issuer URL missing hostname.");
@@ -110,7 +111,7 @@ parse_url(const std::string &url, std::string &schema, std::string &netloc,
110111
netloc.reserve(std::distance(prot_iter, path_iter));
111112
std::transform(prot_iter, path_iter,
112113
std::back_inserter(netloc),
113-
std::ptr_fun<int,int>(tolower));
114+
std::function<int(int)>(tolower));
114115
std::string::const_iterator query_iter = std::find(path_iter, url.end(), '?');
115116
path.assign(path_iter, query_iter);
116117
}

src/scitokens_internal.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,19 @@ friend class scitokens::Validator;
203203
uuid_generate(uuid);
204204
char uuid_str[37];
205205
uuid_unparse_lower(uuid, uuid_str);
206-
m_claims["jti"] = std::string(uuid_str);
206+
m_claims["jti"] = jwt::claim(std::string(uuid_str));
207207

208208
if (m_serialize_profile == Profile::SCITOKENS_2_0) {
209-
m_claims["ver"] = std::string("scitokens:2.0");
209+
m_claims["ver"] = jwt::claim(std::string("scitoken:2.0"));
210210
auto iter = m_claims.find("aud");
211211
if (iter == m_claims.end()) {
212-
m_claims["aud"] = std::string("ANY");
212+
m_claims["aud"] = jwt::claim(std::string("ANY"));
213213
}
214214
} else if (m_serialize_profile == Profile::WLCG_1_0) {
215-
m_claims["wlcg.ver"] = std::string("1.0");
215+
m_claims["wlcg.ver"] = jwt::claim(std::string("1.0"));
216216
auto iter = m_claims.find("aud");
217217
if (iter == m_claims.end()) {
218-
m_claims["aud"] = std::string("https://wlcg.cern.ch/jwt/v1/any");
218+
m_claims["aud"] = jwt::claim(std::string("https://wlcg.cern.ch/jwt/v1/any"));
219219
}
220220
}
221221

@@ -312,7 +312,7 @@ class Validator {
312312
throw jwt::token_verification_exception("'ver' claim value must be a string (if present)");
313313
}
314314
std::string ver_string = claim.as_string();
315-
if (ver_string == "scitokens:2.0") {
315+
if ((ver_string == "scitokens:2.0") || (ver_string == "scitoken:2.0")) {
316316
must_verify_everything = false;
317317
if ((m_validate_profile != SciToken::Profile::COMPAT) &&
318318
(m_validate_profile != SciToken::Profile::SCITOKENS_2_0))

0 commit comments

Comments
 (0)