ソースを参照

test login resfult interface

lusa 5 年 前
コミット
600b46074f

BIN
app/goahead-5.1.0/build/linux-arm-static/.makeflags


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test.gdb


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead.gdb


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/gopass


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/gopass.gdb


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/libgo.a


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/libgoahead-mbedtls.a


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/libmbedtls.a


+ 18 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/ResultUtils.h

@@ -0,0 +1,18 @@
+#ifndef __RESULT_UTILS_H__
+#define __RESULT_UTILS_H__
+
+#include "goahead.h"
+
+void HelloWord(Webs *wp);
+
+char outPutLoginJson(char *cjson_str);
+
+void getErrorJson(char *cjson_str, int cjson_code);
+
+//成功切无数据返回
+void successResult(Webs *wp);
+
+//成功切无数据返回
+void errorResult(Webs *wp);
+
+#endif /* __RESULT_UTILS_H__ */

+ 127 - 101
app/goahead-5.1.0/projects/goahead-linux-static.mk

@@ -204,6 +204,127 @@ $(BUILD)/inc/mbedtls.h: $(DEPS_6)
 	mkdir -p "$(BUILD)/inc"
 	cp src/mbedtls/mbedtls.h $(BUILD)/inc/mbedtls.h
 
+
+#################### jimbo modify ###########################
+#
+#   cJSON
+#
+DEPS_USER_H1 += src/cJSON/cJSON.h
+DEPS_USER_H1 += $(BUILD)/inc/goahead.h
+
+$(BUILD)/inc/cJSON.h: $(DEPS_USER_H1)
+	@echo '      [Copy] $(BUILD)/inc/cJSON.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/cJSON/cJSON.h $(BUILD)/inc/cJSON.h
+
+DEPS_USER_C1 += $(BUILD)/inc/goahead.h
+DEPS_USER_C1 += $(BUILD)/inc/cJSON.h
+
+$(BUILD)/obj/cJSON.o: \
+    src/cJSON/cJSON.c $(DEPS_USER_C1)
+	@echo '   [Compile] $(BUILD)/obj/cJSON.o'
+	$(CC) -c -o $(BUILD)/obj/cJSON.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/cJSON/cJSON.c
+
+#
+#	libipmi
+#
+DEPS_USER_H2 += src/libipmi/inc/libipmi_session.h
+DEPS_USER_H2 += src/libipmi/inc/libipmi.h
+DEPS_USER_H2 += src/libipmi/inc/libipmi_errorcodes.h
+DEPS_USER_H2 += src/libipmi/inc/libipmi_struct.h
+DEPS_USER_H2 += src/libipmi/inc/libipmi_IPM.h
+DEPS_USER_H2 += ../common_include/com_IPMI_AppDevice.h
+DEPS_USER_H2 += ../common_include/com_IPMIDefs.h
+DEPS_USER_H2 += ../common_include/com_IPMI_IPM.h
+DEPS_USER_H2 += ../common_include/com_UDSIfc.h
+DEPS_USER_H2 += ../common_include/com_IPMI_App.h
+
+$(BUILD)/inc/libipmi_session.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi_session.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi_session.h $(BUILD)/inc/libipmi_session.h
+$(BUILD)/inc/libipmi.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi.h $(BUILD)/inc/libipmi.h
+$(BUILD)/inc/libipmi_errorcodes.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi_errorcodes.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi_errorcodes.h $(BUILD)/inc/libipmi_errorcodes.h
+$(BUILD)/inc/libipmi_struct.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi_struct.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi_struct.h $(BUILD)/inc/libipmi_struct.h
+$(BUILD)/inc/libipmi_IPM.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi_IPM.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi_IPM.h $(BUILD)/inc/libipmi_IPM.h
+
+$(BUILD)/inc/com_IPMI_AppDevice.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_IPMI_AppDevice.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_IPMI_AppDevice.h $(BUILD)/inc/com_IPMI_AppDevice.h
+$(BUILD)/inc/com_IPMIDefs.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_IPMIDefs.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_IPMIDefs.h $(BUILD)/inc/com_IPMIDefs.h
+$(BUILD)/inc/com_IPMI_IPM.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_IPMI_IPM.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_IPMI_IPM.h $(BUILD)/inc/com_IPMI_IPM.h
+$(BUILD)/inc/com_UDSIfc.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_UDSIfc.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_UDSIfc.h $(BUILD)/inc/com_UDSIfc.h
+$(BUILD)/inc/com_IPMI_App.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_IPMI_App.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_IPMI_App.h $(BUILD)/inc/com_IPMI_App.h
+
+DEPS_USER_C2 += $(BUILD)/inc/libipmi_session.h
+DEPS_USER_C2 += $(BUILD)/inc/libipmi.h
+DEPS_USER_C2 += $(BUILD)/inc/libipmi_errorcodes.h
+DEPS_USER_C2 += $(BUILD)/inc/libipmi_struct.h
+DEPS_USER_C2 += $(BUILD)/inc/libipmi_IPM.h
+DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_AppDevice.h
+DEPS_USER_C2 += $(BUILD)/inc/com_IPMIDefs.h
+DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_IPM.h
+DEPS_USER_C2 += $(BUILD)/inc/com_UDSIfc.h
+DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_App.h
+
+$(BUILD)/obj/libipmi_session.o: \
+    src/libipmi/src/libipmi_session.c $(DEPS_USER_C2)
+	@echo '   [Compile] $(BUILD)/obj/libipmi_session.o'
+	$(CC) -c -o $(BUILD)/obj/libipmi_session.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/libipmi_session.c
+$(BUILD)/obj/libipmi_uds_session.o: \
+    src/libipmi/src/libipmi_uds_session.c $(DEPS_USER_C2)
+	@echo '   [Compile] $(BUILD)/obj/libipmi_uds_session.o'
+	$(CC) -c -o $(BUILD)/obj/libipmi_uds_session.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/libipmi_uds_session.c
+
+#
+#   LUSA, ResultUtils
+#
+DEPS_USER_H3 += src/utils/mine/ResultUtils.h
+DEPS_USER_H3 += $(BUILD)/inc/goahead.h
+
+$(BUILD)/inc/ResultUtils.h: $(DEPS_USER_H3)
+	@echo '      [Copy] $(BUILD)/inc/ResultUtils.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/utils/mine/ResultUtils.h $(BUILD)/inc/ResultUtils.h
+
+DEPS_USER_C3 += $(BUILD)/inc/goahead.h
+DEPS_USER_C3 += $(BUILD)/inc/ResultUtils.h
+
+$(BUILD)/obj/ResultUtils.o: \
+    src/utils/mine/ResultUtils.c $(DEPS_USER_C3)
+	@echo '   [Compile] $(BUILD)/obj/ResultUtils.o'
+	$(CC) -c -o $(BUILD)/obj/ResultUtils.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/utils/mine/ResultUtils.c
+
+
+
+
+
+
 #
 #   action.o
 #
