Skip to content

Commit 253fec2

Browse files
authored
Markdown and whitespace tweaks (#370)
* Fix broken link * Document dependency on jwt-cpp * Simplify jwt-cpp/README.md to just point at upstream, like other third_party subdirectories * fix tabs to spaces
1 parent 5081f99 commit 253fec2

File tree

8 files changed

+24
-159
lines changed

8 files changed

+24
-159
lines changed

Development/cmake/NmosCppLibraries.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ target_link_libraries(
11101110
nmos-cpp::OpenSSL
11111111
nmos-cpp::cpprestsdk
11121112
nmos-cpp::Boost
1113-
nmos-cpp::jwt-cpp
1113+
nmos-cpp::jwt-cpp
11141114
)
11151115
target_link_libraries(
11161116
nmos-cpp PRIVATE

Development/cmake/NmosCppTest.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ target_link_libraries(
125125
nmos-cpp::mdns
126126
nmos-cpp::cpprestsdk
127127
nmos-cpp::Boost
128-
nmos-cpp::jwt-cpp
128+
nmos-cpp::jwt-cpp
129129
)
130130
if(NMOS_CPP_BUILD_LLDP)
131131
target_link_libraries(

Development/jwk/algorithm.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace jwk
88
DEFINE_STRING_ENUM(algorithm)
99
namespace algorithms
1010
{
11-
// RS256/RS384/RS512
11+
// RS256/RS384/RS512
1212
const algorithm RS256{ U("RS256") };
1313
const algorithm RS384{ U("RS384") };
1414
const algorithm RS512{ U("RS512") };

Development/nmos/api_utils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ namespace nmos
5353
const route_pattern connection_api = make_route_pattern(U("api"), U("connection"));
5454
// IS-07 Events API
5555
const route_pattern events_api = make_route_pattern(U("api"), U("events"));
56-
// IS-08 Channel Mapping API
57-
const route_pattern channelmapping_api = make_route_pattern(U("api"), U("channelmapping"));
56+
// IS-08 Channel Mapping API
57+
const route_pattern channelmapping_api = make_route_pattern(U("api"), U("channelmapping"));
5858
// IS-09 System API (originally specified in JT-NM TR-1001-1:2018 Annex A)
5959
const route_pattern system_api = make_route_pattern(U("api"), U("system"));
6060

Development/nmos/ws_api_utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ namespace nmos
5656
return true;
5757
};
5858
}
59-
}
59+
}
6060
}

