diff options
author | José Bollo <jose.bollo@iot.bzh> | 2017-09-19 12:16:42 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2017-10-09 14:08:29 +0200 |
commit | 15d0dae1cd6ab982137a7c2848de9303a9c969f0 (patch) | |
tree | ba156b222ae058c8f0120def427f0abf3564190c /src/afb-xreq.c | |
parent | 33e615ea0cc26131532f4615ef4a2034488fa48e (diff) |
Add function 'afb_req_get_application_id'
This function is intended to return an identifier of the
calling application. At this time, the identifier is
just derived from the application id but it can be
changed in the future.
Change-Id: Idacde8979ac5bb525352de9cab19e3fc1ed48627
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-xreq.c')
-rw-r--r-- | src/afb-xreq.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/afb-xreq.c b/src/afb-xreq.c index 8a133519..de0710de 100644 --- a/src/afb-xreq.c +++ b/src/afb-xreq.c @@ -520,6 +520,12 @@ static int xreq_has_permission_cb(void*closure, const char *permission) return afb_auth_has_permission(xreq, permission); } +static char *xreq_get_application_id_cb(void*closure) +{ + struct afb_xreq *xreq = closure; + return xreq->cred && xreq->cred->id ? strdup(xreq->cred->id) : NULL; +} + /******************************************************************************/ static struct json_object *xreq_hooked_json_cb(void *closure) @@ -682,6 +688,13 @@ static int xreq_hooked_has_permission_cb(void*closure, const char *permission) return afb_hook_xreq_has_permission(xreq, permission, r); } +static char *xreq_hooked_get_application_id_cb(void*closure) +{ + struct afb_xreq *xreq = closure; + char *r = xreq_get_application_id_cb(closure); + return afb_hook_xreq_get_application_id(xreq, r); +} + /******************************************************************************/ const struct afb_req_itf xreq_itf = { @@ -704,7 +717,8 @@ const struct afb_req_itf xreq_itf = { .vverbose = xreq_vverbose_cb, .store = xreq_store_cb, .subcall_req = xreq_subcall_req_cb, - .has_permission = xreq_has_permission_cb + .has_permission = xreq_has_permission_cb, + .get_application_id = xreq_get_application_id_cb }; const struct afb_req_itf xreq_hooked_itf = { @@ -727,7 +741,8 @@ const struct afb_req_itf xreq_hooked_itf = { .vverbose = xreq_hooked_vverbose_cb, .store = xreq_hooked_store_cb, .subcall_req = xreq_hooked_subcall_req_cb, - .has_permission = xreq_hooked_has_permission_cb + .has_permission = xreq_hooked_has_permission_cb, + .get_application_id = xreq_hooked_get_application_id_cb }; /******************************************************************************/ |