@@ -497,105 +618,6 @@ $(BUILD)/bin/libgoahead-openssl.a: $(DEPS_35)
 	@echo '      [Link] $(BUILD)/bin/libgoahead-openssl.a'
 	$(AR) -cr $(BUILD)/bin/libgoahead-openssl.a "$(BUILD)/obj/goahead-openssl.o"
 endif
-#################### jimbo modify ###########################
-#
-#   cJSON
-#
-DEPS_USER_H1 += src/cJSON/cJSON.h
-DEPS_USER_H1 += $(BUILD)/inc/goahead.h
-
-$(BUILD)/inc/cJSON.h: $(DEPS_USER_H1)
-	@echo '      [Copy] $(BUILD)/inc/cJSON.h'
-	mkdir -p "$(BUILD)/inc"
-	cp src/cJSON/cJSON.h $(BUILD)/inc/cJSON.h
-
-DEPS_USER_C1 += $(BUILD)/inc/goahead.h
-DEPS_USER_C1 += $(BUILD)/inc/cJSON.h
-
-$(BUILD)/obj/cJSON.o: \
-    src/cJSON/cJSON.c $(DEPS_USER_C1)
-	@echo '   [Compile] $(BUILD)/obj/cJSON.o'
-	$(CC) -c -o $(BUILD)/obj/cJSON.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/cJSON/cJSON.c
-
-#
-#	libipmi
-#
-DEPS_USER_H2 += src/libipmi/inc/libipmi_session.h
-DEPS_USER_H2 += src/libipmi/inc/libipmi.h
-DEPS_USER_H2 += src/libipmi/inc/libipmi_errorcodes.h
-DEPS_USER_H2 += src/libipmi/inc/libipmi_struct.h
-DEPS_USER_H2 += src/libipmi/inc/libipmi_IPM.h
-DEPS_USER_H2 += ../common_include/com_IPMI_AppDevice.h
-DEPS_USER_H2 += ../common_include/com_IPMIDefs.h
-DEPS_USER_H2 += ../common_include/com_IPMI_IPM.h
-DEPS_USER_H2 += ../common_include/com_UDSIfc.h
-DEPS_USER_H2 += ../common_include/com_IPMI_App.h
-
-
-$(BUILD)/inc/libipmi_session.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/libipmi_session.h'
-	mkdir -p "$(BUILD)/inc"
-	cp src/libipmi/inc/libipmi_session.h $(BUILD)/inc/libipmi_session.h
-$(BUILD)/inc/libipmi.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/libipmi.h'
-	mkdir -p "$(BUILD)/inc"
-	cp src/libipmi/inc/libipmi.h $(BUILD)/inc/libipmi.h
-$(BUILD)/inc/libipmi_errorcodes.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/libipmi_errorcodes.h'
-	mkdir -p "$(BUILD)/inc"
-	cp src/libipmi/inc/libipmi_errorcodes.h $(BUILD)/inc/libipmi_errorcodes.h
-$(BUILD)/inc/libipmi_struct.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/libipmi_struct.h'
-	mkdir -p "$(BUILD)/inc"
-	cp src/libipmi/inc/libipmi_struct.h $(BUILD)/inc/libipmi_struct.h
-$(BUILD)/inc/libipmi_IPM.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/libipmi_IPM.h'
-	mkdir -p "$(BUILD)/inc"
-	cp src/libipmi/inc/libipmi_IPM.h $(BUILD)/inc/libipmi_IPM.h
-
-$(BUILD)/inc/com_IPMI_AppDevice.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/com_IPMI_AppDevice.h'
-	mkdir -p "$(BUILD)/inc"
-	cp ../common_include/com_IPMI_AppDevice.h $(BUILD)/inc/com_IPMI_AppDevice.h
-$(BUILD)/inc/com_IPMIDefs.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/com_IPMIDefs.h'
-	mkdir -p "$(BUILD)/inc"
-	cp ../common_include/com_IPMIDefs.h $(BUILD)/inc/com_IPMIDefs.h
-$(BUILD)/inc/com_IPMI_IPM.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/com_IPMI_IPM.h'
-	mkdir -p "$(BUILD)/inc"
-	cp ../common_include/com_IPMI_IPM.h $(BUILD)/inc/com_IPMI_IPM.h
-$(BUILD)/inc/com_UDSIfc.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/com_UDSIfc.h'
-	mkdir -p "$(BUILD)/inc"
-	cp ../common_include/com_UDSIfc.h $(BUILD)/inc/com_UDSIfc.h
-$(BUILD)/inc/com_IPMI_App.h: $(DEPS_USER_H2)
-	@echo '      [Copy] $(BUILD)/inc/com_IPMI_App.h'
-	mkdir -p "$(BUILD)/inc"
-	cp ../common_include/com_IPMI_App.h $(BUILD)/inc/com_IPMI_App.h
-
-DEPS_USER_C2 += $(BUILD)/inc/libipmi_session.h
-DEPS_USER_C2 += $(BUILD)/inc/libipmi.h
-DEPS_USER_C2 += $(BUILD)/inc/libipmi_errorcodes.h
-DEPS_USER_C2 += $(BUILD)/inc/libipmi_struct.h
-DEPS_USER_C2 += $(BUILD)/inc/libipmi_IPM.h
-DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_AppDevice.h
-DEPS_USER_C2 += $(BUILD)/inc/com_IPMIDefs.h
-DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_IPM.h
-DEPS_USER_C2 += $(BUILD)/inc/com_UDSIfc.h
-DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_App.h
-
-$(BUILD)/obj/libipmi_session.o: \
-    src/libipmi/src/libipmi_session.c $(DEPS_USER_C2)
-	@echo '   [Compile] $(BUILD)/obj/libipmi_session.o'
-	$(CC) -c -o $(BUILD)/obj/libipmi_session.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/libipmi_session.c
-$(BUILD)/obj/libipmi_uds_session.o: \
-    src/libipmi/src/libipmi_uds_session.c $(DEPS_USER_C2)
-	@echo '   [Compile] $(BUILD)/obj/libipmi_uds_session.o'
-	$(CC) -c -o $(BUILD)/obj/libipmi_uds_session.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/libipmi_uds_session.c
-
-
-
 
 
 #
@@ -610,6 +632,10 @@ ifeq ($(ME_COM_OPENSSL),1)
 endif
 DEPS_36 += $(BUILD)/inc/goahead.h
 DEPS_36 += $(BUILD)/inc/js.h
+DEPS_36 += $(BUILD)/inc/ResultUtils.h
+DEPS_36 += $(BUILD)/inc/cJSON.h
+DEPS_36 += $(BUILD)/obj/ResultUtils.o
+DEPS_36 += $(BUILD)/obj/cJSON.o
 DEPS_36 += $(BUILD)/obj/action.o
 DEPS_36 += $(BUILD)/obj/alloc.o
 DEPS_36 += $(BUILD)/obj/auth.o
@@ -628,14 +654,14 @@ DEPS_36 += $(BUILD)/obj/runtime.o
 DEPS_36 += $(BUILD)/obj/socket.o
 DEPS_36 += $(BUILD)/obj/time.o
 DEPS_36 += $(BUILD)/obj/upload.o
-DEPS_36 += $(BUILD)/obj/cJSON.o
 DEPS_36 += $(BUILD)/obj/libipmi_session.o
 DEPS_36 += $(BUILD)/obj/libipmi_uds_session.o
 
 
+
 $(BUILD)/bin/libgo.a: $(DEPS_36)
 	@echo '      [Link] $(BUILD)/bin/libgo.a'
-	$(AR) -cr $(BUILD)/bin/libgo.a "$(BUILD)/obj/action.o" "$(BUILD)/obj/alloc.o" "$(BUILD)/obj/auth.o" "$(BUILD)/obj/cgi.o" "$(BUILD)/obj/crypt.o" "$(BUILD)/obj/file.o" "$(BUILD)/obj/fs.o" "$(BUILD)/obj/http.o" "$(BUILD)/obj/js.o" "$(BUILD)/obj/jst.o" "$(BUILD)/obj/options.o" "$(BUILD)/obj/osdep.o" "$(BUILD)/obj/rom.o" "$(BUILD)/obj/route.o" "$(BUILD)/obj/runtime.o" "$(BUILD)/obj/socket.o" "$(BUILD)/obj/time.o" "$(BUILD)/obj/upload.o" "$(BUILD)/obj/cJSON.o" "$(BUILD)/obj/libipmi_session.o" "$(BUILD)/obj/libipmi_uds_session.o"
+	$(AR) -cr $(BUILD)/bin/libgo.a "$(BUILD)/obj/ResultUtils.o" "$(BUILD)/obj/action.o" "$(BUILD)/obj/alloc.o" "$(BUILD)/obj/auth.o" "$(BUILD)/obj/cgi.o" "$(BUILD)/obj/crypt.o" "$(BUILD)/obj/file.o" "$(BUILD)/obj/fs.o" "$(BUILD)/obj/http.o" "$(BUILD)/obj/js.o" "$(BUILD)/obj/jst.o" "$(BUILD)/obj/options.o" "$(BUILD)/obj/osdep.o" "$(BUILD)/obj/rom.o" "$(BUILD)/obj/route.o" "$(BUILD)/obj/runtime.o" "$(BUILD)/obj/socket.o" "$(BUILD)/obj/time.o" "$(BUILD)/obj/upload.o" "$(BUILD)/obj/cJSON.o" "$(BUILD)/obj/libipmi_session.o" "$(BUILD)/obj/libipmi_uds_session.o" 
 
 #
 #   install-certs

+ 36 - 8
app/goahead-5.1.0/src/auth.c

@@ -24,6 +24,7 @@
 /********************************* Includes ***********************************/
 
 #include    "goahead.h"
+#include    "ResultUtils.h"
 
 #if ME_GOAHEAD_AUTH
 
@@ -142,6 +143,8 @@ PUBLIC bool websAuthenticate(Webs *wp)
 
 PUBLIC int websOpenAuth(int minimal)
 {
+
+     logmsg(2,"-------------open auth --------------------------------------");
     char    sbuf[64];
 
     assert(minimal == 0 || minimal == 1);
@@ -152,8 +155,11 @@ PUBLIC int websOpenAuth(int minimal)
     if ((roles = hashCreate(-1)) < 0) {
         return -1;
     }
+    // char aa = ""
+   
     if (!minimal) {
         fmt(sbuf, sizeof(sbuf), "%x:%x", rand(), time(0));
+        logmsg(2,"-------------open auth 2222222--------------------------------------%s", sbuf);
         masterSecret = websMD5(sbuf);
 #if ME_GOAHEAD_JAVASCRIPT && FUTURE
         websJsDefine("can", jsCan);
@@ -162,9 +168,12 @@ PUBLIC int websOpenAuth(int minimal)
         websDefineAction("logout", logoutServiceProc);
     }
     if (smatch(ME_GOAHEAD_AUTH_STORE, "file")) {
+        logmsg(2,"-------------come in there222 !!");
         verifyPassword = websVerifyPasswordFromFile;
 #if ME_COMPILER_HAS_PAM
+
     } else if (smatch(ME_GOAHEAD_AUTH_STORE, "pam")) {
+         logmsg(2,"-------------come in11 there !!");
         verifyPassword = websVerifyPasswordFromPam;
 #endif
     }
@@ -489,7 +498,8 @@ PUBLIC bool websLoginUser(Webs *wp, cchar *username, cchar *password)
     assert(wp->route);
     assert(username);
     assert(password);
-
+    logmsg(2, "%s-----------password auth0- ---------", password);
+    logmsg(2, "%s-----------begin auth1 ---------", wp->route);
     if (!wp->route || !wp->route->verify) {
         return 0;
     }
@@ -508,47 +518,59 @@ PUBLIC bool websLoginUser(Webs *wp, cchar *username, cchar *password)
     return 1;
 }
 
