summaryrefslogtreecommitdiffstats
path: root/src/responder/secrets/secsrv_private.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/responder/secrets/secsrv_private.h')
-rw-r--r--src/responder/secrets/secsrv_private.h121
1 files changed, 121 insertions, 0 deletions
diff --git a/src/responder/secrets/secsrv_private.h b/src/responder/secrets/secsrv_private.h
new file mode 100644
index 000000000..4b55f645a
--- /dev/null
+++ b/src/responder/secrets/secsrv_private.h
@@ -0,0 +1,121 @@
+/*
+ SSSD
+
+ Secrets Responder, private header file
+
+ Copyright (C) Simo Sorce <ssorce@redhat.com> 2016
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __SECSRV_PRIVATE_H__
+#define __SECSRV_PRIVATE_H__
+
+#include "config.h"
+#include "responder/common/responder.h"
+#include <http_parser.h>
+
+struct sec_kvp {
+ char *name;
+ char *value;
+};
+
+struct sec_data {
+ char *data;
+ size_t length;
+};
+
+enum sec_http_status_codes {
+ STATUS_200 = 0,
+ STATUS_400,
+ STATUS_401,
+ STATUS_403,
+ STATUS_404,
+ STATUS_405,
+ STATUS_406,
+ STATUS_409,
+ STATUS_500,
+};
+
+struct sec_proto_ctx {
+ http_parser_settings callbacks;
+ http_parser parser;
+};
+
+struct sec_url {
+ char *schema;
+ char *host;
+ int port;
+ char *path;
+ char *fragment;
+ char *userinfo;
+ char *query;
+};
+
+struct sec_req_ctx {
+ struct cli_ctx *cctx;
+ const char *cfg_section;
+ bool complete;
+
+ size_t total_size;
+
+ char *request_url;
+ char *mapped_path;
+
+ uint8_t method;
+ struct sec_url parsed_url;
+ struct sec_kvp *headers;
+ int num_headers;
+ struct sec_data body;
+
+ struct sec_data reply;
+};
+
+typedef struct tevent_req *(*sec_provider_req_t)(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ void *provider_ctx,
+ struct sec_req_ctx *secreq);
+
+struct provider_handle {
+ sec_provider_req_t fn;
+ void *context;
+};
+
+#define SEC_BASEPATH "/secrets/"
+
+/* providers.c */
+int sec_req_routing(TALLOC_CTX *mem_ctx, struct sec_req_ctx *secreq,
+ struct provider_handle **handle);
+int sec_provider_recv(struct tevent_req *subreq);
+
+int sec_http_status_reply(TALLOC_CTX *mem_ctx, struct sec_data *reply,
+ enum sec_http_status_codes code);
+int sec_http_reply_with_body(TALLOC_CTX *mem_ctx, struct sec_data *reply,
+ enum sec_http_status_codes code,
+ const char *content_type,
+ struct sec_data *body);
+enum sec_http_status_codes sec_errno_to_http_status(errno_t err);
+
+int sec_json_to_simple_secret(TALLOC_CTX *mem_ctx,
+ const char *input,
+ char **secret);
+int sec_simple_secret_to_json(TALLOC_CTX *mem_ctx,
+ const char *secret,
+ char **output);
+
+int sec_array_to_json(TALLOC_CTX *mem_ctx,
+ char **array, int count,
+ char **output);
+
+#endif /* __SECSRV_PRIVATE_H__ */