Skip to content

Commit dbecd71

Browse files
committed
metrics: add support for claim value counters in OIDCMetricsData
do not reset Prometheus counters by default, only when explicitly specified; reset to 0 in case of an integer overflow Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 98edbb1 commit dbecd71

File tree

8 files changed

+348
-237
lines changed

8 files changed

+348
-237
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
02/13/2025
2+
- metrics: add support for claim value counters in OIDCMetricsData
3+
- metrics: do not reset Prometheus counters by default, only when explicitly specified
4+
- metrics: reset to 0 in case of an integer overflow
5+
- bump to 2.4.16.8rc0
6+
17
01/29/2025
28
- add OIDCProfile to configure OpenID Connect profile behaviours for, so far "FAPI20" only, which configures:
39
Authentication Request method, DPoP, PKCE, ID token aud values requirements

auth_openidc.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,13 +1082,14 @@
10821082
# authn Authentication request creation and response processing.
10831083
# authz Authorization errors per OIDCUnAutzAction (per Require statement, not overall).
10841084
# require.claim Match/failure count of Require claim directives (per Require statement, not overall).
1085+
# claim.* ID token / Userinfo claim name/value at login and refresh.
10851086
# provider Requests to the provider [token, userinfo, metadata] endpoints.
10861087
# session Existing session processing.
10871088
# cache Cache read/write timings and errors.
10881089
# redirect_uri Requests to the Redirect URI, per type.
10891090
# content Requests to the content handler, per type of request: info, metrics, jwks, etc.
10901091
# When not defined no metrics will be recorded.
1091-
#OIDCMetricsData [ authtype | authn | authz | require.claim | requests | session | cache | redirect_uri | content ]+
1092+
#OIDCMetricsData [ authtype | authn | authz | require.claim | claim.id_token.* | claim.userinfo.* | requests | session | cache | redirect_uri | content ]+
10921093

10931094
# Specify the path where metrics are published and can be consumed.
10941095
# The format parameter can be passed to specify the format in which the collected data is returned.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([mod_auth_openidc],[2.4.16.7],[[email protected]])
1+
AC_INIT([mod_auth_openidc],[2.4.16.8rc0],[[email protected]])
22

33
AC_SUBST(NAMEVER, AC_PACKAGE_TARNAME()-AC_PACKAGE_VERSION())
44

src/handle/authz.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ authz_status oidc_authz_24_worker(request_rec *r, json_t *claims, const char *re
436436
/* see if we can match any of out input claims against this Require'd value */
437437
if (match_claim_fn(r, w, claims) == TRUE) {
438438

439-
OIDC_METRICS_COUNTER_INC_SPEC(r, cfg, OM_AUTHZ_MATCH_REQUIRE_CLAIM, require_args);
439+
OIDC_METRICS_COUNTER_INC_VALUE(r, cfg, OM_AUTHZ_MATCH_REQUIRE_CLAIM, require_args);
440440

441441
oidc_debug(r, "require claim/expr '%s' matched", w);
442442
return AUTHZ_GRANTED;
@@ -448,7 +448,7 @@ authz_status oidc_authz_24_worker(request_rec *r, json_t *claims, const char *re
448448
oidc_warn(r, "'require claim/expr' missing specification(s) in configuration, denying");
449449
}
450450

451-
OIDC_METRICS_COUNTER_INC_SPEC(r, cfg, OM_AUTHZ_ERROR_REQUIRE_CLAIM, require_args);
451+
OIDC_METRICS_COUNTER_INC_VALUE(r, cfg, OM_AUTHZ_ERROR_REQUIRE_CLAIM, require_args);
452452

453453
oidc_debug(r, "could not match require claim expression '%s'", require_args);
454454
oidc_authz_error_add(r, require_args);

src/http.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,13 @@ static apr_byte_t oidc_http_request(request_rec *r, const char *url, const char
914914
* retry */
915915
oidc_error(r, "curl_easy_perform failed with a timeout for %s: [%s]; won't retry", url,
916916
curl_err[0] ? curl_err : "<n/a>");
917-
OIDC_METRICS_COUNTER_INC_SPEC(r, c, OM_PROVIDER_CONNECT_ERROR,
918-
curl_err[0] ? curl_err : "timeout")
917+
OIDC_METRICS_COUNTER_INC_VALUE(r, c, OM_PROVIDER_CONNECT_ERROR,
918+
curl_err[0] ? curl_err : "timeout")
919919
break;
920920
}
921921
oidc_error(r, "curl_easy_perform(%d/%d) failed for %s with: [%s]", i + 1, http_timeout->retries + 1,
922922
url, curl_err[0] ? curl_err : "<n/a>");
923-
OIDC_METRICS_COUNTER_INC_SPEC(r, c, OM_PROVIDER_CONNECT_ERROR, curl_err[0] ? curl_err : "undefined")
923+
OIDC_METRICS_COUNTER_INC_VALUE(r, c, OM_PROVIDER_CONNECT_ERROR, curl_err[0] ? curl_err : "undefined")
924924
/* in case of a connectivity/network glitch we'll back off before retrying */
925925
if (i < http_timeout->retries)
926926
apr_sleep(apr_time_from_msec(http_timeout->retry_interval));
@@ -931,7 +931,7 @@ static apr_byte_t oidc_http_request(request_rec *r, const char *url, const char
931931
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
932932
oidc_debug(r, "HTTP response code=%ld", http_code);
933933

934-
OIDC_METRICS_COUNTER_INC_SPEC(r, c, OM_PROVIDER_HTTP_RESPONSE_CODE, apr_psprintf(r->pool, "%ld", http_code));
934+
OIDC_METRICS_COUNTER_INC_VALUE(r, c, OM_PROVIDER_HTTP_RESPONSE_CODE, apr_psprintf(r->pool, "%ld", http_code));
935935

936936
*response = apr_pstrmemdup(r->pool, d_buf.memory, d_buf.size);
937937
if (response_code)

0 commit comments

Comments
 (0)