-
+/*update by lusa  fix redirect to return json*/
 PUBLIC bool websLogoutUser(Webs *wp)
 {
     assert(wp);
     websRemoveSessionVar(wp, WEBS_SESSION_USERNAME);
     websDestroySession(wp);
     if (smatch(wp->authType, "basic") || smatch(wp->authType, "digest")) {
-        websError(wp, HTTP_CODE_UNAUTHORIZED, "Logged out.");
+        // websError(wp, HTTP_CODE_UNAUTHORIZED, "Logged out.");
+        errorResult(wp);
         return 0;
     }
-    websRedirectByStatus(wp, HTTP_CODE_OK);
+    // websRedirectByStatus(wp, HTTP_CODE_OK);
+    successResult(wp);
     return 1;
 }
 
 
 /*
     Internal login service routine for Form-based auth
+    update by lusa 20191230 
  */
+
 static void loginServiceProc(Webs *wp)
 {
     WebsRoute   *route;
-
+    logmsg(1, "--------------login come in --------在这里用------");
+    HelloWord(wp);  //test
     assert(wp);
     route = wp->route;
     assert(route);
 
     if (websLoginUser(wp, websGetVar(wp, "username", ""), websGetVar(wp, "password", ""))) {
         /* If the application defines a referrer session var, redirect to that */
-        cchar *referrer;
+        //update start 
+       /* cchar *referrer;
         if ((referrer = websGetSessionVar(wp, "referrer", 0)) != 0) {
             websRedirect(wp, referrer);
         } else {
             websRedirectByStatus(wp, HTTP_CODE_OK);
-        }
+        }*/
+
+        successResult(wp);
+        //end 
         websSetSessionVar(wp, "loginStatus", "ok");
+
+        websSetSessionVar(wp, "lang", "en");
     } else {
         if (route->askLogin) {
             (route->askLogin)(wp);
         }
         websSetSessionVar(wp, "loginStatus", "failed");
-        websRedirectByStatus(wp, HTTP_CODE_UNAUTHORIZED);
+        errorResult(wp);
+        // websRedirectByStatus(wp, HTTP_CODE_UNAUTHORIZED);
     }
 }
 
@@ -585,6 +607,7 @@ PUBLIC bool websVerifyPasswordFromFile(Webs *wp)
     char    passbuf[ME_GOAHEAD_LIMIT_PASSWORD * 3 + 3];
     bool    success;
 
