afb-auth: export method to check a single permission
authorJosé Bollo <jose.bollo@iot.bzh>
Mon, 4 Sep 2017 08:30:26 +0000 (10:30 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Thu, 7 Sep 2017 07:43:13 +0000 (09:43 +0200)
Change-Id: I45c4872f34ff8f25c14872d7b3610fa15f48062e
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-auth.c
src/afb-auth.h

index 5c62f9f..17d355b 100644 (file)
@@ -29,8 +29,6 @@
 #include "afb-cred.h"
 #include "verbose.h"
 
-static int check_permission(struct afb_xreq *xreq, const char *permission);
-
 int afb_auth_check(struct afb_xreq *xreq, const struct afb_auth *auth)
 {
        switch (auth->type) {
@@ -46,7 +44,7 @@ int afb_auth_check(struct afb_xreq *xreq, const struct afb_auth *auth)
 
        case afb_auth_Permission:
                if (xreq->cred && auth->text)
-                       return check_permission(xreq, auth->text);
+                       return afb_auth_check_permission(xreq, auth->text);
                /* TODO: handle case of self permission */
                return 1;
 
@@ -73,7 +71,7 @@ int afb_auth_check(struct afb_xreq *xreq, const struct afb_auth *auth)
 static cynara *handle;
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
-static int check_permission(struct afb_xreq *xreq, const char *permission)
+int afb_auth_check_permission(struct afb_xreq *xreq, const char *permission)
 {
        int rc;
 
@@ -99,7 +97,7 @@ static int check_permission(struct afb_xreq *xreq, const char *permission)
 
 /*********************************************************************************/
 #else
-static int check_permission(struct afb_xreq *xreq, const char *permission)
+int afb_auth_check_permission(struct afb_xreq *xreq, const char *permission)
 {
        WARNING("Granting permission %s by default of backend", permission);
        return 1;
index 786f397..d388e77 100644 (file)
@@ -21,3 +21,5 @@ struct afb_auth;
 struct afb_xreq;
 
 extern int afb_auth_check(struct afb_xreq *xreq, const struct afb_auth *auth);
+extern int afb_auth_check_permission(struct afb_xreq *xreq, const char *permission);
+