Development/third_party/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Third-party source files used by the nmos-cpp libraries
77
- [cmake](cmake)
88
CMake modules derived from third-party sources
99
- [jwt-cpp](jwt-cpp)
10-
The [C++ JSON Web Tokens creator and validator] (https://github.com/Thalhammer/jwt-cpp) header only library
10+
The [Thalhammer/jwt-cpp](https://github.com/Thalhammer/jwt-cpp) header only library for creating and validating JSON Web Tokens in C++11
1111
- [mDNSResponder](mDNSResponder)
1212
Patches and patched source files for the Bonjour DNS-SD implementation
1313
- [nlohmann](nlohmann)
+5-152
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,8 @@
1-
<img src="https://raw.githubusercontent.com/Thalhammer/jwt-cpp/master/.github/logo.svg" alt="logo" width="100%">
1+
# jwt-cpp
22

3-
[![License Badge](https://img.shields.io/github/license/Thalhammer/jwt-cpp)](https://github.com/Thalhammer/jwt-cpp/blob/master/LICENSE)
4-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5f7055e294744901991fd0a1620b231d)](https://app.codacy.com/gh/Thalhammer/jwt-cpp/dashboard)
5-
[![Linux Badge][Linux]][Cross-Platform]
6-
[![MacOS Badge][MacOS]][Cross-Platform]
7-
[![Windows Badge][Windows]][Cross-Platform]
8-
[![Coverage Status](https://coveralls.io/repos/github/Thalhammer/jwt-cpp/badge.svg?branch=master)](https://coveralls.io/github/Thalhammer/jwt-cpp?branch=master)
3+
This directory contains files from the [Thalhammer/jwt-cpp](https://github.com/Thalhammer/jwt-cpp) header only library for creating and validating JSON Web Tokens in C++11.
94

10-
[![Documentation Badge](https://img.shields.io/badge/Documentation-master-blue)](https://thalhammer.github.io/jwt-cpp/)
5+
Original source code:
116

12-
[![Stars Badge](https://img.shields.io/github/stars/Thalhammer/jwt-cpp)](https://github.com/Thalhammer/jwt-cpp/stargazers)
13-
[![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/Thalhammer/jwt-cpp?include_prereleases)](https://github.com/Thalhammer/jwt-cpp/releases)
14-
[![ConanCenter package](https://repology.org/badge/version-for-repo/conancenter/jwt-cpp.svg)](https://repology.org/project/jwt-cpp/versions)
15-
[![Vcpkg package](https://repology.org/badge/version-for-repo/vcpkg/jwt-cpp.svg)](https://repology.org/project/jwt-cpp/versions)
16-
17-
[Linux]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/cross-platform/ubuntu-latest/shields.json
18-
[MacOS]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/cross-platform/macos-latest/shields.json
19-
[Windows]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/cross-platform/windows-latest/shields.json
20-
[Cross-Platform]: https://github.com/Thalhammer/jwt-cpp/actions?query=workflow%3A%22Cross-Platform+CI%22
21-
22-
A header only library for creating and validating [JSON Web Tokens](https://tools.ietf.org/html/rfc7519) in C++11. For a great introduction, [read this](https://jwt.io/introduction/).
23-
24-
## Signature algorithms
25-
26-
jwt-cpp supports all the algorithms defined by the specifications. The modular design allows to easily add additional algorithms without any problems. If you need any feel free to create a pull request or [open an issue](https://github.com/Thalhammer/jwt-cpp/issues/new).
27-
28-
For completeness, here is a list of all supported algorithms:
29-
30-
| HMSC | RSA | ECDSA | PSS | EdDSA |
31-
|-------|-------|--------|-------|---------|
32-
| HS256 | RS256 | ES256 | PS256 | Ed25519 |
33-
| HS384 | RS384 | ES384 | PS384 | Ed448 |
34-
| HS512 | RS512 | ES512 | PS512 | |
35-
| | | ES256K | | |
36-
37-
## SSL Compatibility
38-
39-
In the name of flexibility and extensibility, jwt-cpp supports [OpenSSL](https://github.com/openssl/openssl), [LibreSSL](https://github.com/libressl-portable/portable), and [wolfSSL](https://github.com/wolfSSL/wolfssl). Read [this page](docs/ssl.md) for more details. These are the version which are currently being tested:
40-
41-
| OpenSSL | LibreSSL | wolfSSL |
42-
|-------------------|----------------|----------------|
43-
| ![1.0.2u][o1.0.2] | ![3.3.6][l3.3] | ![5.1.1][w5.1] |
44-
| ![1.1.0i][o1.1.0] | ![3.4.3][l3.4] | ![5.2.0][w5.2] |
45-
| ![1.1.1q][o1.1.1] | ![3.5.3][l3.5] | ![5.3.0][w5.3] |
46-
| ![3.0.5][o3.0] | | |
47-
48-
> ℹ️ Note: A complete list of versions tested in the past can be found [here](https://github.com/Thalhammer/jwt-cpp/tree/badges).
49-
50-
[o1.0.2]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/1.0.2u/shields.json
51-
[o1.1.0]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/1.1.0i/shields.json
52-
[o1.1.1]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/1.1.1q/shields.json
53-
[o3.0]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/openssl/3.0.5/shields.json
54-
[l3.3]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/3.3.6/shields.json
55-
[l3.4]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/3.4.3/shields.json
56-
[l3.5]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/libressl/3.5.3/shields.json
57-
[w5.1]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.1.1/shields.json
58-
[w5.2]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.2.0/shields.json
59-
[w5.3]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/wolfssl/5.3.0/shields.json
60-
61-
## Overview
62-
63-
There is no hard dependency on a JSON library. Instead, there's a generic `jwt::basic_claim` which is templated around type traits, which described the semantic [JSON types](https://json-schema.org/understanding-json-schema/reference/type.html) for a value, object, array, string, number, integer and boolean, as well as methods to translate between them.
64-
65-
```cpp
66-
jwt::basic_claim<my_favorite_json_library_traits> claim(json::object({{"json", true},{"example", 0}}));
67-
```
68-
69-
This allows for complete freedom when picking which libraries you want to use. For more information, [read this page](docs/traits.md)).
70-
71-
For your convenience there are serval traits implementation which provide some popular JSON libraries. They are:
72-
73-
[![picojson][picojson]](https://github.com/kazuho/picojson)
74-
[![nlohmann][nlohmann]](https://github.com/nlohmann/json)
75-
[![jsoncons][jsoncons]](https://github.com/danielaparker/jsoncons)
76-
[![boostjson][boostjson]](https://github.com/boostorg/json)
77-
78-
[picojson]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/traits/kazuho-picojson/shields.json
79-
[nlohmann]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/traits/nlohmann-json/shields.json
80-
[jsoncons]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/traits/danielaparker-jsoncons/shields.json
81-
[boostjson]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/traits/boost-json/shields.json
82-
83-
In order to maintain compatibility, [picojson](https://github.com/kazuho/picojson) is still used to provide a specialized `jwt::claim` along with all helpers. Defining `JWT_DISABLE_PICOJSON` will remove this optional dependency. It's possible to directly include the traits defaults for the other JSON libraries. See the [traits examples](https://github.com/Thalhammer/jwt-cpp/tree/master/example/traits) for details.
84-
85-
As for the base64 requirements of JWTs, this library provides `base.h` with all the required implementation; However base64 implementations are very common, with varying degrees of performance. When providing your own base64 implementation, you can define `JWT_DISABLE_BASE64` to remove the jwt-cpp implementation.
86-
87-
### Getting Started
88-
89-
Simple example of decoding a token and printing all [claims](https://tools.ietf.org/html/rfc7519#section-4) ([try it out](https://github.com/Thalhammer/jwt-cpp/tree/master/example/print-claims.cpp)):
90-
91-
```cpp
92-
#include <jwt-cpp/jwt.h>
93-
#include <iostream>
94-
95-
int main() {
96-
std::string token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9.AbIJTDMFc7yUa5MhvcP03nJPyCPzZtQcGEp-zWfOkEE";
97-
auto decoded = jwt::decode(token);
98-
99-
for(auto& e : decoded.get_payload_json())
100-
std::cout << e.first << " = " << e.second << std::endl;
101-
}
102-
```
103-
104-
In order to verify a token you first build a verifier and use it to verify a decoded token.
105-
106-
```cpp
107-
auto verifier = jwt::verify()
108-
.allow_algorithm(jwt::algorithm::hs256{ "secret" })
109-
.with_issuer("auth0");
110-
111-
verifier.verify(decoded_token);
112-
```
113-
114-
The created verifier is stateless so you can reuse it for different tokens.
115-
116-
Creating a token (and signing) is equally as easy.
117-
118-
```cpp
119-
auto token = jwt::create()
120-
.set_issuer("auth0")
121-
.set_type("JWS")
122-
.set_payload_claim("sample", jwt::claim(std::string("test")))
123-
.sign(jwt::algorithm::hs256{"secret"});
124-
```
125-
126-
> To see more examples working with RSA public and private keys, visit our [examples](https://github.com/Thalhammer/jwt-cpp/tree/master/example)!
127-
128-
### Providing your own JSON Traits
129-
130-
To learn how to writes a trait's implementation, checkout the [these instructions](docs/traits.md)
131-
132-
## Contributing
133-
134-
If you have an improvement or found a bug feel free to [open an issue](https://github.com/Thalhammer/jwt-cpp/issues/new) or add the change and create a pull request. If you file a bug please make sure to include as much information about your environment (compiler version, etc.) as possible to help reproduce the issue. If you add a new feature please make sure to also include test cases for it.
135-
136-
## Dependencies
137-
138-
In order to use jwt-cpp you need the following tools.
139-
140-
* libcrypto (openssl or compatible)
141-
* libssl-dev (for the header files)
142-
* a compiler supporting at least c++11
143-
* basic stl support
144-
145-
In order to build the test cases you also need
146-
147-
* gtest
148-
* pthread
149-
150-
## Troubleshooting
151-
152-
See the [FAQs](docs/faqs.md) for tips.
153-
154-
## Conference Coverage
155-
[![CppCon](https://img.youtube.com/vi/Oq4NW5idmiI/0.jpg)](https://www.youtube.com/watch?v=Oq4NW5idmiI)
7+
- Licensed under the MIT License <http://opensource.org/licenses/MIT>.
8+
- Copyright (c) 2018 Dominik Thalhammer

Documents/Dependencies.md

+12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ More details are given below.
1212
- This library incorporates some third-party material including WebSocket++, and also relies on e.g. some of the Boost C++ Libraries and [OpenSSL](https://www.openssl.org/).
1313
- The [WebSocket++](https://github.com/zaphoyd/websocketpp) header-only C++ websocket client/server library, to implement Query API websocket subscriptions
1414
- For JSON Schema validation, the [Modern C++ JSON schema validator](https://github.com/pboettch/json-schema-validator) library, which is implemented on top of [JSON for Modern C++](https://github.com/nlohmann/json)
15+
- For creating and validating JSON Web Tokens, the [Thalhammer/jwt-cpp](https://github.com/Thalhammer/jwt-cpp) header only library
1516
- For DNS Service Discovery (DNS-SD), the [Bonjour SDK](https://developer.apple.com/bonjour/) on Windows, and on Linux either [Avahi](https://www.avahi.org/) or Apple's [mDNSResponder](https://opensource.apple.com/tarballs/mDNSResponder/) (another name for Bonjour)
1617
- The [Catch](https://github.com/philsquared/Catch) automated test framework, for unit testing
1718

@@ -257,6 +258,17 @@ No installation is necessary.
257258

258259
</details>
259260

261+
### jwt-cpp
262+
263+
If using Conan, this section can be skipped.
264+
<details>
265+
<summary>If not using Conan...</summary>
266+
267+
A copy of the source code necessary to use this library is included in the [third_party/jwt-cpp](../Development/third_party/jwt-cpp) directory.
268+
No installation is necessary.
269+
270+
</details>
271+
260272
### DNS Service Discovery
261273

262274
**Windows**

0 commit comments

Comments
 (0)