+    logmsg(2, "***************start to auth pwd***************")
     assert(wp);
     if (!wp->user && (wp->user = websLookupUser(wp->username)) == 0) {
         trace(5, "verifyUser: Unknown user \"%s\"", wp->username);
@@ -594,17 +617,22 @@ PUBLIC bool websVerifyPasswordFromFile(Webs *wp)
         Verify the password. If using Digest auth, we compare the digest of the password.
         Otherwise we encode the plain-text password and compare that
      */
+    // logmsg(2, "***************start to auth pwd111***************%s" , websMD5(passbuf))
     if (!wp->encoded) {
         fmt(passbuf, sizeof(passbuf), "%s:%s:%s", wp->username, ME_GOAHEAD_REALM, wp->password);
         wfree(wp->password);
+        logmsg(2, "***************start to auth pwd222***************%s" , websMD5(passbuf));
         wp->password = websMD5(passbuf);
         wp->encoded = 1;
     }
+
     if (wp->digest) {
         success = smatch(wp->password, wp->digest);
     } else {
+
         success = smatch(wp->password, wp->user->password);
     }
+
     if (success) {
         trace(5, "User \"%s\" authenticated", wp->username);
     } else {

+ 5 - 4
app/goahead-5.1.0/src/auth.txt

@@ -21,7 +21,8 @@ role name=person abilities=breathe
 role name=user abilities=view,person
 role name=administrator abilities=user,manage
 
-user name=julie password=9d8873a123eb506e7f8e84d1f2a26916 roles=user
-user name=joshua password=2fd6e47ff9bb70c0465fd2f5c8e5305e roles=administrator,purchase
-user name=mary password=5b90553bea8ba3686f4239d62801f0f3 roles=user
-user name=peter password=7cdba57892649fd95a540683fdf8fba6 roles=user
+#user name=julie password=13fe720f98d63de9d25ad4aaf595dcf9 roles=user
+user name=julie password=13fe720f98d63de9d25ad4aaf595dcf9 roles=user
+user name=joshua password=13fe720f98d63de9d25ad4aaf595dcf9 roles=administrator,purchase
+user name=mary password=13fe720f98d63de9d25ad4aaf595dcf9 roles=user
+user name=peter password=13fe720f98d63de9d25ad4aaf595dcf9 roles=user

+ 53 - 29
app/goahead-5.1.0/src/http.c

@@ -10,6 +10,10 @@
 /********************************* Includes ***********************************/
 
 #include    "goahead.h"
+#include    <stdio.h>
+#include    <string.h>
+// #include     "cJSON.h"
+#include    "ResultUtils.h"
 
 /********************************* Defines ************************************/
 
@@ -220,6 +224,8 @@ static void     socketEvent(int sid, int mask, void *data);
 static void     writeEvent(Webs *wp);
 static char     *validateToken(char *token, char *endToken, int validation);
 
+
+
 #if ME_GOAHEAD_ACCESS_LOG
 static void     logRequest(Webs *wp, int code);
 #endif
@@ -1611,22 +1617,30 @@ PUBLIC void websCancelTimeout(Webs *wp)
 /*
     Output a HTTP response back to the browser. If redirect is set to a URL, the browser will be sent to this location.
  */
+//modify by lusa 
 PUBLIC void websResponse(Webs *wp, int code, cchar *message)
 {
     ssize   len;
 
     assert(websValid(wp));
     websSetStatus(wp, code);
-
+    logmsg(2,"-----------------------response 0-----------------------%s", wp->method);
     if (!smatch(wp->method, "HEAD") && message && *message) {
+
+        logmsg(2,"-----------------------response 1-----------------------%s", message);
         len = slen(message);
         websWriteHeaders(wp, len + 2, 0);
         websWriteEndHeaders(wp);
         websWriteBlock(wp, message, len);
         websWriteBlock(wp, "\r\n", 2);
+
+        // websWrite(wp, message);
+       
     } else {
+        logmsg(2,"-----------------------response 2-----------------------%s", message);
         websWriteHeaders(wp, 0, 0);
         websWriteEndHeaders(wp);
+        // websWriteBlock(wp, message, len);
     }
     websDone(wp);
 }
@@ -1709,29 +1723,34 @@ PUBLIC void websRedirect(Webs *wp, cchar *uri)
     wfree(location);
 }
 
-
+/*
+        update by lusa 
+*/
 PUBLIC int websRedirectByStatus(Webs *wp, int status)
 {
-    WebsKey     *key;
-    char        code[16], *uri;
 
-    assert(wp);
-    assert(status >= 0);
+    logmsg(2,"--------------------------------Warning come in redirect TODO fix this-------------------- ");
+    // WebsKey     *key;
+    // char        code[16], *uri;
+
+    // assert(wp);
+    // assert(status >= 0);
 
     if (wp->route && wp->route->redirects >= 0) {
-        itosbuf(code, sizeof(code), status, 10);
-        if ((key = hashLookup(wp->route->redirects, code)) != 0) {
-            uri = key->content.value.string;
-        } else {
-            return -1;
-        }
-        websRedirect(wp, uri);
+         logmsg(2,"--------------------------------Warning come in redirect TODO fix this-------------------- ");
+    //     itosbuf(code, sizeof(code), status, 10);
+    //     if ((key = hashLookup(wp->route->redirects, code)) != 0) {
+    //         uri = key->content.value.string;
+    //     } else {
+    //         return -1;
+    //     }
+    //     websRedirect(wp, uri);
     } else {
-        if (status == HTTP_CODE_UNAUTHORIZED) {
-            websError(wp, status, "Access Denied. User not logged in.");
-        } else {
-            websError(wp, status, 0);
-        }
+    //     if (status == HTTP_CODE_UNAUTHORIZED) {
+    //         websError(wp, status, "Access Denied. User not logged in.");
+    //     } else {
+    //         websError(wp, status, 0);
+    //     }
     }
     return 0;
 }
@@ -3444,10 +3463,10 @@ static void setFileLimits(void)
 PUBLIC void websError(Webs *wp, int code, cchar *fmt, ...)
 {
     va_list     args;
-    char        *msg, *buf;
+    char        *msg;//, *buf;
     char        *encoded;
     int         status;
-
+    char        buf[100] = {0};
     assert(wp);
     wp->error = 1;
     if (code & WEBS_CLOSE) {
@@ -3476,21 +3495,26 @@ PUBLIC void websError(Webs *wp, int code, cchar *fmt, ...)
             trace(2, "%s", msg);
             wfree(msg);
         }
-        buf = sfmt("\
-<html>\r\n\
-    <head><title>Document Error: %s</title></head>\r\n\
-    <body>\r\n\
-        <h2>Access Error: %s</h2>\r\n\
-    </body>\r\n\
-</html>\r\n", websErrorMsg(code), websErrorMsg(code));
+//         buf = sfmt("\
+// <html>\r\n\
+//     <head><title>Document Error: %s</title></head>\r\n\
+//     <body>\r\n\
+//         <h2>Access Error: %s</h2>\r\n\
+//     </body>\r\n\
+// </html>\r\n", websErrorMsg(code), websErrorMsg(code));
+         getErrorJson(buf, code);
     } else {
-        buf = 0;
+        //buf = 0;
+        memset(buf, 0, 100);
+        
     }
     websResponse(wp, code, buf);
-    wfree(buf);
+    //wfree(buf);
 }
 
 
