mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-04 11:51:44 +02:00
Add JWT class
This commit is contained in:
parent
97739a460e
commit
4321a9d9d1
10 changed files with 346 additions and 10 deletions
71
common/jwt.hpp
Normal file
71
common/jwt.hpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
/***
|
||||
This file is part of snapcast
|
||||
Copyright (C) 2014-2024 Johannes Pohl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#pragma once
|
||||
|
||||
// local headers
|
||||
#include "common/json.hpp"
|
||||
|
||||
// standard headers
|
||||
#include <string>
|
||||
|
||||
|
||||
/*
|
||||
https://datatracker.ietf.org/doc/html/rfc7518#section-3
|
||||
|
||||
+--------------+-------------------------------+--------------------+
|
||||
| "alg" Param | Digital Signature or MAC | Implementation |
|
||||
| Value | Algorithm | Requirements |
|
||||
+--------------+-------------------------------+--------------------+
|
||||
| HS256 | HMAC using SHA-256 | Required |
|
||||
| HS384 | HMAC using SHA-384 | Optional |
|
||||
| HS512 | HMAC using SHA-512 | Optional |
|
||||
| RS256 | RSASSA-PKCS1-v1_5 using | Recommended |
|
||||
| | SHA-256 | |
|
||||
| RS384 | RSASSA-PKCS1-v1_5 using | Optional |
|
||||
| | SHA-384 | |
|
||||
| RS512 | RSASSA-PKCS1-v1_5 using | Optional |
|
||||
| | SHA-512 | |
|
||||
| ES256 | ECDSA using P-256 and SHA-256 | Recommended+ |
|
||||
| ES384 | ECDSA using P-384 and SHA-384 | Optional |
|
||||
| ES512 | ECDSA using P-521 and SHA-512 | Optional |
|
||||
| PS256 | RSASSA-PSS using SHA-256 and | Optional |
|
||||
| | MGF1 with SHA-256 | |
|
||||
| PS384 | RSASSA-PSS using SHA-384 and | Optional |
|
||||
| | MGF1 with SHA-384 | |
|
||||
| PS512 | RSASSA-PSS using SHA-512 and | Optional |
|
||||
| | MGF1 with SHA-512 | |
|
||||
| none | No digital signature or MAC | Optional |
|
||||
| | performed | |
|
||||
+--------------+-------------------------------+--------------------+
|
||||
*/
|
||||
|
||||
// https://techdocs.akamai.com/iot-token-access-control/docs/generate-jwt-rsa-keys
|
||||
using json = nlohmann::json;
|
||||
|
||||
class Jwt
|
||||
{
|
||||
public:
|
||||
Jwt();
|
||||
|
||||
bool decode(const std::string& token);
|
||||
|
||||
private:
|
||||
json header_;
|
||||
json payload_;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue