Commit Graph

147 Commits

Author SHA1 Message Date
Marek Klein
275c750fa1 🔧 Replace deprecated OpenSSL functions (#191)
* do not use deprecated functions in ecdsa context

* check ecdsa key on creation

* add test

* set compiler flags correctly

* set compiler flags correctly attempt 2

Co-authored-by: Chris McArthur <prince.chrismc@gmail.com>
2021-12-12 10:25:43 -08:00
Marek Klein
55aaf31ad8 🔧 Replace RSA related deprecated functions (#189)
* RSA_size() --> EVP_PKEY_size()

* getting rid of deprecated functions in rsa-pss signature creation

* getting rid of deprecated functions in rsa-pss signature verification

* generate_hash not used in pss
2021-11-22 20:18:50 -08:00
Marek Klein
66eea980b5 🗜️ Simplify reading of EC keys (#185)
* simplify reading of EC keys

* fix formatting
2021-11-18 20:26:03 -08:00
Chris Mc
ab1a60ec8a ⬆️ Bump danielaparker/jsoncons to v0.167.1 (#178)
* Update traits.yml

* Update traits.yml

* better error report for missing method

* clean up traits implementation

in prep for Thalhammer#174
2021-09-27 09:23:36 -04:00
Chris Mc
de457af919 🐺 Add WolfSSL support (#171)
* outline for wolfssl support

lots of missing symbols

* rm old libressl dockerfile

* ass wolfssl test + dry up workflows

with improved composite action having `use` keyword

* autoreconf

* brute force zap openssl headers

* Update action.yml

* try to access nested headers

* trying to log include headers

* more debug logs

* fix bad variable

* tweaks

* more features

* cleanup

* wolfssl is special like libressl

* test header order

* revert order

* trying wolfssl master

* adding wolfssl compatiblity macros

trying to get access to

1662b01157/wolfssl/ssl.h (L3960)

* trying no newline

to fix tests

* typo

* bad copy paste pt2

* not a new line problem

* typo

* workaround failing helper test

* update cmake test

list(TRANSFORM raised min

* test cmake install with wolfSSL

* add missing EOF

* more generic wolfssl install

since there is no release that works yet

* typo

* debug print

* add more checks

* force HAVE_ECC

* install master

* hunter does not support wolfssl

* pretty job name

* clean up

* Update README.md

* bump to latest master

* Update cmake.yml

* bump coveralls action

* switch badge name to sha

* Update jwt.yml

they published a bad tag =)
2021-09-21 21:30:54 -04:00
Chris Mc
7fd8470cf1 🧷 Fuzz testing (#98)
* Update coverage.yml

* adding a fuzz test

* adding more fuzzing

TBA how to handle input requirement of decode

* base64 encoding input to avoid "obvious" exceptions

trying out the EVP_ interface from #89

* fixing decode fuzz

* accepting exceptions are normal

After comparing with https://github.com/nlohmann/json/blob/v3.9.0/test/src/fuzzer-parse_json.cpp I must agree data can be random so it should be accepted

* decoding twice should produce the same result

again based on https://github.com/nlohmann/json/blob/v3.9.0/test/src/fuzzer-parse_json.cpp

* fixing token decode fuzzer

* adding corpus for fuzz tests + adding them to ci

* removing numbers with more meaning descriptions

* Update BaseEncodeFuzz.cpp

* Update coverage.yml

* Update coverage.yml

* shrink interations

* cleaning cmake

* Update and rename coverage.yml to jwt.yml

* Update lint.yml

* Update jwt.yml

* Update jwt.yml
2021-09-17 20:01:38 -04:00
Chris Mc
aaf3c714e3 🔧 Fix shadow variables (#170)
* Renamed variables being shadowed by lambda arguments

Co-authored-by: Tobias Kux <XyFreak@users.noreply.github.com>

* Renamed lambda parameter name shadowing parameter of parent function

Co-authored-by: Tobias Kux <XyFreak@users.noreply.github.com>

* Update include/jwt-cpp/jwt.h

Co-authored-by: Tobias Kux <XyFreak@users.noreply.github.com>

Co-authored-by: Tobias Kux <XyFreak@users.noreply.github.com>
2021-09-13 20:37:38 -04:00
Chris Mc
bb8627bf66 🗺️ Add support for Boost.JSON traits (#165)
* wip boost test

* wip hardcoded just to test

* wip more

* working POC

* trying boost json with c++17

* working boost json standalone with cxx17

* Delete conanfile.txt

* revert some changes to see if they are required

* adding a workflow

* cleanup

* naming convention

* testing for substr on string_type

* trying to test for operator+

* fix check for operator+

* losen std::string requirement (experimental)

* Update .gitignore

Co-authored-by: gerardoprada <gerardoprada@users.noreply.github.com>

Co-authored-by: gerardoprada <gerardoprada@users.noreply.github.com>
2021-09-13 20:10:04 -04:00
Dominik Thalhammer
da4adc3651 Fix to_lower_unicode to do what it claims (#162)
No idea how it came in there and it doesn't influence anything as long as both expected and checked
value have the same casing (which they do since we apply it to both).
2021-09-01 18:54:08 +02:00
Aydin
402179d8fb 🔑 Using RSA_padding_add_PKCS1_PSS and RSA_verify_PKCS1_PSS functions (#159)
When both Hash and mgs1Hash parameters match in the _mgf1 equivalent calls,
or mgf1Hash is NULL, we can opt to use the non _mgf1 calls mentioned.
This change will allow wolfssl to be compiled with jwt-cpp.

Co-authored-by: Aydin Arik <aarik@teradici.com>
2021-09-01 12:01:37 -04:00
Chris Mc
d708be00b8 🔐 Adding support for "alg" ES256K (#156)
* adding support for alg es256k

* fix example

* chore: lint

* update alg tabls

Co-authored-by: Dominik Thalhammer <dominik@thalhammer.it>
2021-08-17 17:51:22 -04:00
Chris Mc
23fd608caf 📈 Improving OpenSSL test coverage (#155)
This cleans up some of the testing for specific ssl versions, updates LibreSSL tests to the latest patch versions and adds badges for OpenSSL test.
2021-08-17 13:42:24 +02:00
Marek Klein
17fdd26d97 Fix tests for OpenSSL 3.0.0 (#153)
* update signatures of PEM_write_bio_PUBKEY and PEM_write_bio_X509
* run tests with openssl
* Update .github/workflows/openssl.yml
* fetch openssl from github

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
2021-08-13 13:33:43 +02:00
Dominik Thalhammer
619948fdc0 Rework verifier checks (#148)
Reworks the verifier to allow for per claim verification functions. This removes the need for special cases in the core verifier and allows users to do advanced verification like deep object inspection or case sensitive/insensitive comparisons.

In addition a dedicated "typ" check has been added.

API Breakage: none
ABI Breakage: verifier
2021-07-08 11:46:54 +02:00
Tarun Chinmai Sekar
ae8d1ef632 Add JWKS parsing (#146)
* Add JWKS parsing
* Add more unit-tests, modify get_x5c to return an array per review-comments
* Add accessors for remaining jwk fields
* Apply suggestions from code review

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
Co-authored-by: Dominik Thalhammer <dominik@thalhammer.it>
2021-07-01 11:17:21 +02:00
Chris Mc
0d10b631ea 🐛 Fix warning C4267 from STL to OpenSSL API (#141) 2021-04-21 08:50:42 -04:00
Chris Mc
4620bf43be Remove unused member from eddsa algorithm base (#136)
* Remove unsed memember from eddsa algotithm base

* docs

* Remove silly test code
2021-03-20 17:08:12 +01:00
Chris Mc
0f20aa600f 🐛 Relax operator access syntax for MSVC (#132) 2021-02-14 09:52:11 -05:00
Dominik Thalhammer
cf11f094e3 Update picojson to most recent version (#123)
closes #92
2021-01-18 13:46:11 +01:00
Chris Mc
b21d80c22e 🧰 Linting and maintenance (#120)
* some manual fixes to obtain

* fairly close enough

* whitespace fixes

* add comment

* adding clang format + applied

* add editorconfig (supported natively by github web editor)

* apply linting to project

* clean up CI workflows

* zap vcpkg folder

actual one is here
https://github.com/microsoft/vcpkg/tree/master/ports/jwt-cpp

* adding a logo

* thin the lines in the pluses

* use logo + more links to spec and examples

* Create lint.yml

* apply linting
2021-01-11 17:37:14 -05:00
Chris Mc
ac3de9e69b 🐛 Remove noexcept specifiers when using default (#121)
the C++ ISO describes the expected behavoir where by default ctors may in fact be noexcept
ref: https://en.cppreference.com/w/cpp/language/noexcept_spec

resolves #118
2021-01-09 19:27:36 -05:00
Chris Mc
933fc1681f 🎛️ Expand support to include non STL container based JSON implementations (#117)
* initial outline for a jsoncons traits implementation

https://github.com/danielaparker/jsoncon

fix extracted dir

* make sure to set cmake to current directory

* install jwt + pass install prefix

fix bad copy paste

fix filename

* Update JsonconsTest.cpp

* add checks for type alias in object_type

* poc for checking for `cbegin` (begin does not work because of overloads... no sure how compilers do this in for loops

* add checks for begin method

* check for begin const overload

* add missing details to object_type

rm extra update

fix using ctor

* adding missing type trait for pretty print

fix typo

fix type extraction

* fix object wrapper extraction

revet int extraction

* try calling ctor directly

trying a differnt ctor

* trying operator[] with no args (hoping for default ctor)

* adding missing pair to second from it

* dont assume std::pair

more adjustments

* apply constness

* refactor parsing of claims to no longer assume/require std::pair

cherry picking https://github.com/dtiukalov/jwt-cpp/pull/1

* add missing header

* adding missing at functors

* add missing move assignment

fixes

implementing compilers

more indirection

attempt 3

more fixes

more ctors

oen more time

again

* fix serilization

* prefer apt-get for stable cli

* add note about serializationg requirements in readme

* adding call to get decoded claims (this should fail)

* print helpful failure message

* move get claim to traits test that support it

* remove cbegin traits check (not used) replaced with end

* adding count, at, and [] requirements to traits

dont used removed functions

update tests

changed missing claim to return expected ISO exception base type

* remove extra nesting namespace
2021-01-09 09:39:02 -05:00
Chris Mc
159527930e Make LibreSSL support official (tested against 3.3.0 along with CMake install) (#113)
outline to add libressl testing

add missing arg

fix bad copy paste

adding cmake option for openssl versus libressl

explicit directory

set cmake dirs

used seperate build folder + make directly

trying autotools

download cmake module

typo

link against correct ssl target

force openssl 1.0 API when using libressl

add missing macro

make sure to configure ssl error tests based on ssl lib/version

fix compare on min ssl version

fix compare

adding CMake install support to SSL optional

Make sure to copy fin package module

fix fake install path

Update cmake.yml

Update cmake.yml

Update tests/cmake/libressl-is-used.cpp

jwt header now configures itself for libressl (no externly dep on cmake)

this is acompnaied by a docker image to test libressl with

writing sheild.io json to seperate branch

fix bad syntax

make missing dirs

make sure to not overwrite files

add tables to advertise support

only update on push to master
2020-12-13 20:43:24 +01:00
Chris Mc
ca110ade5b 🔧 Improved CMake options and macros to prevent collisions (#109)
* exclude any folder prefixed with build

* seeing how far generator expresstion will go

* refactor cmake + outline some tests

* adding missing install destiniation

* rolling back some changes since the workflow was no support by CMake

* adding missing include

* fixing old variable names being used

* using target_compile_definitions instead of options

* correct options for CI + reporting errors for consumer

* using sudo to install

* fix bad variable

* trying CMAKE_PREFIX_PATH

* removing recursive call

* remove options from generators + dedicated exports target

* remove pthread link lib (unused)

* install targets files + include

* add missing main

* remove install prefix

* revive CMAKE_PREFIX_PATH it's really needed

* fix collision on DISABLE_BASE64 + more cmake tests

* bump cmake version + test minimum

* fix job names

* fix bad replace

* fix bad permissions

* fix install of picojson

* adding missing ifndef and overload for pico and no base64

* linting

* test for version

* trying to find version

* [test] remove semver prerelase from CMake

* fixing some documentation issues

* limit cmake test to only related files

* touch up docs

* making sure new helper supports no base64 mode

* some doc fixes

* Update cmake.yml

* Update .github/workflows/cmake.yml

* Update .gitignore
2020-11-29 15:56:53 +01:00
Chris Mc
4dc22036bf Removing code incorrectly introduced into nlohmann/json (#107)
while experimenting with the traits supporting `std::wstring` some test code was not reverted.

The new copy is simply https://github.com/nlohmann/json/releases/download/v3.9.1/json.hpp

This was flagged fd6cec9a8d (commitcomment-44012502)

/cc @nickform-ost
2020-11-11 16:35:45 +01:00
Jaideep Bajwa
aa258bdfdf Add helper function to convert cert from base64DER to PEM (#106)
* Add helper function to convert cert from base64DER to PEM

This is particularly useful when dealing with JWKs x5c claim which
is encoded as base64 DER. With this helper function the client can
convert x5c claim to PEM, which makes it easy to interact with this
library.
2020-11-08 22:04:51 +01:00
Dominik Thalhammer
0ebf4f16c9 Fix issue #100 and #99 (#105)
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
2020-10-26 16:48:50 +01:00
Dominik Thalhammer
7715cc2eff Bugfix type in ed448 implementation
partially fix for #99
2020-09-10 13:34:26 +02:00
Speeder
49d29e3d43 Added EdDSA support (#95)
* Fixed a build error

`jwt.h` previously depended on the nlohmann JSON library's inclusion of `iso646.h`, which defines the `not` operator.

* Added EdDSA support

https://github.com/Thalhammer/jwt-cpp/issues/79
Disabled EdDSA support when building with OpenSSL <1.1.1. Support for EdDSA came with OpenSSL version 1.1.1, incl. API extensions.

* Fixed build generation for Microsoft Visual Studio

* Fixed MSVC build warnings "hides previous local declaration"

* Fixed narrowing warnings when building with OpenSSL 1.0.2

* Compacted the string buffer initialization code pattern

As per review comment: https://github.com/Thalhammer/jwt-cpp/pull/95#discussion_r462985506

* adding eddsa openssl tests

* adding on mock openssl call as a test

* adding more mock openssl call to test failures

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
2020-08-03 23:40:08 +02:00
Speeder
8642cb0582 Fixed a build error (#91)
`jwt.h` previously depended on the nlohmann JSON library's inclusion of `iso646.h`, which defines the `not` operator.
2020-07-22 17:25:22 +02:00
Dominik Thalhammer
9711259ef2 Openssl testing (#90)
* Add error_code support to algorithm::verify

* Add error_code support for signing

* Add error_code overloads to verifying

* Fix missing throw

* Improvements

* Remove unused throwing overloads

* Fix test on older gtest

* Found bug and added more testing

* Move exceptions into error namespace

* Initial implementation of openssl tests

* Fix tests for older compilers

* Only enable openssl test on openssl >=1.1
2020-07-21 18:47:10 +02:00
Dominik Thalhammer
ab37be7df4 Initial support for std::error_code (#86)
* Add error_code support to algorithm::verify

* Add error_code support for signing

* Add error_code overloads to verifying

* Fix missing throw

* Improvements

* Remove unused throwing overloads

* Fix test on older gtest

* Found bug and added more testing

* Move exceptions into error namespace
2020-07-21 18:30:51 +02:00
Dominik Thalhammer
85c214d8e3 Merge branch 'master' into stl-detector 2020-07-16 11:26:05 +02:00
Matthias Vogelgesang
9be143971d Add virtual dtor to algo_base
Otherwise, compilers will complain if verifier is used as a member
variable.
2020-07-14 10:00:27 +02:00
Chris Mc
184134c317 Add cpp14check for fundamentals ts v2 include 2020-07-09 22:36:26 -04:00
Christopher McArthur
bc3cfd6479 add support for stl detect idiom
over in-house impl

closes #73
2020-07-09 20:55:14 -04:00
Chris Mc
00f96ea6e7 🖊️ improving documentation
around namespaces and implementating traits
2020-07-07 20:01:20 -04:00
Chris Mc
b93bdcf60b correcting decoded_jwt + builder api breaks
- decoded_jwt to expose get_payload_claims() and get_header_claims()
- builder set expires, not_before and issued correctly pass date as an arg
2020-07-01 17:33:42 -04:00
Dominik Thalhammer
9efa1c90c3 Use C++17 void_t if available
See #73
2020-06-27 14:10:28 +02:00
Dominik Thalhammer
2d362fddbe Move json types into json trait 2020-06-26 14:40:49 +02:00
Christopher McArthur
10361407f8 adding option to remove picojson dep 2020-06-10 20:38:22 -04:00
Chris Mc
cb8af09d10 adding option to disable the base64 support 2020-06-07 16:35:19 -04:00
Christopher McArthur
fea7c9feeb minor improvement to docs 2020-06-06 21:55:26 -04:00
Christopher McArthur
09797d2123 compressing static insertions
moved to two more generic type trait validation
2020-06-06 21:44:54 -04:00
Christopher McArthur
a080fbe0c0 proper adding clang-tidy config 2020-06-06 21:09:01 -04:00
Christopher McArthur
7b4d65dd2e clang-tidy fixes
- google-readability-namespace-comments
- hicpp-uppercase-literal-suffix
- llvm-include-order
- llvm-header-guard
- readability-const-return-type
- readability-else-after-return
- hicpp-special-member-functions
- google-readability-casting
2020-06-06 20:35:51 -04:00
Christopher McArthur
af43faaaa6 applying clang-tidy fixes
running clang-diagnostic-*,clang-analyzer-*,-*,bugprone*,modernize*,performance*,-modernize-pass-by-value,-modernize-use-auto,-modernize-use-using
2020-06-06 19:45:18 -04:00
Christopher McArthur
5fc1a6af50 removing decode assert + improved docs 2020-06-05 20:41:31 -04:00
Christopher McArthur
4993fc96a8 more type checking 2020-06-03 20:58:19 -04:00
Chris Mc
cdbc1168d7 removing as_set from traits 2020-05-31 10:16:32 -04:00