Skip to content

Commit

Permalink
Merge pull request #12 for v0.9 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm authored Oct 4, 2017
2 parents c4aa79e + 0063968 commit b4b4069
Show file tree
Hide file tree
Showing 20 changed files with 775 additions and 185 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Home of all aah framework CLI tools.
## aah CLI Tool
[![Build Status](https://travis-ci.org/go-aah/tools.svg?branch=master)](https://travis-ci.org/go-aah/tools) [![Go Report Card](https://goreportcard.com/badge/aahframework.org/tools.v0)](https://goreportcard.com/report/aahframework.org/tools.v0/aah)
[![Powered by Go](https://img.shields.io/badge/powered_by-go-blue.svg)](https://golang.org)
[![Version](https://img.shields.io/badge/version-0.8-blue.svg)](https://github.com/go-aah/tools/releases/latest)
[![Version](https://img.shields.io/badge/version-0.9-blue.svg)](https://github.com/go-aah/tools/releases/latest)
[![License](https://img.shields.io/github/license/go-aah/tools.svg)](LICENSE) [![Twitter](https://img.shields.io/badge/twitter-@aahframework-55acee.svg)](https://twitter.com/aahframework)

***Release [v0.8](https://github.com/go-aah/tools/releases/latest) tagged on Sep 01, 2017***
***Release [v0.9](https://github.com/go-aah/tools/releases/latest) tagged on Oct 04, 2017***

aah framework - A scalable, performant, rapid development Web framework for Go.

Expand Down
30 changes: 16 additions & 14 deletions aah/aah.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ import (
)

const (
aahImportPath = "aahframework.org/aah.v0"
aahCLIImportPath = "aahframework.org/tools.v0/aah"
permRWXRXRX = 0755
permRWRWRW = 0666
permRWXRXRX = 0755
permRWRWRW = 0666
versionSeries = "v0"
importPrefix = "aahframework.org"
)

var (
gopath string
gocmd string
gosrcDir string

libNames = []string{"aah", "ahttp", "aruntime", "config", "essentials", "forge", "i18n",
"log", "router", "security", "test", "tools", "valpar", "view"}

// abstract it, so we can do unit test
fatal = log.Fatal
fatalf = log.Fatalf
Expand Down Expand Up @@ -102,6 +105,7 @@ func main() {
buildCmd,
listCmd,
cleanCmd,
switchCmd,
}

sort.Sort(cli.FlagsByName(app.Flags))
Expand All @@ -113,7 +117,7 @@ func main() {
//___________________________________

func printHeader(c *cli.Context) error {
hdr := fmt.Sprintf("aah framework v%s - https://aahframework.org", aah.Version)
hdr := fmt.Sprintf("aah framework v%s - https://aahframework.org", aah.Version)
improveRpt := "# Report improvements/bugs at https://github.com/go-aah/aah/issues #"
cnt := len(improveRpt)
sp := (cnt - len(hdr)) / 2
Expand All @@ -122,13 +126,13 @@ func printHeader(c *cli.Context) error {
fmt.Fprintf(c.App.Writer, "\033[1;32m")
}

printChr(c.App.Writer, "", cnt)
printChr(c.App.Writer, "", cnt)
fmt.Fprintf(c.App.Writer, "\n")
printChr(c.App.Writer, " ", sp)
fmt.Fprintf(c.App.Writer, hdr)
printChr(c.App.Writer, " ", sp)
fmt.Fprintf(c.App.Writer, "\n")
printChr(c.App.Writer, "", cnt)
printChr(c.App.Writer, "_", cnt)
fmt.Fprintf(c.App.Writer, "\n")

if !isWindowsOS() {
Expand Down Expand Up @@ -158,18 +162,16 @@ func init() {

cli.VersionPrinter = func(c *cli.Context) {
_ = printHeader(c)
fmt.Fprint(c.App.Writer, "Version(s):\n")
fmt.Fprint(c.App.Writer, "Version Info:\n")
fmt.Fprintf(c.App.Writer, "\t%-17s v%s\n", "aah framework", aah.Version)
fmt.Fprintf(c.App.Writer, "\t%-17s v%s\n", "aah cli tool", Version)
fmt.Fprintf(c.App.Writer, "\t%-17s %s\n", "Modules: ", strings.Join(
[]string{
"config v" + config.Version, "essentials v" + ess.Version,
"ahttp v" + ahttp.Version, "router v" + router.Version,
"security v" + security.Version}, ", "))
"ahttp v" + ahttp.Version, "aruntime v" + aruntime.Version, "config v" + config.Version,
"essentials v" + ess.Version, "i18n v" + i18n.Version, "log v" + log.Version}, ", "))
fmt.Fprintf(c.App.Writer, "\t%-17s %s\n", "", strings.Join(
[]string{"i18n v" + i18n.Version, "view v" + view.Version,
"log v" + log.Version, "test v" + test.Version,
"aruntime v" + aruntime.Version, "valpar v" + valpar.Version}, ", "))
[]string{"router v" + router.Version, "security v" + security.Version,
"test v" + test.Version, "valpar v" + valpar.Version, "view v" + view.Version}, ", "))
fmt.Println()
fmt.Fprintf(c.App.Writer, "\t%-17s %s\n", fmt.Sprintf("go[%s/%s]",
runtime.GOOS, runtime.GOARCH), runtime.Version()[2:])
Expand Down
15 changes: 11 additions & 4 deletions aah/app-template/aah.project.atmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ build {
# Default value is `false`.
#dep_get = true

# Log level is used for aah CLI tool logging.
# Default value is `info`.
#log_level = "info"

flags = ["-i"]

ldflags = ""
Expand All @@ -42,6 +38,17 @@ build {
excludes = ["*.go", "*_test.go", ".*", "*.bak", "*.tmp", "vendor", "app", "build", "tests", "logs"]
}

# Logger configuration for aah CLI tool.
log {
# Log level
# Default value is `info`.
#level = "info"

# Log colored output
# Default value is `true`.
#color = false
}

# Hot-Reload is development purpose to help developer.
# Read more about implementation here - https://github.com/go-aah/aah/issues/4
#
Expand Down
68 changes: 68 additions & 0 deletions aah/app-template/app/security/authentication_provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package security

import (
"aahframework.org/aah.v0"
"aahframework.org/config.v0"
"aahframework.org/security.v0/authc"
)

var _ authc.Authenticator = (*AuthenticationProvider)(nil)

// AuthenticationProvider struct implements `authc.Authenticator` interface.
type AuthenticationProvider struct {
}

// Init method initializes the AuthenticationProvider, this method gets called
// during server start up.
func (a *AuthenticationProvider) Init(cfg *config.Config) error {

// NOTE: Init is called on application startup

return nil
}

// GetAuthenticationInfo method is `authc.Authenticator` interface
func (a *AuthenticationProvider) GetAuthenticationInfo(authcToken *authc.AuthenticationToken) (*authc.AuthenticationInfo, error) {

//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
// This code snippet provided as a reference
//
// Call your appropriate datasource here (such as DB, API, LDAP, etc)
// to get the subject (aka user) authentication information.
//
// Form Auth Values from authcToken
// authcToken.Identity => username
// authcToken.Credential => passowrd
//_____________________________________________________________________

// user := models.FindUserByEmail(authcToken.Identity)
// if user == nil {
// // No subject exists, return nil and error
// return nil, authc.ErrSubjectNotExists
// }

// User found, now create authentication info and return to the framework
authcInfo := authc.NewAuthenticationInfo()
// authcInfo.Principals = append(authcInfo.Principals,
// &authc.Principal{
// Value: user.Email,
// IsPrimary: true,
// Realm: "inmemory",
// })
// authcInfo.Credential = []byte(user.Password)
// authcInfo.IsLocked = user.IsLocked
// authcInfo.IsExpired = user.IsExpried

return authcInfo, nil
}

func postAuthEvent(e *aah.Event) {
ctx := e.Data.(*aah.Context)

// Do post successful authentication actions...
_ = ctx
}

func init() {
aah.OnPostAuth(postAuthEvent)
}
43 changes: 43 additions & 0 deletions aah/app-template/app/security/authorization_provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package security

import (
"aahframework.org/config.v0"
"aahframework.org/security.v0/authc"
"aahframework.org/security.v0/authz"
)

var _ authz.Authorizer = (*AuthorizationProvider)(nil)

// AuthorizationProvider struct implements `authz.Authorizer` interface.
type AuthorizationProvider struct {
}

// Init method initializes the AuthorizationProvider, this method gets called
// during server start up.
func (a *AuthorizationProvider) Init(cfg *config.Config) error {

// NOTE: Init is called on application startup

return nil
}

// GetAuthorizationInfo method is `authz.Authorizer` interface.
//
// GetAuthorizationInfo method gets called after authentication is successful
// to get Subject's (aka User) access control information such as roles and permissions.
func (a *AuthorizationProvider) GetAuthorizationInfo(authcInfo *authc.AuthenticationInfo) *authz.AuthorizationInfo {
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
// This code snippet provided as a reference
//
// Call your appropriate datasource here (such as DB, API, etc)
// to get the subject (aka user) authorization details (roles, permissions)
//__________________________________________________________________________

// authorities := models.FindUserByEmail(authcInfo.PrimaryPrincipal().Value)

authzInfo := authz.NewAuthorizationInfo()
// authzInfo.AddRole(authorities.Roles...)
// authzInfo.AddPermissionString(authorities.Permissions...)

return authzInfo
}
66 changes: 60 additions & 6 deletions aah/app-template/config/aah.conf.atmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ name = "{{ .AppName }}"
# Friendly description of application
desc = "aah framework {{ .AppType }} application"

# Application instance name is used when you're running aah application cluster.
# This value is used in the context based logging, it distinguishes your instance
# log from other instances.
#
# Typically you can to pass `instance_name` value via aah external config
# support or Environment variable.
instance_name = $AAH_INSTANCE_NAME

# 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`
Expand All @@ -26,7 +34,7 @@ server {
# Default value is `empty` string.
#address = ""

# For port `80` and `443`, put empty string or a value
# For standard port `80` and `443`, put empty string or a value
# Default value is 8080.
#port = ""

Expand Down Expand Up @@ -79,6 +87,27 @@ server {
# Default value is `false`.
#disable_http2 = true

# Redirect HTTP => HTTPS functionality does protocol switch, so it works
# with domain and subdomains.
# For example:
# http://aahframework.org => https://aahframework.org
# http://www.aahframework.org => https://www.aahframework.org
# http://docs.aahframework.org => https://docs.aahframework.org
redirect_http {
# Enabling HTTP => HTTPS redirects.
# Default is value is `false`.
#enable = true

# Port no. of HTTP requests to listen.
# For standard port `80` put empty string or a value.
# It is required value, no default.
port = "8080"

# Redirect code
# Default value is `307`.
#code = 307
}

lets_encrypt {
# To get SSL certificate from Let's Encrypt CA, enable it.
# Don't forget to enable `server.ssl.enable=true`.
Expand Down Expand Up @@ -117,9 +146,12 @@ server {
}
}

# --------------------------------------------------------------------------
# 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.
# Doc: https://docs.aahframework.org/server-access-log.html
# --------------------------------------------------------------------------
access_log {
# Enabling server access log
# Default value is `false`.
Expand All @@ -140,6 +172,31 @@ server {
# Default value is `true`.
#static_file = false
}

# -------------------------------------------------------
# Dump Request & Response Details
# Such as URL, Proto, Headers, Body, etc.
# Note: Dump is not applicable for Static Files delivery.
# Doc: https://docs.aahframework.org/server-dump-log.html
# -------------------------------------------------------
dump_log {
# Default value is `false`.
#enable = true

# Absolute path to dump log file or relative path.
# Default location is application logs directory
#file = "{{ .AppName }}-dump.log"

# Log Request body into dump log. aah dumps body for JSON, XML, Form
# HTML and Plain Text content types.
# Default value is `false`.
#request_body = true

# Log Request body into dump log. aah dumps body for JSON, XML, Form
# HTML, and Plain Text content types.
# Default value is `false`.
#response_body = true
}
}

# ------------------------------------------------------------------
Expand All @@ -148,7 +205,7 @@ server {
# ------------------------------------------------------------------
request {
# aah framework encourages to have unique `Request Id` for each incoming
# request, it helps in traceability. If request has already `X-Request-Id`
# request, it helps in traceability. If request has already `sX-Request-Id`
# HTTP header then it does not generate one.
id {
# Default value is `true`.
Expand Down Expand Up @@ -212,7 +269,6 @@ request {
#tag_name = "bind"
}
}

{{ if eq .AppType "web" -}}
# ---------------------------------------------------------------
# i18n configuration
Expand Down Expand Up @@ -309,7 +365,6 @@ render {
#level = 4
}
}

{{ if eq .AppType "web" -}}
# ------------------------------------------------------------------
# Cache configuration
Expand Down Expand Up @@ -369,8 +424,7 @@ view {
# So option to disable the default layout for HTML.
# Default value is `true`. Available since v0.6
#default_layout = false
}
{{- end }}
}{{ end }}

# --------------------------------------------------------------
# Application Security
Expand Down
Loading

0 comments on commit b4b4069

Please sign in to comment.