lusa 5 anni fa
parent
commit
16ab9b86d8
42 ha cambiato i file con 149 aggiunte e 69 eliminazioni
  1. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead
  2. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test
  3. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test.gdb
  4. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead.gdb
  5. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/gopass
  6. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/gopass.gdb
  7. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/libgo.a
  8. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/libgoahead-mbedtls.a
  9. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/libmbedtls.a
  10. 6 0
      app/goahead-5.1.0/build/linux-arm-static/inc/goahead.h
  11. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/action.o
  12. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/alloc.o
  13. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/auth.o
  14. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/cgi.o
  15. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/crypt.o
  16. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/file.o
  17. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/fs.o
  18. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/goahead-mbedtls.o
  19. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/goahead.o
  20. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/gopass.o
  21. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/http.o
  22. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/js.o
  23. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/jst.o
  24. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/mbedtls.o
  25. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/options.o
  26. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/osdep.o
  27. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/rom.o
  28. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/route.o
  29. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/runtime.o
  30. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/socket.o
  31. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/test.o
  32. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/time.o
  33. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/upload.o
  34. 3 0
      app/goahead-5.1.0/src/auth.c
  35. 10 0
      app/goahead-5.1.0/src/auth.txt
  36. 1 43
      app/goahead-5.1.0/src/goahead.c
  37. 6 0
      app/goahead-5.1.0/src/goahead.h
  38. 60 1
      app/goahead-5.1.0/src/route.c
  39. 50 25
      app/goahead-5.1.0/src/route.txt
  40. 10 0
      app/goahead-5.1.0/src/web/login.html
  41. 2 0
      app/goahead-5.1.0/test/test.c
  42. 1 0
      gd32450i-eval.initramfs

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


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


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

@@ -3986,6 +3986,10 @@ PUBLIC void websRemoveSessionVar(Webs *wp, cchar *name);
  */
 PUBLIC int websSetSessionVar(Webs *wp, cchar *name, cchar *value);
 
+
+//add by lusa
+PUBLIC void personInfoAction(Webs *wp);
+
 /************************************ Legacy **********************************/
 /*
     Legacy mappings for pre GoAhead 3.X applications
@@ -4173,6 +4177,8 @@ PUBLIC int websSetSessionVar(Webs *wp, cchar *name, cchar *value);
  #include "customize.h"
 #endif
 
+
+
 #ifdef __cplusplus
 }
 #endif

BIN
app/goahead-5.1.0/build/linux-arm-static/obj/action.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/alloc.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/auth.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/cgi.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/crypt.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/file.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/fs.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/goahead-mbedtls.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/goahead.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/gopass.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/http.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/js.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/jst.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/mbedtls.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/options.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/osdep.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/rom.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/route.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/runtime.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/socket.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/test.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/time.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/upload.o


+ 3 - 0
app/goahead-5.1.0/src/auth.c

@@ -75,6 +75,9 @@ static char *parseDigestNonce(char *nonce, char **secret, char **realm, WebsTime
 static int pamChat(int msgCount, const struct pam_message **msg, struct pam_response **resp, void *data);
 #endif
 
+
+
+
 /************************************ Code ************************************/
 
 PUBLIC bool websAuthenticate(Webs *wp)

+ 10 - 0
app/goahead-5.1.0/src/auth.txt

@@ -15,3 +15,13 @@
 #   Define a user
 #       user name=joshua password=2fd6e47ff9bb70c0465fd2f5c8e5305e roles=manager,purchaser
 #
+
+
+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

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

@@ -40,49 +40,7 @@ static void sigHandler(int signo);
 
 static void buy(Webs *wp);
 static void actionTest(Webs *wp);
-static void personInfoAction(Webs *wp);
-
-
-typedef struct PERSON
-{
-  char *name;
-  int age;
-  char *gender;
-}Person;
-
-
-
-static void personInfoAction(Webs *wp)
-{
-    logmsg(2, "-----------------------111----------------------");
-    int i; 
-    Person person[2];
-    person[0].name = "kangkang";
-    person[0].age = 12;
-    person[0].gender = "male";
-    person[1].name = "Jane";
-    person[1].age = 14;
-    person[1].gender = "female";
-
-   websSetStatus(wp, 200);
-   websWriteHeaders(wp, -1, 0);
-   websWriteEndHeaders(wp);
-
-    websWrite(wp, "[");
-     for (i = 0;i < 2; i++)
-     {
-      
-      websWrite(wp, "       {\"name\":\"%s\",\"age\":\"%d\",\"gender\":\"%s\"}",
-       person[i].name, person[i].age, person[i].gender);
-      if (i != 1)
-      {
-       websWrite(wp, ",");
-      }
-      
-     }
-     websWrite(wp, "]");
-     websDone(wp);
-}
+// static void personInfoAction(Webs *wp);
 
 
 static void buy(Webs *wp)

+ 6 - 0
app/goahead-5.1.0/src/goahead.h

@@ -3986,6 +3986,10 @@ PUBLIC void websRemoveSessionVar(Webs *wp, cchar *name);
  */
 PUBLIC int websSetSessionVar(Webs *wp, cchar *name, cchar *value);
 
+
+//add by lusa
+PUBLIC void personInfoAction(Webs *wp);
+
 /************************************ Legacy **********************************/
 /*
     Legacy mappings for pre GoAhead 3.X applications
@@ -4173,6 +4177,8 @@ PUBLIC int websSetSessionVar(Webs *wp, cchar *name, cchar *value);
  #include "customize.h"
 #endif
 
+
+
 #ifdef __cplusplus
 }
 #endif

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

@@ -33,6 +33,53 @@ static void growRoutes(void);
 static int lookupRoute(cchar *uri);
 static bool redirectHandler(Webs *wp);
 
+
+
+
+
+
+typedef struct PERSON
+{
+  char *name;
+  int age;
+  char *gender;
+}Person;
+
+
+
+void personInfoAction(Webs *wp)
+{
+    logmsg(2, "-----------------------111----------------------");
+    int i; 
+    Person person[2];
+    person[0].name = "kangkang";
+    person[0].age = 12;
+    person[0].gender = "male";
+    person[1].name = "Jane";
+    person[1].age = 14;
+    person[1].gender = "female";
+
+   websSetStatus(wp, 200);
+   websWriteHeaders(wp, -1, 0);
+   websWriteEndHeaders(wp);
+
+    websWrite(wp, "[");
+     for (i = 0;i < 2; i++)
+     {
+      
+      websWrite(wp, " {\"name\":\"%s\",\"age\":\"%d\",\"gender\":\"%s\"}",
+       person[i].name, person[i].age, person[i].gender);
+      if (i != 1)
+      {
+       websWrite(wp, ",");
+      }
+      
+     }
+     websWrite(wp, "]");
+     websDone(wp);
+}
+
+
 /************************************ Code ************************************/
 /*
     Route the request. If wp->route is already set, test routes after that route
@@ -40,6 +87,9 @@ static bool redirectHandler(Webs *wp);
 
 PUBLIC void websRouteRequest(Webs *wp)
 {
+
+    // logmsg(2,"——————————————————————0————————————");
+    logmsg(2, "-----------------------222----------------------");
     WebsRoute   *route;
     WebsHandler *handler;
     ssize       plen, len;
@@ -53,7 +103,7 @@ PUBLIC void websRouteRequest(Webs *wp)
 
     safeMethod = smatch(wp->method, "POST") || smatch(wp->method, "GET") || smatch(wp->method, "HEAD");
     plen = slen(wp->path);
-
+        logmsg(2, "-----------------------0.1----------------------");
     /*
         Resume routine from last matched route. This permits the legacy service() callbacks to return false
         and continue routing.
@@ -71,10 +121,12 @@ PUBLIC void websRouteRequest(Webs *wp)
     } else {
         i = 0;
     }
+    // logmsg(2, "-----------------------0.11----------------------");
     wp->route = 0;
 
     for (; i < routeCount; i++) {
         route = routes[i];
+         logmsg(2, "-----------------------0.2----------------------%s", route->prefix);
         assert(route->prefix && route->prefixLen > 0);
 
         if (plen < route->prefixLen) continue;
@@ -84,6 +136,7 @@ PUBLIC void websRouteRequest(Webs *wp)
             Match route
          */
         if (strncmp(wp->path, route->prefix, len) != 0) {
+             // logmsg(2,"——————————————————————————————%s", route->prefix);
             continue;
         }
         if (route->protocol && !smatch(route->protocol, wp->protocol)) {
@@ -100,15 +153,21 @@ PUBLIC void websRouteRequest(Webs *wp)
         }
         if (route->extensions >= 0 && (wp->ext == 0 || !hashLookup(route->extensions, &wp->ext[1]))) {
             trace(5, "Route %s doesn match extension %s", route->prefix, wp->ext ? wp->ext : "");
+            
             continue;
         }
 
         wp->route = route;
+         logmsg(2,"-----------------------11-----------------------");
 #if ME_GOAHEAD_AUTH
+          logmsg(2,"-----------------------22-----------------------%s", route->authType);
         if (route->authType && !websAuthenticate(wp)) {
+            personInfoAction(wp);// 
+            logmsg(2,"-----------------------33-----------------------");
             return;
         }
         if (route->abilities >= 0 && !websCan(wp, route->abilities)) {
+            logmsg(2,"-----------------------44-----------------------");
             return;
         }
 #endif

+ 50 - 25
app/goahead-5.1.0/src/route.txt

@@ -1,46 +1,71 @@
 #
-#   route.txt - Route and authorization configuration
+#   route.txt - Route 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 
+#   Abilities are a set of required abilities that the user or request must possess.
+#   The abilities, extensions, methods and redirect keywords may 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.
+#   The protocol keyword may be set to http or https
+#   Multiple redirect fields are permissable
 #
-#   Examples:
+#   Redirect over TLS
+#       route uri=/ protocol=http redirect=https handler=redirect
 #
-#   Universally redirect http to https for secure communications
-#       route uri=/ protocol=http redirect=*@https handler=redirect
+#   Form based login pattern
+#       route uri=/login.html
+#       route uri=/action/login methods=POST handler=action redirect=200@/ redirect=401@/login.html
+#       route uri=/action/logout methods=POST handler=action redirect=200@/login.html
+#       route uri=/ auth=form handler=continue redirect=401@/login.html
 #
-#   Form based login pattern. 
-#       route uri=/pub/
-#       route uri=/action/login methods=POST handler=action redirect=200@/ redirect=401@/pub/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
+route uri=/old-alias/ redirect=/alias/atest.html handler=redirect
+
+#
+#   Basic and digest authentication required for these directories.
+#   Require the "manage" ability which only "joshua" has.
+#
+route uri=/auth/basic/admin/  auth=basic abilities=manage
+route uri=/auth/digest/admin/ auth=digest abilities=manage
+route uri=/auth/basic/  auth=basic abilities=view
+route uri=/auth/digest/ auth=digest abilities=view
+
+#
+#   Form-based authentication for content under /auth/form
+#   The login form is /auth/form/login.html. The page to display when logged-in is /auth/form/index.html
+#   Everything else under /auth/form is secured and requires the "manage" ability 
+#
+route uri=/login.html
+
+route uri=/action/login methods=POST handler=action redirect=200@/index.html redirect=401@/login.html
+route uri=/action/logout methods=GET|POST handler=action redirect=200@/login.html
+route uri=/auth/form/ auth=form handler=continue abilities=manage redirect=401@/login.html
+
+route uri=/auth/person auth=digest handler=continue methods=GET|POST abilities=manage redirect=401@/login.html
+
+#route uri=/action/person methods=GET|POST handler=action 
+
+#
+#   Support PUT and DELETE methods only for the BIT_GOAHEAD_PUT_DIR directory
+#
+route uri=/tmp/ methods=PUT|DELETE
+
 #
-#   Sample basic or digest authentication for user "joshua" 
-#       route uri=/auth/basic/ auth=basic abilities=manage
-#       route uri=/auth/digest/ auth=digest abilities=manage
+#   Require TLS to access anything under /secure
 #
-#   Eanable the PUT or DELETE methods (only) for the BIT_GOAHEAD_PUT_DIR directory
-#       route uri=/put/ methods=PUT|DELETE
+route uri=/secure/ protocol=http redirect=https handler=redirect
+
 #
 #   Standard routes
 #
-route uri=/cgi-bin dir=cgi-bin handler=cgi
-route uri=/action handler=action
-route uri=/ extensions=jst handler=jst
+route uri=/cgi-bin handler=cgi
+route uri=/action handler=action auth=form
 route uri=/ methods=OPTIONS|TRACE handler=options
-
-#   For legacy GoAhead applications using /goform
-route uri=/goform handler=action
+route uri=/ extensions=jst,asp handler=jst
 
 #
 #   Catch-all route without authentication for all other URIs
 #
 route uri=/
-route uri=/ extension=jst,html,asp handler=jst
+

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

@@ -0,0 +1,10 @@
+<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>

+ 2 - 0
app/goahead-5.1.0/test/test.c

@@ -51,9 +51,11 @@ static bool testHandler(Webs *wp);
 static int aspTest(int eid, Webs *wp, int argc, char **argv);
 static int bigTest(int eid, Webs *wp, int argc, char **argv);
 #endif
+
 static void actionTest(Webs *wp);
 static void sessionTest(Webs *wp);
 static void showTest(Webs *wp);
+
 #if ME_GOAHEAD_UPLOAD && !ME_ROM
 static void uploadTest(Webs *wp);
 #endif

+ 1 - 0
gd32450i-eval.initramfs

@@ -133,6 +133,7 @@ file /etc/goahead/route.txt ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-5.1.0
 
 file /var/www/goahead/favicon.ico ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-5.1.0/src/web/favicon.ico 755 0 0
 file /var/www/goahead/index.html ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-5.1.0/src/web/index.html 755 0 0
+file /var/www/goahead/login.html ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-5.1.0/src/web/login.html 755 0 0
 file /var/www/goahead/static/css/app.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-5.1.0/src/web/static/css/app.css 755 0 0
 file /var/www/goahead/static/img/logo.82b9c7a5.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-5.1.0/src/web/static/img/logo.82b9c7a5.png 755 0 0
 file /var/www/goahead/static/js/app.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-5.1.0/src/web/static/js/app.js 755 0 0