Skip to content

Conversation

@panik4
Copy link
Contributor

@panik4 panik4 commented Oct 15, 2019

I was not able to compile this on debian stretch with system g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 until I created the jwt::claim explicitly.

In file included from /tmp/scitokens-cpp/src/scitokens.cpp:7:0:
/tmp/scitokens-cpp/src/scitokens_internal.h: In member function ‘std::__cxx11::string scitokens::SciToken::serialize()’:
/tmp/scitokens-cpp/src/scitokens_internal.h:163:47: error: no match for ‘operator=’ (operand types are ‘std::unordered_map<std::__cxx11::basic_string, jwt::claim>::mapped_type {aka jwt::claim}’ and ‘std::__cxx11::string {aka std::__cxx11::basic_string}’)
m_claims["jti"] = std::string(uuid_str);
^
In file included from /tmp/scitokens-cpp/src/scitokens_internal.h:6:0,
from /tmp/scitokens-cpp/src/scitokens.cpp:7:
/usr/include/jwt-cpp/jwt.h:750:8: note: candidate: jwt::claim& jwt::claim::operator=(const jwt::claim&)
class claim {
^~~~~
/usr/include/jwt-cpp/jwt.h:750:8: note: no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string}’ to ‘const jwt::claim&’
/usr/include/jwt-cpp/jwt.h:750:8: note: candidate: jwt::claim& jwt::claim::operator=(jwt::claim&&)
/usr/include/jwt-cpp/jwt.h:750:8: note: no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string}’ to ‘jwt::claim&&’
/tmp/scitokens-cpp/src/scitokens.cpp: In function ‘int scitoken_set_claim_string(SciToken, const char*, const char*, char**)’:
/tmp/scitokens-cpp/src/scitokens.cpp:59:54: error: no matching function for call to ‘scitokens::SciToken::set_claim(const char*&, std::__cxx11::string)’
real_token->set_claim(key, std::string(value));
^
In file included from /tmp/scitokens-cpp/src/scitokens.cpp:7:0:
/tmp/scitokens-cpp/src/scitokens_internal.h:119:5: note: candidate: void scitokens::SciToken::set_claim(const string&, const jwt::claim&)
set_claim(const std::string &key, const jwt::claim &value) {
^~~~~~~~~
/tmp/scitokens-cpp/src/scitokens_internal.h:119:5: note: no known conversion for argument 2 from ‘std::__cxx11::string {aka std::__cxx11::basic_string}’ to ‘const jwt::claim&’

@bbockelm
Copy link
Contributor

@djw8605 - can you review this please?

@bbockelm bbockelm requested a review from djw8605 October 18, 2019 13:13
@duncanmmacleod
Copy link
Contributor

For me this patch isn't quite enough, I needed to duplicate the same change in a few more places:

diff --git a/src/scitokens.cpp b/src/scitokens.cpp
index 25e9607..54c1efb 100644
--- a/src/scitokens.cpp
+++ b/src/scitokens.cpp
@@ -56,7 +56,7 @@ int scitoken_set_claim_string(SciToken token, const char *key, const char *value
         return -1;
     }
     try {
-        real_token->set_claim(key, std::string(value));
+        real_token->set_claim(key, jwt::claim(std::string(value)));
     } catch (std::exception &exc) {
         if (err_msg) {
             *err_msg = strdup(exc.what());
diff --git a/src/scitokens_internal.h b/src/scitokens_internal.h
index db10078..ae7d4e6 100644
--- a/src/scitokens_internal.h
+++ b/src/scitokens_internal.h
@@ -203,19 +203,19 @@ public:
         uuid_generate(uuid);
         char uuid_str[37];
         uuid_unparse_lower(uuid, uuid_str);
-        m_claims["jti"] = std::string(uuid_str);
+        m_claims["jti"] = jwt::claim(std::string(uuid_str));

         if (m_serialize_profile == Profile::SCITOKENS_2_0) {
-            m_claims["ver"] = std::string("scitokens:2.0");
+            m_claims["ver"] = jwt::claim(std::string("scitokens:2.0"));
             auto iter = m_claims.find("aud");
             if (iter == m_claims.end()) {
-                m_claims["aud"] = std::string("ANY");
+                m_claims["aud"] = jwt::claim(std::string("ANY"));
             }
         } else if (m_serialize_profile == Profile::WLCG_1_0) {
-            m_claims["wlcg.ver"] = std::string("1.0");
+            m_claims["wlcg.ver"] = jwt::claim(std::string("1.0"));
             auto iter = m_claims.find("aud");
             if (iter == m_claims.end()) {
-                m_claims["aud"] = std::string("https://wlcg.cern.ch/jwt/v1/any");
+                m_claims["aud"] = jwt::claim(std::string("https://wlcg.cern.ch/jwt/v1/any"));
             }
         }

@bbockelm
Copy link
Contributor

bbockelm commented Feb 2, 2023

It looks like @duncanmmacleod rolled these into a later branch (which was merged). Closing for now.

@bbockelm bbockelm closed this Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants