typedef enum {AFB_PLUGIN_JSON=123456789, AFB_PLUGIN_JSCRIPT=987654321, AFB_PLUGIN_RAW=987123546} AFB_pluginT;
// prebuild json error are constructed in config.c
-typedef enum { AFB_FALSE, AFB_TRUE, AFB_FATAL, AFB_FAIL, AFB_WARNING, AFB_EMPTY, AFB_SUCCESS, AFB_DONE} AFB_error;
+typedef enum { AFB_FALSE, AFB_TRUE, AFB_FATAL, AFB_FAIL, AFB_WARNING, AFB_EMPTY, AFB_SUCCESS, AFB_DONE, AFB_UNAUTH} AFB_error;
extern char *ERROR_LABEL[];
#define ERROR_LABEL_DEF {"false", "true","fatal", "fail", "warning", "empty", "success"}
</toolsSet>
<flagsDictionary>
<element flagsID="0" commonFlags="-fPIE"/>
- <element flagsID="1" commonFlags="-mtune=generic -march=x86-64 -fPIE"/>
</flagsDictionary>
<codeAssistance>
</codeAssistance>
<buildCommand>${MAKE} -f Makefile</buildCommand>
<cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
<executablePath>build/src/afb-daemon</executablePath>
+ <cTool>
+ <incDir>
+ <pElem>include</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>build/src</pElem>
+ </incDir>
+ </cTool>
</makeTool>
<preBuild>
<preBuildCommandWorkingDir>build</preBuildCommandWorkingDir>
</makefileType>
<item path="src/afbs-api.c" ex="false" tool="0" flavor2="2">
<cTool flags="0">
- <incDir>
- <pElem>include</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>build/src</pElem>
- </incDir>
</cTool>
</item>
<item path="src/alsa-api.c" ex="false" tool="0" flavor2="2">
- <cTool flags="1">
- <incDir>
- <pElem>src</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>include</pElem>
- <pElem>/usr/include/uuid</pElem>
- <pElem>build/src</pElem>
- </incDir>
- <preprocessorList>
- <Elem>__PIC__=2</Elem>
- <Elem>__PIE__=2</Elem>
- <Elem>__REGISTER_PREFIX__=</Elem>
- <Elem>__USER_LABEL_PREFIX__=</Elem>
- <Elem>__pic__=2</Elem>
- <Elem>__pie__=2</Elem>
- </preprocessorList>
+ <cTool flags="0">
</cTool>
</item>
<item path="src/config.c" ex="false" tool="0" flavor2="2">
- <cTool flags="1">
- <incDir>
- <pElem>src</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>include</pElem>
- <pElem>/usr/include/uuid</pElem>
- <pElem>build/src</pElem>
- </incDir>
- <preprocessorList>
- <Elem>__PIC__=2</Elem>
- <Elem>__PIE__=2</Elem>
- <Elem>__REGISTER_PREFIX__=</Elem>
- <Elem>__USER_LABEL_PREFIX__=</Elem>
- <Elem>__pic__=2</Elem>
- <Elem>__pie__=2</Elem>
- </preprocessorList>
+ <cTool flags="0">
</cTool>
</item>
<item path="src/dbus-api.c" ex="false" tool="0" flavor2="2">
- <cTool flags="1">
- <incDir>
- <pElem>src</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>include</pElem>
- <pElem>/usr/include/uuid</pElem>
- <pElem>build/src</pElem>
- </incDir>
- <preprocessorList>
- <Elem>__PIC__=2</Elem>
- <Elem>__PIE__=2</Elem>
- <Elem>__REGISTER_PREFIX__=</Elem>
- <Elem>__USER_LABEL_PREFIX__=</Elem>
- <Elem>__pic__=2</Elem>
- <Elem>__pie__=2</Elem>
- </preprocessorList>
+ <cTool flags="0">
</cTool>
</item>
<item path="src/http-svc.c" ex="false" tool="0" flavor2="2">
- <cTool flags="1">
- <incDir>
- <pElem>src</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>include</pElem>
- <pElem>/usr/include/uuid</pElem>
- <pElem>build/src</pElem>
- </incDir>
- <preprocessorList>
- <Elem>__PIC__=2</Elem>
- <Elem>__PIE__=2</Elem>
- <Elem>__REGISTER_PREFIX__=</Elem>
- <Elem>__USER_LABEL_PREFIX__=</Elem>
- <Elem>__pic__=2</Elem>
- <Elem>__pie__=2</Elem>
- </preprocessorList>
+ <cTool flags="0">
</cTool>
</item>
<item path="src/main.c" ex="false" tool="0" flavor2="2">
- <cTool flags="1">
- <incDir>
- <pElem>src</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>include</pElem>
- <pElem>/usr/include/uuid</pElem>
- <pElem>build/src</pElem>
- </incDir>
- <preprocessorList>
- <Elem>__PIC__=2</Elem>
- <Elem>__PIE__=2</Elem>
- <Elem>__REGISTER_PREFIX__=</Elem>
- <Elem>__USER_LABEL_PREFIX__=</Elem>
- <Elem>__pic__=2</Elem>
- <Elem>__pie__=2</Elem>
- </preprocessorList>
+ <cTool flags="0">
</cTool>
</item>
<item path="src/rest-api.c" ex="false" tool="0" flavor2="2">
- <cTool flags="1">
- <incDir>
- <pElem>src</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>include</pElem>
- <pElem>/usr/include/uuid</pElem>
- <pElem>build/src</pElem>
- </incDir>
- <preprocessorList>
- <Elem>__PIC__=2</Elem>
- <Elem>__PIE__=2</Elem>
- <Elem>__REGISTER_PREFIX__=</Elem>
- <Elem>__USER_LABEL_PREFIX__=</Elem>
- <Elem>__pic__=2</Elem>
- <Elem>__pie__=2</Elem>
- </preprocessorList>
+ <cTool flags="0">
</cTool>
</item>
<item path="src/session.c" ex="false" tool="0" flavor2="2">
- <cTool flags="1">
- <incDir>
- <pElem>src</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>/usr/include/uuid</pElem>
- <pElem>include</pElem>
- <pElem>build/src</pElem>
- </incDir>
- <preprocessorList>
- <Elem>__PIC__=2</Elem>
- <Elem>__PIE__=2</Elem>
- <Elem>__REGISTER_PREFIX__=</Elem>
- <Elem>__USER_LABEL_PREFIX__=</Elem>
- <Elem>__pic__=2</Elem>
- <Elem>__pie__=2</Elem>
- </preprocessorList>
+ <cTool flags="0">
</cTool>
</item>
</conf>
+/home/fulup/Workspace/afb-daemon/src/session.c=/home/fulup/Workspace/afb-daemon/build/src#-g3 -gdwarf-2 -fPIE -I/home/fulup/Workspace/afb-daemon/include -I/usr/include/json-c -o CMakeFiles/afb-daemon.dir/session.c.o -c /home/fulup/Workspace/afb-daemon/src/session.c
+/home/fulup/Workspace/afb-daemon/src/alsa-api.c=/home/fulup/Workspace/afb-daemon/build/src#-g3 -gdwarf-2 -fPIE -I/home/fulup/Workspace/afb-daemon/include -I/usr/include/json-c -o CMakeFiles/afb-daemon.dir/alsa-api.c.o -c /home/fulup/Workspace/afb-daemon/src/alsa-api.c
+/home/fulup/Workspace/afb-daemon/src/main.c=/home/fulup/Workspace/afb-daemon/build/src#-g3 -gdwarf-2 -fPIE -I/home/fulup/Workspace/afb-daemon/include -I/usr/include/json-c -o CMakeFiles/afb-daemon.dir/main.c.o -c /home/fulup/Workspace/afb-daemon/src/main.c
+/home/fulup/Workspace/afb-daemon/src/dbus-api.c=/home/fulup/Workspace/afb-daemon/build/src#-g3 -gdwarf-2 -fPIE -I/home/fulup/Workspace/afb-daemon/include -I/usr/include/json-c -o CMakeFiles/afb-daemon.dir/dbus-api.c.o -c /home/fulup/Workspace/afb-daemon/src/dbus-api.c
+/home/fulup/Workspace/afb-daemon/src/http-svc.c=/home/fulup/Workspace/afb-daemon/build/src#-g3 -gdwarf-2 -fPIE -I/home/fulup/Workspace/afb-daemon/include -I/usr/include/json-c -o CMakeFiles/afb-daemon.dir/http-svc.c.o -c /home/fulup/Workspace/afb-daemon/src/http-svc.c
/home/fulup/Workspace/afb-daemon/src/afbs-api.c=/home/fulup/Workspace/afb-daemon/build/src#-g3 -gdwarf-2 -fPIE -I/home/fulup/Workspace/afb-daemon/include -I/usr/include/json-c -o CMakeFiles/afb-daemon.dir/afbs-api.c.o -c /home/fulup/Workspace/afb-daemon/src/afbs-api.c
+/home/fulup/Workspace/afb-daemon/src/rest-api.c=/home/fulup/Workspace/afb-daemon/build/src#-g3 -gdwarf-2 -fPIE -I/home/fulup/Workspace/afb-daemon/include -I/usr/include/json-c -o CMakeFiles/afb-daemon.dir/rest-api.c.o -c /home/fulup/Workspace/afb-daemon/src/rest-api.c
+/home/fulup/Workspace/afb-daemon/src/config.c=/home/fulup/Workspace/afb-daemon/build/src#-g3 -gdwarf-2 -fPIE -I/home/fulup/Workspace/afb-daemon/include -I/usr/include/json-c -o CMakeFiles/afb-daemon.dir/config.c.o -c /home/fulup/Workspace/afb-daemon/src/config.c
return (jsonNewMessage(AFB_FAIL, "Token exist use refresh"));
}
+ // request a new client context token and check result
+ if (AFB_UNAUTH == ctxTokenCreate (request)) {
+ request->errcode=MHD_HTTP_UNAUTHORIZED;
+ jresp= jsonNewMessage(AFB_FAIL, "No/Invalid initial token provided [should match --token=xxxx]");
+ return (jresp);
+ }
+
// request a new client context token and check result
if (AFB_SUCCESS != ctxTokenCreate (request)) {
request->errcode=MHD_HTTP_UNAUTHORIZED;
*/
-
#include "../include/local-def.h"
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
-
#define AFB_CONFIG_JTYPE "AFB_config"
PUBLIC char *ERROR_LABEL[]=ERROR_LABEL_DEF;
{SET_SMACK ,1,"smack" , "Set Smack Label [default demo]"},
{SET_PLUGINS ,1,"mods" , "Enable module [default all]"},
- {SET_AUTH_TOKEN ,1,"token" , "Initial Secret [default=non]"},
+ {SET_AUTH_TOKEN ,1,"token" , "Initial Secret [default=no-session, --token="" for session without authentication]"},
{DISPLAY_VERSION ,0,"version" , "Display version and copyright"},
{DISPLAY_HELP ,0,"help" , "Display this help"},
int oldTnkValid;
const char *ornew;
uuid_t newuuid;
+ const char *token;
if (request->client == NULL) return AFB_EMPTY;
+ // if config->token!="" then verify that we have the right initial share secret
+ if (request->config->token[0] != '\0') {
+
+ // check for initial token secret and return if not presented
+ token = MHD_lookup_connection_value(request->connection, MHD_GET_ARGUMENT_KIND, "token");
+ if (token == NULL) return AFB_UNAUTH;
+
+ // verify that presented initial tokens fit
+ if (strcmp(request->config->token, token)) return AFB_UNAUTH;
+
+ }
+
+
// create a UUID as token value
uuid_generate(newuuid);
uuid_unparse_lower(newuuid, request->client->token);