From d2da74a80feb32db3f9d7f347c76754665fb3fc2 Mon Sep 17 00:00:00 2001 From: Mehmet Ali Baykara Date: Sat, 9 Jan 2021 16:03:22 +0100 Subject: [PATCH] :card_index_dividers: Add Conan example (#119) * conan example added * remove cmake overhead * Update conan-example/CMakeLists.txt change cmake version Co-authored-by: Chris Mc Co-authored-by: Mehmet Ali Baykara Co-authored-by: Chris Mc --- conan-example/CMakeLists.txt | 7 +++++++ conan-example/README.md | 25 +++++++++++++++++++++++++ conan-example/conanfile.txt | 5 +++++ conan-example/main.cpp | 15 +++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 conan-example/CMakeLists.txt create mode 100644 conan-example/README.md create mode 100644 conan-example/conanfile.txt create mode 100644 conan-example/main.cpp diff --git a/conan-example/CMakeLists.txt b/conan-example/CMakeLists.txt new file mode 100644 index 0000000..0dcc350 --- /dev/null +++ b/conan-example/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.8) + +project(conan-example) +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() +add_executable(${PROJECT_NAME} main.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/conan-example/README.md b/conan-example/README.md new file mode 100644 index 0000000..3f985f5 --- /dev/null +++ b/conan-example/README.md @@ -0,0 +1,25 @@ +Conan example + + +In the current directory on Linux environment +``` +mkdir build && cd build +conan install .. && cmake .. +cmake --build . +``` +run executable +``` +./bin/conan-example +``` +the output: +``` +sub = "jrocket@example.com" +iss = "Online JWT Builder" +exp = 1641559177 +aud = "www.example.com" +Surname = "Rocket" +Role = ["Manager","Project Administrator"] +iat = 1610023177 +GivenName = "Johnny" +Email = "jrocket@example.com" +``` \ No newline at end of file diff --git a/conan-example/conanfile.txt b/conan-example/conanfile.txt new file mode 100644 index 0000000..335324e --- /dev/null +++ b/conan-example/conanfile.txt @@ -0,0 +1,5 @@ +[requires] +jwt-cpp/0.4.0 + +[generators] +cmake \ No newline at end of file diff --git a/conan-example/main.cpp b/conan-example/main.cpp new file mode 100644 index 0000000..3dc6420 --- /dev/null +++ b/conan-example/main.cpp @@ -0,0 +1,15 @@ +#include"jwt-cpp/jwt.h" +#include +#include + + +int main() { + + std::string token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE2MTAwMjMxNzcsImV4cCI6MTY0MTU1OTE3NywiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsIkdpdmVuTmFtZSI6IkpvaG5ueSIsIlN1cm5hbWUiOiJSb2NrZXQiLCJFbWFpbCI6Impyb2NrZXRAZXhhbXBsZS5jb20iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.5EOfHnBmpdPvRHAuVDttgJQvbFuGEF7fC4uBSXAGg6c"; + + auto decoded = jwt::decode(token); + + for(auto& e : decoded.get_payload_claims()) + std::cout << e.first << " = " << e.second << std::endl; + +} \ No newline at end of file