From 3dbe2d3eeeec9c1d3cf82f41378b306499b9d41b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Mon, 29 May 2017 16:11:49 +0200 Subject: [PATCH] Relax authorisation checlk for self MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I115bbebb2f51be92578d1cc6b2fb5ae89813b630 Signed-off-by: José Bollo --- src/afb-auth.c | 5 ++++- src/afb-hreq.c | 1 - src/afb-svc.c | 1 - src/afb-ws-json1.c | 2 -- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/afb-auth.c b/src/afb-auth.c index 82e6fd21..900ec4c6 100644 --- a/src/afb-auth.c +++ b/src/afb-auth.c @@ -45,7 +45,10 @@ int afb_auth_check(const struct afb_auth *auth, struct afb_xreq *xreq) return afb_context_check_loa(&xreq->context, auth->loa); case afb_auth_Permission: - return xreq->cred && auth->text && check_permission(auth->text, xreq); + if (xreq->cred && auth->text) + return check_permission(auth->text, xreq); + /* TODO: handle case of self permission */ + return 1; case afb_auth_Or: return afb_auth_check(auth->first, xreq) || afb_auth_check(auth->next, xreq); diff --git a/src/afb-hreq.c b/src/afb-hreq.c index 62b322c3..b87251be 100644 --- a/src/afb-hreq.c +++ b/src/afb-hreq.c @@ -982,7 +982,6 @@ struct afb_hreq *afb_hreq_create() if (hreq) { /* init the request */ afb_xreq_init(&hreq->xreq, &afb_hreq_xreq_query_itf); - hreq->xreq.cred = afb_cred_current(); hreq->reqid = ++global_reqids; } return hreq; diff --git a/src/afb-svc.c b/src/afb-svc.c index ac012914..b4032e32 100644 --- a/src/afb-svc.c +++ b/src/afb-svc.c @@ -275,7 +275,6 @@ static struct svc_req *svcreq_create(struct afb_svc *svc, const char *api, const afb_xreq_init(&svcreq->xreq, &afb_svc_xreq_itf); afb_context_init(&svcreq->xreq.context, svc->session, NULL); svcreq->xreq.context.validated = 1; - svcreq->xreq.cred = afb_cred_current(); copy = (char*)&svcreq[1]; memcpy(copy, api, lenapi); svcreq->xreq.api = copy; diff --git a/src/afb-ws-json1.c b/src/afb-ws-json1.c index 3d1f29dc..4b6c04eb 100644 --- a/src/afb-ws-json1.c +++ b/src/afb-ws-json1.c @@ -129,8 +129,6 @@ struct afb_ws_json1 *afb_ws_json1_create(int fd, struct afb_apiset *apiset, stru goto error4; result->cred = afb_cred_create_for_socket(fd); - if (!result->cred) - result->cred = afb_cred_current(); result->apiset = afb_apiset_addref(apiset); return result; -- 2.16.6