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-06-05 09:12:45 +0200
commita376770e0a8ed304660d911dfc4448aeb8c814b0 (patch)
tree1d29153a38480d514cb716d53e104502edd703d5 /mod/jwt.hxx
parent976d5d4c0c8b8b9eeaf2f386e72e2db06e83ac41 (diff)
Generate JWT
Diffstat (limited to 'mod/jwt.hxx')
-rw-r--r--mod/jwt.hxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/mod/jwt.hxx b/mod/jwt.hxx
new file mode 100644
index 0000000..65ad5c5
--- /dev/null
+++ b/mod/jwt.hxx
@@ -0,0 +1,35 @@
+#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 RFC 7519.
+ //
+ // 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.
+ //
+ // Return the token or empty if openssl exited with a non-zero status.
+ //
+ // Throw process_error or io_error (both derived from std::system_error) if
+ // openssl could not be executed or communication with its process failed.
+ //
+ string
+ gen_jwt (const options::openssl_options&,
+ const path& private_key,
+ const string& issuer,
+ const std::chrono::minutes& validity_period);
+}
+
+#endif