slurmrestd - Convert rest_authenticate_http_request()
Convert rest_authenticate_http_request to use http_context_set_auth()
instead of accessing args->context->auth directly.
Issue: 50189
diff --git a/src/slurmrestd/rest_auth.c b/src/slurmrestd/rest_auth.c
index 3148edf..3b1c379 100644
--- a/src/slurmrestd/rest_auth.c
+++ b/src/slurmrestd/rest_auth.c
@@ -164,18 +164,13 @@
extern int rest_authenticate_http_request(on_http_request_args_t *args)
{
int rc = ESLURM_AUTH_CRED_INVALID;
- rest_auth_context_t *context =
- (rest_auth_context_t *) args->context->auth;
-
- if (context) {
- fatal("%s: authentication context already set for connection: %s",
- __func__, conmgr_fd_get_name(args->context->con));
- }
-
- args->context->auth = context = rest_auth_g_new();
+ rest_auth_context_t *context = rest_auth_g_new();
_check_magic(context);
+ if (http_context_set_auth(args->context, context))
+ fatal_abort("authentication context already set for connection");
+
/* continue if already authenticated via plugin */
if (context->plugin_id)
return rest_auth_g_apply(context);
@@ -194,7 +189,10 @@
break;
}
- FREE_NULL_REST_AUTH(args->context->auth);
+ if (http_context_set_auth(args->context, NULL) != context)
+ fatal_abort("authentication context unexpectedly changed");
+
+ FREE_NULL_REST_AUTH(context);
return rc;
}