+
+
 /*
     Return the error message for a given code
  */

+ 1 - 1
app/goahead-5.1.0/src/route.c

@@ -162,7 +162,7 @@ PUBLIC void websRouteRequest(Webs *wp)
 #if ME_GOAHEAD_AUTH
           logmsg(2,"-----------------------22-----------------------%s", route->authType);
         if (route->authType && !websAuthenticate(wp)) {
-            personInfoAction(wp);// 
+            // personInfoAction(wp);// 
             logmsg(2,"-----------------------33-----------------------");
             return;
         }

+ 46 - 0
app/goahead-5.1.0/src/route1.txt

@@ -0,0 +1,46 @@
+#
+#   route.txt - Route and authorization configuration
+#
+#   Schema
+#       route uri=URI protocol=PROTOCOL methods=METHODS handler=HANDLER redirect=STATUS@URI \
+#           extensions=EXTENSIONS abilities=ABILITIES 
+#
+#   Routes may require authentication and that users possess certain abilities.
+#   The abilities, extensions, methods and redirect keywords use comma separated tokens to express a set of 
+#       required options, or use "|" separated tokens for a set of alternative options. This implements AND/OR.
+#   The protocol keyword may be set to http or https. The redirect status may be "*" to match all HTTP status codes.
+#   Multiple redirect fields are permissible.
+#
+#   Examples:
+#
+#   Universally redirect http to https for secure communications
+#       route uri=/ protocol=http redirect=*@https handler=redirect
+#
+#   Form based login pattern. 
+#       route uri=/pub/
+      	route uri=/action/login methods=POST handler=action redirect=200@/ redirect=401@/web/login.html
+#       route uri=/action/logout methods=POST handler=action redirect=200@/pub/login.html
+#       route uri=/ auth=form handler=continue redirect=401@/pub/login.html
+#
+#   Sample basic or digest authentication for user "joshua" 
+#       route uri=/auth/basic/ auth=basic abilities=manage
+#       route uri=/auth/digest/ auth=digest abilities=manage
+#
+#   Eanable the PUT or DELETE methods (only) for the BIT_GOAHEAD_PUT_DIR directory
+#       route uri=/put/ methods=PUT|DELETE
+#
+#   Standard routes
+#
+route uri=/cgi-bin dir=cgi-bin handler=cgi
+route uri=/action handler=action
+route uri=/ extensions=jst handler=jst
+route uri=/ methods=OPTIONS|TRACE handler=options
+
+#   For legacy GoAhead applications using /goform
+route uri=/goform handler=action
+
+#
+#   Catch-all route without authentication for all other URIs
+#
+route uri=/
+route uri=/ extension=jst,html,asp handler=jst

+ 74 - 0
app/goahead-5.1.0/src/utils/mine/ResultUtils.c

