From dfa7d29dae9d3b3cc1d8a434bc8e5ca330e6202f Mon Sep 17 00:00:00 2001 From: Omar Mohamed Date: Sat, 21 Sep 2024 20:36:29 +0300 Subject: [PATCH 1/3] Use operator[] instead of front to support jsoncpp Replace the `front()` with `[0]` as front is not supported by jsoncpp on array types. Signed-off-by: Omar Mohamed --- include/jwt-cpp/jwt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h index 21960cd0..b78e2120 100644 --- a/include/jwt-cpp/jwt.h +++ b/include/jwt-cpp/jwt.h @@ -3925,7 +3925,7 @@ namespace jwt { auto x5c_array = get_jwk_claim("x5c").as_array(); if (x5c_array.size() == 0) throw error::claim_not_present_exception(); - return json_traits::as_string(x5c_array.front()); + return json_traits::as_string(x5c_array[0]); }; /** From 2080a10febf8a5f69ebb682aa1addf0b262f3bde Mon Sep 17 00:00:00 2001 From: Omar Mohamed Date: Sun, 22 Sep 2024 11:33:34 +0300 Subject: [PATCH 2/3] Revert "Use operator[] instead of front to support jsoncpp" This reverts commit dfa7d29dae9d3b3cc1d8a434bc8e5ca330e6202f. --- include/jwt-cpp/jwt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h index b78e2120..21960cd0 100644 --- a/include/jwt-cpp/jwt.h +++ b/include/jwt-cpp/jwt.h @@ -3925,7 +3925,7 @@ namespace jwt { auto x5c_array = get_jwk_claim("x5c").as_array(); if (x5c_array.size() == 0) throw error::claim_not_present_exception(); - return json_traits::as_string(x5c_array[0]); + return json_traits::as_string(x5c_array.front()); }; /** From 776b79206902462e8ff4c25296c8ca2540e1a447 Mon Sep 17 00:00:00 2001 From: Omar Mohamed Date: Sun, 22 Sep 2024 11:48:12 +0300 Subject: [PATCH 3/3] Implement `front()` in jsoncpp array_type Signed-off-by: Omar Mohamed --- include/jwt-cpp/traits/open-source-parsers-jsoncpp/traits.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/jwt-cpp/traits/open-source-parsers-jsoncpp/traits.h b/include/jwt-cpp/traits/open-source-parsers-jsoncpp/traits.h index 5442ba0f..8d64dd7d 100644 --- a/include/jwt-cpp/traits/open-source-parsers-jsoncpp/traits.h +++ b/include/jwt-cpp/traits/open-source-parsers-jsoncpp/traits.h @@ -33,6 +33,10 @@ namespace jwt { ~array_type() = default; array_type& operator=(const array_type& o) = default; array_type& operator=(array_type&& o) noexcept = default; + + value_type& front() { return this->operator[](0U); } + + value_type const& front() const { return this->operator[](0U); } }; using number_type = double; using integer_type = Json::Value::Int;