* Create getting-started.md * Update getting-started.md * Create header-only.yml * Create package-managers.yml * Update package-managers.yml * Update getting-started.md * Update getting-started.md * Update header-only.yml * Update header-only.yml * Update header-only.yml * Update header-only.yml * use `jwt::algorithm::hs256` to link against openssl * add crypto * switch to ssl * Update header-only.yml * tidy * lets install conan * tidying * Adding a CMake target to make the docs * cleaning up repo root folder * fix typo * set docs flag as on * update awesome doxy theme to latest * Updated overrides for new version * output folder and target name are changed * add a few more docs * white space * cmake format * playing with settings * move algorithms - magically fixed missing structs * playing with the idea of more refactoring * more testing * moved evp_handle def to special namespace for doxygen * split evp class by it's self * fix doc links * playing with evp class to fix error -- no luck * revert testing changes * clang format * cache should be container specific * clean up includes * combined class definition * split algos but running in ci with older version * trying slightly newer version of doxygen * doxygen 196 * doxygen 197 * doxygen 198 * avoid regression in 198 * more docs * playing with adding examples * playing around with example support to see if I like * docs include all the example files to be referenced in the code * bump version to 0.7.0 * missing header * devcontainer for testing openssl 3 * add test explorer * add clang helpers * there's a lot of package managers in 2023 * fixup colors with doxygen 1.10 * bump doxygen version since my bug has been fixed * move everything to one file (too many changes) * update doxyfile to 1.10 * minimize diff * fix extra line * fix whitespace * clean up dev container * min changes * cleanup * better checking + warnings for doxygen * whitespace * adding in more docs * fix spelling * make sure traits appear * trying to add snippets from examples cant figure it out https://github.com/doxygen/doxygen/issues/10517 * Update faqs.md * Delete .github/workflows/header-only.yml * Delete .github/workflows/package-managers.yml * Delete example/conan/CMakeLists.txt * Delete example/conan/conanfile.txt * Delete example/conan/main.cpp * Delete example/conan/README.md * Update nlohmann-json.cpp * add updated getting started docs first pass towards https://github.com/Thalhammer/jwt-cpp/issues/319 * touch ups * linking deprecated messages * improve cmake with find_package examples * fix code link color * be more clear about turning off examples good suggestion https://github.com/Thalhammer/jwt-cpp/pull/321#issuecomment-1870488941 * clarify openssl install and fixup fetch tag * apply workaround from https://github.com/doxygen/doxygen/issues/10517#issuecomment-1870509240 * fix renamed types * linting * cross reference new docs * trying new alert syntax https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts * move sections out of readme trying to make it shorter and more approachable * improve "getting started" readme section with a more through example * sort out doubled "getting started" second one in docs/ is just installation * linter * fixup english * formatting * whitespace * tie in more examples with snippets * minor touch ups * Update signing.md * JWT_BUILD_DOCS * better cache string for new option * word crafting * word crafting * add missing open-source-parsers/jsoncpp to traits list * better github alert * fixup new shields io start style * improve docs cmake target name * linter --------- Co-authored-by: Christopher McArthur <christopherm@jfrog.com>
3.7 KiB
Frequently Asked Questions
Handling Tokens
The generated JWT token can be decoded, is this correct and secure?
This is the expected behavior. While the integrity of tokens is ensured by the generated/verified hash, the contents of the token are only encoded and not encrypted. This means you can be sure the token has not been modified by an unauthorized party, but you should not store confidential information in it. Anyone with access to the token can read all the claims you put into it. They can however not modify them unless they have the (private or symmetric) key used to generate the token. If you need to put confidential information into it, current industry recommends generating a random id and store the data on your server, using the id to look it up whenever you need.
How can new keys be generated for my application?
The algorithms provided are all based on OpenSSL, mixing other cryptographic tools might not work.
Here are a few links for your convenience:
Can this library encrypt/decrypt claims?
No it does not, see #115 for more details. More importantly you probably don't want to be using JWTs for anything sensitive. Read this for more.
Why are my tokens immediately expired?
If you are generating tokens that seem to immediately expire, you are likely mixing local time where it is not required. The JWT specification requires using UTC which this library does.
Here is a simple example of creating a token that will expire in one hour:
auto token = jwt::create()
.set_issued_now()
.set_expires_in(std::chrono::seconds{3600})
.sign(jwt::algorithm::hs256{"secret"});
Can you add claims to a signed token?
The signature includes both the header and payload, according to the RFCs... changing the payload would cause a discrepancy. That should result in the token being rejected. For more details checkout #194.
Why does jwt::basic_claim have no as_object() method?
This was brought up in #212 and #101 as it's an excellent question.
It simply was not required to handle the required keys in JWTs for signing or verification. All the the mandatory keys are numeric, string or array types which required type definitions and access.
The alternative is to use the to_json() method and use the libraries own APIs to pick the data type you need.
Build Issues
Missing _HMAC and _EVP_sha256 symbols on Mac
There seems to exists a problem with the included openssl library of MacOS. Make sure you link to one provided by brew. See #6 for more details.
Building on windows fails with syntax errors
The header <Windows.h>, which is often included in Windows projects, defines macros for MIN and MAX which conflicts
with std::numeric_limits. See #5 for more details or this StackOverflow thread.
To fix this do one of the following things:
- define
NOMINMAX, which suppresses this behavior - include this library before you
#include <Windows.h> - place
#undef maxand#undef minbefore you include this library