aboutsummaryrefslogtreecommitdiff
path: root/mod/jwt.hxx
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2024-02-06 16:35:59 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2024-12-10 11:16:07 +0200
commitabd6ede8444a89b6c56c20d06110cb3923b05bbe (patch)
tree48600db8ab80599e014c07ad79769469754321c0 /mod/jwt.hxx
parent1c994eadb89bdafdbeb7e16adcf4f0a55c497942 (diff)
Get installation access token (IAT) and restructure code
Diffstat (limited to 'mod/jwt.hxx')
-rw-r--r--mod/jwt.hxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/mod/jwt.hxx b/mod/jwt.hxx
new file mode 100644
index 0000000..b0df714
--- /dev/null
+++ b/mod/jwt.hxx
@@ -0,0 +1,37 @@
+#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).
+ //
+ // Return the token or throw std::system_error in case of an error.
+ //
+ string
+ generate_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