Skip to content

Commit b476a1d

Browse files
committed
code: refactor util.c into util/ directory
Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 04bec87 commit b476a1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1511
-1184
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
05/17/2025
2+
- code: refactor util.c into util/ directory
3+
14
05/06/2025
25
- allow adding a prefix to the cache (section) key through environment variable OIDC_CACHE_PREFIX
36
- bump to 2.4.17.1dev

Makefile.am

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,21 @@ libauth_openidc_la_SOURCES = \
4343
src/proto/state.c \
4444
src/proto/token.c \
4545
src/proto/userinfo.c \
46+
src/util/base64.c \
47+
src/util/expr.c \
48+
src/util/html.c \
49+
src/util/jq.c \
50+
src/util/json.c \
51+
src/util/jwt.c \
52+
src/util/pcre_subst.c \
53+
src/util/random.c \
54+
src/util/util.c \
4655
src/metrics.c \
4756
src/oauth.c \
48-
src/util.c \
4957
src/http.c \
5058
src/session.c \
5159
src/metadata.c \
52-
src/jose.c \
53-
src/pcre_subst.c
60+
src/jose.c
5461

5562
AM_CFLAGS = -DNAMEVER="@NAMEVER@" -I${top_srcdir}/src @APACHE_CFLAGS@ @OPENSSL_CFLAGS@ @CURL_CFLAGS@ @JANSSON_CFLAGS@ @CJOSE_CFLAGS@ @PCRE_CFLAGS@
5663
AM_CPPFLAGS = @APACHE_CPPFLAGS@
@@ -98,15 +105,15 @@ noinst_HEADERS = \
98105
src/handle/handle.h \
99106
src/proto/proto.h \
100107
src/cache/cache.h \
108+
src/util/util.h \
109+
src/util/pcre_subst.h \
101110
src/oauth.h \
102111
src/metadata.h \
103112
src/session.h \
104113
src/jose.h \
105114
src/http.h \
106-
src/util.h \
107115
src/metrics.h \
108-
src/const.h \
109-
src/pcre_subst.h
116+
src/const.h
110117

111118
if HAVE_LIBHIREDIS
112119
noinst_HEADERS += \

src/cache/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#include "cfg/cfg_int.h"
5353
#include "jose.h"
5454
#include "metrics.h"
55-
#include "util.h"
55+
#include "util/util.h"
5656

5757
#ifdef AP_NEED_SET_MUTEX_PERMS
5858
#include "unixd.h"

src/cache/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
#include "cfg/cache.h"
4747
#include "cfg/cfg_int.h"
48-
#include "util.h"
48+
#include "util/util.h"
4949

5050
/*
5151
* header structure that holds the metadata info for a cache file entry
@@ -367,7 +367,7 @@ static apr_byte_t oidc_cache_file_set(request_rec *r, const char *section, const
367367
char s_err[128];
368368
char *rnd = NULL;
369369

370-
oidc_util_generate_random_string(r, &rnd, 12);
370+
oidc_util_random_str_gen(r, &rnd, 12);
371371

372372
/* get the fully qualified path to the cache file based on the key name */
373373
const char *target = oidc_cache_file_path(r, section, key);

src/cfg/cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#include "metrics.h"
5151
#include "proto/proto.h"
5252
#include "session.h"
53-
#include "util.h"
53+
#include "util/util.h"
5454

5555
const char *oidc_cfg_string_list_add(apr_pool_t *pool, apr_array_header_t **list, const char *arg) {
5656
if (*list == NULL)

src/cfg/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "cfg/dir.h"
4444
#include "cfg/cfg_int.h"
4545
#include "cfg/parse.h"
46-
#include "util.h"
46+
#include "util/util.h"
4747

4848
/*
4949
* directory related configuration

src/cfg/parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include "cfg/dir.h"
4545
#include "const.h"
4646
#include "proto/proto.h"
47-
#include "util.h"
47+
#include "util/util.h"
4848
#include <apr_base64.h>
4949
#include <apr_file_io.h>
5050
#include <apr_strings.h>

src/handle/authz.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
#include "http_protocol.h"
4646
#include "metrics.h"
4747
#include "mod_auth_openidc.h"
48-
#include "pcre_subst.h"
48+
#include "util/pcre_subst.h"
4949
#include "proto/proto.h"
50-
#include "util.h"
50+
#include "util/util.h"
5151

5252
static apr_byte_t oidc_authz_match_json_string(request_rec *r, const char *spec, json_t *val, const char *key) {
5353
return (_oidc_strcmp(json_string_value(val), spec) == 0);
@@ -360,7 +360,7 @@ static apr_byte_t oidc_authz_match_claims_expr(request_rec *r, const char *const
360360

361361
oidc_debug(r, "enter: '%s'", attr_spec);
362362

363-
str = oidc_util_jq_filter(r, oidc_util_encode_json(r->pool, claims, JSON_PRESERVE_ORDER | JSON_COMPACT),
363+
str = oidc_util_jq_filter(r, oidc_util_json_encode(r->pool, claims, JSON_PRESERVE_ORDER | JSON_COMPACT),
364364
attr_spec);
365365
rv = (_oidc_strcmp(str, "true") == 0);
366366

@@ -389,11 +389,11 @@ static void oidc_authz_get_claims_idtoken_scope(request_rec *r, json_t **claims,
389389

390390
const char *s_claims = oidc_request_state_get(r, OIDC_REQUEST_STATE_KEY_CLAIMS);
391391
if (s_claims != NULL)
392-
oidc_util_decode_json_object(r, s_claims, claims);
392+
oidc_util_json_decode_object(r, s_claims, claims);
393393

394394
const char *s_id_token = oidc_request_state_get(r, OIDC_REQUEST_STATE_KEY_IDTOKEN);
395395
if (s_id_token != NULL)
396-
oidc_util_decode_json_object(r, s_id_token, id_token);
396+
oidc_util_json_decode_object(r, s_id_token, id_token);
397397

398398
*scope = oidc_request_state_get(r, OIDC_REQUEST_STATE_KEY_SCOPE);
399399
}

src/handle/content.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "handle/handle.h"
4444
#include "metrics.h"
4545
#include "mod_auth_openidc.h"
46-
#include "util.h"
46+
#include "util/util.h"
4747

4848
/*
4949
* handle content generating requests

src/handle/discovery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "metadata.h"
4646
#include "mod_auth_openidc.h"
4747
#include "proto/proto.h"
48-
#include "util.h"
48+
#include "util/util.h"
4949

5050
/* parameter name of the callback URL in the discovery response */
5151
#define OIDC_DISC_CB_PARAM "oidc_callback"

0 commit comments

Comments
 (0)