/*
- * Copyright (C) 2016, 2017, 2018 "IoT.bzh"
+ * Copyright (C) 2015-2020 "IoT.bzh"
* Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* limitations under the License.
*/
+#if WITH_LEGACY_BINDING_V1 && WITH_DYNAMIC_BINDING
+
#define _GNU_SOURCE
#include <stdio.h>
#include "afb-context.h"
#include "afb-api-so.h"
#include "afb-xreq.h"
+#include "afb-auth.h"
#include "verbose.h"
/*
afb_xreq_call_verb_v1(xreq, verb);
}
-static struct json_object *addperm(struct json_object *o, struct json_object *x)
-{
- struct json_object *a;
-
- if (!o)
- return x;
-
- if (!json_object_object_get_ex(o, "allOf", &a)) {
- a = json_object_new_array();
- json_object_array_add(a, o);
- o = json_object_new_object();
- json_object_object_add(o, "allOf", a);
- }
- json_object_array_add(a, x);
- return o;
-}
-
-static struct json_object *addperm_key_val(struct json_object *o, const char *key, struct json_object *val)
-{
- struct json_object *x = json_object_new_object();
- json_object_object_add(x, key, val);
- return addperm(o, x);
-}
-
-static struct json_object *addperm_key_valstr(struct json_object *o, const char *key, const char *val)
-{
- return addperm_key_val(o, key, json_object_new_string(val));
-}
-
-static struct json_object *addperm_key_valint(struct json_object *o, const char *key, int val)
-{
- return addperm_key_val(o, key, json_object_new_int(val));
-}
-
struct json_object *afb_api_so_v1_make_description_openAPIv3(struct afb_binding_v1 *binding, const char *apiname)
{
char buffer[256];
g = json_object_new_object();
json_object_object_add(f, "get", g);
- a = NULL;
- if (verb->session & AFB_SESSION_CLOSE_X1)
- a = addperm_key_valstr(a, "session", "close");
- if (verb->session & AFB_SESSION_CHECK_X1)
- a = addperm_key_valstr(a, "session", "check");
- if (verb->session & AFB_SESSION_RENEW_X1)
- a = addperm_key_valstr(a, "token", "refresh");
- if (verb->session & AFB_SESSION_LOA_MASK_X1)
- a = addperm_key_valint(a, "LOA", (verb->session >> AFB_SESSION_LOA_SHIFT_X1) & AFB_SESSION_LOA_MASK_X1);
+ a = afb_auth_json_x1(verb->session);
if (a)
json_object_object_add(g, "x-permissions", a);
/* allocates the description */
init = dlsym(handle, afb_api_so_v1_service_init);
onevent = dlsym(handle, afb_api_so_v1_service_event);
- export = afb_export_create_v1(declare_set, call_set, path, init, onevent);
+ export = afb_export_create_v1(declare_set, call_set, path, init, onevent, path);
if (export == NULL) {
ERROR("binding [%s] creation failure...", path);
goto error;
return -1;
}
+#endif
+