Skip to content

Commit 89b4e8a

Browse files
committed
validate claims in separate method
1 parent acaf9c5 commit 89b4e8a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

include/jwt-cpp/jwt.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3360,6 +3360,15 @@ namespace jwt {
33603360
/// Supported algorithms
33613361
std::unordered_map<std::string, std::shared_ptr<algo_base>> algs;
33623362

3363+
void verify_claims(const decoded_jwt<json_traits>& jwt, std::error_code& ec) const {
3364+
verify_ops::verify_context<json_traits> ctx{clock.now(), jwt, default_leeway};
3365+
for (auto& c : claims) {
3366+
ctx.claim_key = c.first;
3367+
c.second(ctx, ec);
3368+
if (ec) return;
3369+
}
3370+
}
3371+
33633372
public:
33643373
/**
33653374
* Constructor for building a new verifier instance
@@ -3551,12 +3560,7 @@ namespace jwt {
35513560
algs.at(algo)->verify(data, sig, ec);
35523561
if (ec) return;
35533562

3554-
verify_ops::verify_context<json_traits> ctx{clock.now(), jwt, default_leeway};
3555-
for (auto& c : claims) {
3556-
ctx.claim_key = c.first;
3557-
c.second(ctx, ec);
3558-
if (ec) return;
3559-
}
3563+
verify_claims(jwt, ec);
35603564
}
35613565
};
35623566

0 commit comments

Comments
 (0)