slurmrestd - Add http_context_set_auth()
Issue: 50189
diff --git a/src/slurmrestd/http.c b/src/slurmrestd/http.c
index 4ddab79..0a43966 100644
--- a/src/slurmrestd/http.c
+++ b/src/slurmrestd/http.c
@@ -850,3 +850,18 @@
return context->auth;
}
+
+extern void *http_context_set_auth(http_context_t *context, void *auth)
+{
+ void *old = NULL;
+
+ if (!context)
+ return auth;
+
+ xassert(context->magic == MAGIC);
+
+ old = context->auth;
+ context->auth = auth;
+
+ return old;
+}
diff --git a/src/slurmrestd/http.h b/src/slurmrestd/http.h
index aaa9c86..daf9b06 100644
--- a/src/slurmrestd/http.h
+++ b/src/slurmrestd/http.h
@@ -168,4 +168,12 @@
*/
extern void *http_context_get_auth(http_context_t *context);
+/*
+ * Set and Get (arbitrary) auth pointer from context
+ * IN context - connection context
+ * IN auth - (arbitrary) auth pointer to set into context
+ * RET Prior auth pointer or auth arg if context==NULL
+ */
+extern void *http_context_set_auth(http_context_t *context, void *auth);
+
#endif /* SLURMRESTD_HTTP_H */