aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-ci-github.cxx
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2025-02-11 15:45:52 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2025-02-12 11:11:25 +0200
commit6ff3737c632f4d77e3d60d9e13c23ceed5ea3468 (patch)
treef9803095f92b7fbcb9cf8a0ed4150bfb672e6054 /mod/mod-ci-github.cxx
parent217b2780813819bbad5c6eed41997d8e1e85fa8c (diff)
ci-github: Store App id as uint64_t
Diffstat (limited to 'mod/mod-ci-github.cxx')
-rw-r--r--mod/mod-ci-github.cxx19
1 files changed, 14 insertions, 5 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
index b71e85c..3d3fe7c 100644
--- a/mod/mod-ci-github.cxx
+++ b/mod/mod-ci-github.cxx
@@ -261,7 +261,7 @@ namespace brep
// Process the `app-id` and `warning` webhook request query parameters.
//
- string app_id;
+ uint64_t app_id;
bool warning_success;
{
const name_values& rps (rq.parameters (1024, true /* url_only */));
@@ -281,7 +281,16 @@ namespace brep
badreq ("missing 'app-id' webhook query parameter value");
ai = true;
- app_id = *rp.value;
+
+ // Parse the app id value.
+ //
+ char* e (nullptr);
+ app_id = strtoull (rp.value->c_str (), &e, 10);
+ if (app_id == 0 || app_id == ULLONG_MAX || *e != '\0')
+ {
+ badreq ("invalid 'app-id' webhook query parameter value: '" +
+ *rp.value + '\'');
+ }
}
else if (rp.name == "warning")
{
@@ -3295,7 +3304,7 @@ namespace brep
}
optional<string> ci_github::
- generate_jwt (const string& app_id,
+ generate_jwt (uint64_t app_id,
const basic_mark& trace,
const basic_mark& error) const
{
@@ -3304,7 +3313,7 @@ namespace brep
{
// Look up the private key path for the app id and fail if not found.
//
- const map<string, dir_path>& pks (
+ const map<uint64_t, dir_path>& pks (
options_->ci_github_app_id_private_key ());
auto pk (pks.find (app_id));
@@ -3320,7 +3329,7 @@ namespace brep
//
jwt = brep::generate_jwt (
*options_,
- pk->second, app_id,
+ pk->second, to_string (app_id),
chrono::seconds (options_->ci_github_jwt_validity_period ()),
chrono::seconds (60));