Преглед изворни кода

aah framework updated to latest release v0.8 (#2933)

* benchmark updated to use latest release version v0.7
- fixed TFB Host header issue

* benchmark app updated to latest aah version 0.8
Jeevanandam M пре 8 година
родитељ
комит
33fd4c7104

+ 18 - 11
frameworks/Go/aah/setup.sh

@@ -4,28 +4,35 @@ fw_depends mysql go
 
 set -x
 
-mkdir bin
+mkdir -p bin
 
-# Install aah CLI tool and glide
-go get aahframework.org/tools.v0/aah
-curl https://glide.sh/get | sh
+# Install aah CLI tool (installing specific tag version)
+mkdir -p src/aahframework.org
+git clone https://github.com/go-aah/tools.git src/aahframework.org/tools.v0
+cd src/aahframework.org/tools.v0
+git checkout tags/v0.8 -b v0.8
+cd -
+go get aahframework.org/tools.v0/aah/...
+go install aahframework.org/tools.v0/aah
 
-# Clean src directory, glide is used to get dependencies libraries
-rm -rf src/aahframework.org
-rm -rf src/golang.org
+# print aah version
+aah -v
 
-# print version
-aah version
+# Install glide
+curl https://glide.sh/get | sh
 glide -v
 
+# Clean src directory, glide is used to get dependencies libraries
+rm -rf src/aahframework.org src/golang.org src/gopkg.in
+
 # Run glide to get dependencies
 cd src/benchmark
 glide install
 
 # Build and unpack
-aah build
+aah build -o build/benchmark.zip
 cd build
-unzip benchmark-0.0.1-linux-amd64.zip
+unzip benchmark.zip
 
 # Start server
 ./benchmark/aah.sh start

+ 1 - 0
frameworks/Go/aah/src/benchmark/.gitignore

@@ -3,6 +3,7 @@
 aah.go
 *.pid
 build/
+vendor/*/
 
 # Compiled Object files, Static and Dynamic libs (Shared Objects)
 *.o

+ 10 - 0
frameworks/Go/aah/src/benchmark/app/controllers/app.go

@@ -92,3 +92,13 @@ func (a *AppController) handleResult(worlds *[]models.World, err error) {
 	}
 	a.Reply().JSON(worlds)
 }
+
+// TFB request has incorrect Host header i.e. `Host: TFB-Server`
+// Correct Host header is `Host: TFB-server:8080`
+func onRequestEvent(e *aah.Event) {
+	e.Data.(*aah.Context).Req.Host = "TFB-Server:8080"
+}
+
+func init() {
+	aah.OnRequest(onRequestEvent)
+}

+ 52 - 22
frameworks/Go/aah/src/benchmark/config/aah.conf

@@ -12,6 +12,11 @@ name = "benchmark"
 # Friendly description of application
 desc = "aah framework web application"
 
+# Configure file path of application PID file to be written.
+# Ensure application has appropriate permission and directory exists.
+# Default value is `<app-base-dir>/<app-binary-name>.pid`
+#pid_file = "/path/to/pidfile.pid"
+
 # -----------------------------------------------------------------
 # Server configuration - HTTP
 # Doc: https://docs.aahframework.org/app-config.html#section-server
@@ -25,6 +30,10 @@ server {
   # Default value is 8080.
   #port = ""
 
+  # Header value written as `Server` HTTP header.
+  # If you do not want to include `Server` header, comment it out.
+  header = "aah-go-server"
+
   # Valid time units are "s = seconds", "m = minutes"
   timeout {
     # mapped to `http.Server.ReadTimeout`.
@@ -100,6 +109,30 @@ server {
       #cache_dir = "/Users/jeeva/autocert"
     }
   }
+
+  # To manage aah server effectively it is necessary to know details about the
+  # request, response, processing time, client IP address, etc. aah framework
+  # provides the flexible and configurable access log capabilities.
+  access_log {
+    # Enabling server access log
+    # Default value is `false`.
+    #enable = true
+
+    # Absolute path to access log file or relative path.
+    # Default location is application logs directory
+    #file = "{{ .AppName }}-access.log"
+
+    # Default server access log pattern
+    #pattern = "%clientip %custom:- %reqtime %reqmethod %requrl %reqproto %resstatus %ressize %restime %reqhdr:referer"
+
+    # Access Log channel buffer size
+    # Default value is `500`.
+    #channel_buffer_size = 500
+
+    # Include static files access log too.
+    # Default value is `true`.
+    #static_file = false
+  }
 }
 
 # ------------------------------------------------------------------
@@ -139,11 +172,15 @@ i18n {
 # Doc: https://docs.aahframework.org/app-config.html#section-format
 # -----------------------------------------------------------------
 format {
-  # Default value is `2006-01-02`.
-  #date = "2006-01-02"
-
-  # Default value is `2006-01-02 15:04:05`.
-  #datetime = "2006-01-02 15:04:05"
+  # Time format for auto parse and bind. aah tries to parse the
+  # time value in the order they defined till it gets success
+  # otherwise returns the error.
+  time = [
+    "2006-01-02T15:04:05Z07:00",
+    "2006-01-02T15:04:05Z",
+    "2006-01-02 15:04:05",
+    "2006-01-02"
+  ]
 }
 
 # ------------------------------------------------------------------
@@ -161,19 +198,6 @@ runtime {
     # Default value is `false`.
     #all_goroutines = true
   }
-
-  # Pooling configuration is to reduce GC overhead from framework.
-  # Tune these value based on your use case. Pool doesn't create object
-  # unless it's needed.
-  # Doc: https://docs.aahframework.org/pooling.html
-  pooling {
-    # Default value is `500`.
-    global = 5000
-
-    # Used for `bytes.Buffer`
-    # Default value is `200`.
-    buffer = 1500
-  }
 }
 
 # -----------------------------------------------------------------
@@ -277,11 +301,17 @@ view {
 
 # DataSource config
 datasource {
-    benchmark {
-      driver = "mysql"
-      url = "benchmarkdbuser:benchmarkdbpass@tcp(%s:3306)/hello_world"
-    }
+  benchmark {
+    driver = "mysql"
+    url = "benchmarkdbuser:benchmarkdbpass@tcp(%s:3306)/hello_world"
   }
+}
+
+# --------------------------------------------------------------
+# Application Security
+# Doc: https://docs.aahframework.org/security-config.html
+# --------------------------------------------------------------
+include "./security.conf"
 
 # --------------------------------------------------------------
 # Environment Profiles e.g.: dev, qa, prod

+ 9 - 64
frameworks/Go/aah/src/benchmark/config/security.conf

@@ -12,72 +12,17 @@ security {
   # Doc: https://docs.aahframework.org/security-config.html#section-session
   # -----------------------------------------------------------------------
   session {
-    # Session mode to choose whether HTTP session should be persisted or
-    # destroyed at the end of the request. Supported values are `stateless`
-    # and `stateful`.
-    # Default value is `stateless` for API and `stateful` for Web app.
-    #mode = "stateful"
 
-    # Session store is to choose where session value should be persisted.
-    store {
-      # Currently aah framework supports `cookie` and `file` as store type.
-      # Also framework provide extensible `session.Storer` interface to
-      # add custom session store.
-      # Default value is `cookie`.
-      type = "cookie"
-
-      
-    }
-
-    # Session ID length
-    # Default value is `32`.
-    #id_length = 32
-
-    # Time-to-live for session data. Valid time units are "m = minutes",
-    # "h = hours" and 0.
-    # Default value is `0`, cookie is deleted when the browser is closed.
-    #ttl = "0"
-
-    # Session cookie name prefix.
-    # Default value is `aah` For e.g.: `aah_session`
-    #prefix = "aah"
-
-    # Default value is `empty` string.
-    #domain = ""
-
-    # Default value is `/`.
-    #path = "/"
-
-    # HTTP session cookie HTTPOnly value. This option prevents XSS
-    # (Cross Site Scripting) attacks.
-    # Default value is `true`.
-    #http_only = true
-
-    # HTTP session cookie secure value.
-    # However if aah server is not configured with SSL then
-    # framework sets this value as false
-    # Default value is `true`.
-    #secure = true
-
-    # HTTP session cookie value signing using `HMAC`. For server farm this
-    # should be same in all instance. For HMAC sign & verify it recommend to use
-    # key size is `32` or `64` bytes.
-    # Default value is `64` bytes (generated when application gets created
-    # using `aah new` command).
-    sign_key = "74cb9e6a73a7d41c76b0d145e18bc41c74484fe71d16ee148ef5612aa8c3078b"
+  }
 
-    # HTTP session cookie value encryption and decryption using `AES`. For server
-    # farm this should be same in all instance. AES algorithm is used, valid
-    # lengths are `16`, `24`, or `32` bytes to select `AES-128`, `AES-192`, or `AES-256`.
-    # Default value is `32` bytes (generated when application gets created
-    # using `aah new` command).
-    enc_key = "b318415ff2b65b03332e822e1101cf53"
+  # ---------------------------------------------------------------------------
+  # HTTP Secure Header(s)
+  # Application security headers with many safe defaults.
+  # Doc: https://docs.aahframework.org/security-config.html#section-http-header
+  #
+  # Tip: Quick way to verify secure headers - https://securityheaders.io
+  # ---------------------------------------------------------------------------
+  http_header {
 
-    # Cleanup Interval is used to clean the expired session objects from store.
-    # This is only applicable for non-cookie store type.
-    # Cleanup performed in dedicated goroutine. Valid time units are
-    # `m -> minutes`, `h -> hours`.
-    # Default value is `30m`.
-    #cleanup_interval = "30m"
   }
 }

+ 21 - 15
frameworks/Go/aah/src/benchmark/glide.lock

@@ -1,39 +1,45 @@
-hash: 8a2f4a09267a0af0254fb9e9328c1b6dbd69fa526243254f5d13f790effb76dd
-updated: 2017-06-08T04:39:51.485650163Z
+hash: b59c0b33b5d6504b9f21d3f99163f8c8a21e4b450399cf7ea730920d982c1756
+updated: 2017-09-03T00:28:05.557966684Z
 imports:
 - name: aahframework.org/aah.v0
-  version: e577358978ee343da0347e3d5e3ddf6a320be794
+  version: 12414997d4457838756dcb53e2e3b6a184d4950f
 - name: aahframework.org/ahttp.v0
-  version: e15ece4bedd71ec9c49e412e4bc6c7681a7a7e5d
+  version: f9b651b8092ec7477d4349bce07eb95c482306c8
 - name: aahframework.org/aruntime.v0
   version: 3368d72836c245d93409bcf73e2eb5e74cf02767
 - name: aahframework.org/config.v0
-  version: c13836cc8b02b1667856aaa929167c680be3e9d6
+  version: 5e0e808cbd7cfa9a9b51c26adb2af891bd73ccda
 - name: aahframework.org/essentials.v0
-  version: a3d81313d1d8f7061f2a380f30367beb9fcd11db
+  version: cf06313c993843e9affb565fde6177ccd1807921
 - name: aahframework.org/forge.v0
   version: 9f3b186d1c58fb40060cc9783d990d3a9c5e0176
   subpackages:
   - token
 - name: aahframework.org/i18n.v0
-  version: 6089355055bb15109f7f3aefb8efd2a955115d6d
+  version: 8558a9d1e89af246eda371c0b0e66e83b12dbded
 - name: aahframework.org/log.v0
-  version: f32cca084e451e2f811eb2d82bc8cd5636741f66
-- name: aahframework.org/pool.v0
-  version: b334c816f1647832a73e84af41c828171b24324c
+  version: a6c07023e1cb69de3f987f2bd90be33446b5ba0e
 - name: aahframework.org/router.v0
-  version: f490947101db8d646cc36d045548a32350f56243
+  version: 14ed79c8c87d3e368633b67ba37010f2d3d6c12a
 - name: aahframework.org/security.v0
-  version: e37fb86ca4b437b6af01212318123bb43f27aa5f
+  version: 308ebec6eab3744c83df77637c30adff959dc782
   subpackages:
+  - acrypto
+  - authc
+  - authz
+  - scheme
   - session
+- name: aahframework.org/valpar.v0
+  version: b66ffe09843404678baecd85d7d0401ea7d9e8f3
 - name: aahframework.org/view.v0
-  version: 3f4c1cf783430edeefb8cbdc98f11128f6595318
+  version: 38179594120f15376a4d8305ccc87645f5a88637
 - name: github.com/go-sql-driver/mysql
-  version: e3f0fdcf52770a162d5a4540ddb8d9957ff456d1
+  version: 26471af196a17ee75a22e6481b5a5897fb16b081
 - name: golang.org/x/crypto
-  version: e7ba82683099cae71475961448ab8f903ea77c26
+  version: 81e90905daefcd6fd217b62423c0908922eadb30
   subpackages:
   - acme
   - acme/autocert
+  - bcrypt
+  - blowfish
 testImports: []

+ 1 - 1
frameworks/Go/aah/src/benchmark/glide.yaml

@@ -1,5 +1,5 @@
 package: benchmark
 import:
 - package: aahframework.org/aah.v0
-  version: ^v0.6
+  version: ^v0.8
 - package: github.com/go-sql-driver/mysql