@@ -0,0 +1,74 @@
+
+#include    "ResultUtils.h"
+#include    "goahead.h"
+#include    "cJSON.h"
+#include 	<stdio.h>
+
+static void commResult(Webs *wp, int msgCode, int httpStatus, int isSuccess) ;
+
+void HelloWord(Webs *wp)
+{
+	printf("---> hello ResultUtils!\n");
+
+}
+
+void successResult(Webs *wp) {
+     commResult(wp, 100001, 200, 1);
+}
+
+
+void errorResult(Webs *wp) {
+
+    commResult(wp, 100002, 500, 0);
+}
+
+
+
+static void commResult(Webs *wp, int msgCode, int httpStatus, int isSuccess) {
+    char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    // cJSON * next =  cJSON_CreateObject();
+
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(websErrorMsg(msgCode)));
+    cJSON_AddItemToObject(root, "code", cJSON_CreateNumber(msgCode));
+    cJSON_AddItemToObject(root, "isSuccess", cJSON_CreateNumber(isSuccess));
+    
+    pStr = cJSON_Print(root);
+    
+
+    // memcpy(cjson_str, pStr, strlen(pStr));
+    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
+    websResponse(wp, httpStatus, pStr);
+    cJSON_Delete(root);//free memery
+    wfree(pStr);
+
+}
+
+
+
+
+//add by lusa 
+void getErrorJson(char *cjson_str, int cjson_code)
+{
+    logmsg(2, "-----------------------json----------------------");
+    char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    // cJSON * next =  cJSON_CreateObject();
+
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(websErrorMsg(cjson_code)));
+    cJSON_AddItemToObject(root, "code", cJSON_CreateNumber(cjson_code));
+    
+
+    pStr = cJSON_Print(root);
+     logmsg(2, "-----------------------jso1n----------------------%s", pStr);
+    //cjson_str = sfmt("%s", pStr);
+    // printf("---> pStr: %s\n", pStr);
+    
+    memcpy(cjson_str, pStr, strlen(pStr));
+    logmsg(2, "-----------------------json-2------ %d ---------------%s", strlen(pStr), cjson_str);
+
+}

+ 19 - 0
app/goahead-5.1.0/src/utils/mine/ResultUtils.h

@@ -0,0 +1,19 @@
+#ifndef __RESULT_UTILS_H__
+#define __RESULT_UTILS_H__
+
+#include "goahead.h"
+
+void HelloWord(Webs *wp);
+
+char outPutLoginJson(char *cjson_str);
+
+void getErrorJson(char *cjson_str, int cjson_code);
+
+//成功切无数据返回
+void successResult(Webs *wp);
+
+//成功切无数据返回
+void errorResult(Webs *wp);
+
+
+#endif /* __RESULT_UTILS_H__ */

BIN
app/goahead-5.1.0/src/web/favicon.ico


+ 0 - 36
app/goahead-5.1.0/src/web/index.html

@@ -1,36 +0,0 @@
- <p>Please log in</p>
-    <form action=/action/test method="post">
-        <table>
-        <tr><td>账号:</td><td><input type="text" name="name"></td></tr>
-        <tr><td>密码:</td><td><input type="password" name="address"></td></tr>
-        <tr><td><input type="submit" name="submit" value="submit"></td>
-            <td><input type="reset" value="reset"></td></tr>
-        </table>
-    </form>
-    
-    <script type="text/javascript">
-    function loadXMLDoc()
-    {
-        var xmlhttp;
-        if (window.XMLHttpRequest)
-          {// code for IE7+, Firefox, Chrome, Opera, Safari
-              xmlhttp=new XMLHttpRequest();
-          }
-        else
-          {// code for IE6, IE5
-              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
-          }
-        xmlhttp.onreadystatechange=function()
-          {
-              if (xmlhttp.readyState==4 && xmlhttp.status==200)
-            {
-                document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
-                }
-          }
-        xmlhttp.open("GET","action/test",true);
-        xmlhttp.send();
-    }
-    </script>
-    
-    <div id="myDiv"><h2>需要刷新的局部内容</h2></div>
-    <button type="button" onclick="loadXMLDoc()">通过 AJAX 实现局部刷新</button>

+ 0 - 10
app/goahead-5.1.0/src/web/login.html

@@ -1,10 +0,0 @@
-<html><head><title>login.html</title></head>
-<body>
-    <p>Please log i111111111n</p>
-    <form name="details" method="post" action="/action/login">
-        Username <input type="text" name="username" value=''><br/>
-        Password <input type="password" name="password" value=''><br/>
-        <input type="submit" name="submit" value="OK">
-    </form>
-</body>
-</html>

+ 0 - 1
app/goahead-5.1.0/src/web/static/css/app.css

@@ -1 +0,0 @@
-h3[data-v-b9167eee]{margin:40px 0 0}ul[data-v-b9167eee]{list-style-type:none;padding:0}li[data-v-b9167eee]{display:inline-block;margin:0 10px}a[data-v-b9167eee]{color:#42b983}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50;margin-top:60px}

BIN
app/goahead-5.1.0/src/web/static/img/logo.82b9c7a5.png


ファイルの差分が大きいため隠しています
+ 0 - 0
app/goahead-5.1.0/src/web/static/js/app.js


ファイルの差分が大きいため隠しています
+ 0 - 0
app/goahead-5.1.0/src/web/static/js/chunk-vendors.js


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません