blob: 550649f2d4e4ea57ef67af92b0ac166954085f35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#ifndef MOD_JWT_HXX
#define MOD_JWT_HXX
#include <libbrep/types.hxx>
#include <libbrep/utility.hxx>
#include <mod/module-options.hxx>
#include <chrono>
namespace brep
{
// Generate a JSON Web Token (JWT), defined in RFC7519.
//
// A JWT is essentially the token issuer's name along with a number of
// claims, signed with a private key.
//
// Note that only GitHub's requirements are implemented, not the entire JWT
// spec; see the source file for details.
//
// The token expires when the validity period has elapsed.
//
// The backdate argument specifies the number of seconds to subtract from
// the "issued at" time in order to combat potential clock drift (which can
// cause the token to be not valid yet).
//
// @@ TODO Is there a standard term? "drift" or "drift value" seems to be
// used quite often.
//
// Return the token or throw std::system_error in case of an error.
//
string
gen_jwt (const options::openssl_options&,
const path& private_key,
const string& issuer,
const std::chrono::seconds& validity_period,
const std::chrono::seconds& backdate = std::chrono::seconds (60));
}
#endif
|