Skip to content

Commit

Permalink
refactoring, part 2: rename userinfo
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Zandbelt <[email protected]>
  • Loading branch information
zandbelt committed Feb 27, 2024
1 parent 3896aa3 commit 9b2bc67
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
11 changes: 5 additions & 6 deletions src/handle/handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ int oidc_revoke_at_cache_remove(request_rec *r, oidc_cfg *c);
int oidc_session_management(request_rec *r, oidc_cfg *c, oidc_session_t *session);

// userinfo.c
void oidc_store_userinfo_claims(request_rec *r, oidc_cfg *c, oidc_session_t *session, oidc_provider_t *provider,
void oidc_userinfo_store_claims(request_rec *r, oidc_cfg *c, oidc_session_t *session, oidc_provider_t *provider,
const char *claims, const char *userinfo_jwt);
const char *oidc_retrieve_claims_from_userinfo_endpoint(request_rec *r, oidc_cfg *c, oidc_provider_t *provider,
const char *access_token, oidc_session_t *session,
char *id_token_sub, char **userinfo_jwt);
apr_byte_t oidc_refresh_claims_from_userinfo_endpoint(request_rec *r, oidc_cfg *cfg, oidc_session_t *session,
apr_byte_t *needs_save);
const char *oidc_userinfo_retrieve_claims(request_rec *r, oidc_cfg *c, oidc_provider_t *provider,
const char *access_token, oidc_session_t *session, char *id_token_sub,
char **userinfo_jwt);
apr_byte_t oidc_userinfo_refresh_claims(request_rec *r, oidc_cfg *cfg, oidc_session_t *session, apr_byte_t *needs_save);
2 changes: 1 addition & 1 deletion src/handle/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int oidc_info_request(request_rec *r, oidc_cfg *c, oidc_session_t *session, apr_
* note that OIDCUserInfoRefreshInterval should be set to control the refresh policy
*/
if (b_extend_session) {
if (oidc_refresh_claims_from_userinfo_endpoint(r, c, session, &needs_save) == FALSE) {
if (oidc_userinfo_refresh_claims(r, c, session, &needs_save) == FALSE) {
rc = HTTP_INTERNAL_SERVER_ERROR;
goto end;
}
Expand Down
4 changes: 2 additions & 2 deletions src/handle/response.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ static apr_byte_t oidc_response_save_in_session(request_rec *r, oidc_cfg *c, oid
oidc_session_set_userinfo_refresh_interval(r, session, provider->userinfo_refresh_interval);

/* store claims resolved from userinfo endpoint */
oidc_store_userinfo_claims(r, c, session, provider, claims, userinfo_jwt);
oidc_userinfo_store_claims(r, c, session, provider, claims, userinfo_jwt);

/* see if we have an access_token */
if (access_token != NULL) {
Expand Down Expand Up @@ -616,7 +616,7 @@ static int oidc_response_process(request_rec *r, oidc_cfg *c, oidc_session_t *se
* optionally resolve additional claims against the userinfo endpoint
* parsed claims are not actually used here but need to be parsed anyway for error checking purposes
*/
const char *claims = oidc_retrieve_claims_from_userinfo_endpoint(
const char *claims = oidc_userinfo_retrieve_claims(
r, c, provider, apr_table_get(params, OIDC_PROTO_ACCESS_TOKEN), NULL, jwt->payload.sub, &userinfo_jwt);

/* restore the original protected URL that the user was trying to access */
Expand Down
18 changes: 9 additions & 9 deletions src/handle/userinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/*
* store claims resolved from the userinfo endpoint in the session
*/
void oidc_store_userinfo_claims(request_rec *r, oidc_cfg *c, oidc_session_t *session, oidc_provider_t *provider,
void oidc_userinfo_store_claims(request_rec *r, oidc_cfg *c, oidc_session_t *session, oidc_provider_t *provider,
const char *claims, const char *userinfo_jwt) {

oidc_debug(r, "enter");
Expand Down Expand Up @@ -81,9 +81,9 @@ void oidc_store_userinfo_claims(request_rec *r, oidc_cfg *c, oidc_session_t *ses
/*
* retrieve claims from the userinfo endpoint and return the stringified response
*/
const char *oidc_retrieve_claims_from_userinfo_endpoint(request_rec *r, oidc_cfg *c, oidc_provider_t *provider,
const char *access_token, oidc_session_t *session,
char *id_token_sub, char **userinfo_jwt) {
const char *oidc_userinfo_retrieve_claims(request_rec *r, oidc_cfg *c, oidc_provider_t *provider,
const char *access_token, oidc_session_t *session, char *id_token_sub,
char **userinfo_jwt) {

char *result = NULL;
char *refreshed_access_token = NULL;
Expand Down Expand Up @@ -161,8 +161,8 @@ const char *oidc_retrieve_claims_from_userinfo_endpoint(request_rec *r, oidc_cfg
/*
* get (new) claims from the userinfo endpoint
*/
apr_byte_t oidc_refresh_claims_from_userinfo_endpoint(request_rec *r, oidc_cfg *cfg, oidc_session_t *session,
apr_byte_t *needs_save) {
apr_byte_t oidc_userinfo_refresh_claims(request_rec *r, oidc_cfg *cfg, oidc_session_t *session,
apr_byte_t *needs_save) {

apr_byte_t rc = TRUE;
oidc_provider_t *provider = NULL;
Expand Down Expand Up @@ -198,11 +198,11 @@ apr_byte_t oidc_refresh_claims_from_userinfo_endpoint(request_rec *r, oidc_cfg *
access_token = oidc_session_get_access_token(r, session);

/* retrieve the current claims */
claims = oidc_retrieve_claims_from_userinfo_endpoint(r, cfg, provider, access_token,
session, NULL, &userinfo_jwt);
claims = oidc_userinfo_retrieve_claims(r, cfg, provider, access_token, session, NULL,
&userinfo_jwt);

/* store claims resolved from userinfo endpoint */
oidc_store_userinfo_claims(r, cfg, session, provider, claims, userinfo_jwt);
oidc_userinfo_store_claims(r, cfg, session, provider, claims, userinfo_jwt);

if (claims == NULL) {
*needs_save = FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/mod_auth_openidc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ static int oidc_handle_existing_session(request_rec *r, oidc_cfg *cfg, oidc_sess
}

/* if needed, refresh claims from the user info endpoint */
rv = oidc_refresh_claims_from_userinfo_endpoint(r, cfg, session, needs_save);
rv = oidc_userinfo_refresh_claims(r, cfg, session, needs_save);
if (rv == FALSE) {
*needs_save = FALSE;
oidc_debug(r, "action_on_userinfo_error: %d", cfg->action_on_userinfo_error);
Expand Down

0 comments on commit 9b2bc67

Please sign in to comment.