Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
PID = .pid
GO_FILES = $(shell find . -type f -name "*.go")
GONODE_MODULES = $(shell ls -d ./modules/* | grep -v go)
GONODE_CORE = $(shell ls -d ./core/* | grep -v go)
GONODE_FUNC_TESTS = $(shell ls -d ./test/modules/* | grep -v go)

GO_PATH = $(shell go env GOPATH)
Expand Down Expand Up @@ -53,7 +54,7 @@ format:
go fix ./...

test-backend: bin
go test $(GONODE_MODULES) $(GONODE_FUNC_TESTS) ./core ./commands/server
go test $(GONODE_CORE) $(GONODE_MODULES) $(GONODE_FUNC_TESTS) ./commands/server
go vet ./...

test-frontend:
Expand Down
8 changes: 4 additions & 4 deletions commands/dev/dev_list_node_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"github.com/rande/goapp"

"github.com/rande/gonode/commands/server"
"github.com/rande/gonode/core"
"github.com/rande/gonode/core/config"
"github.com/rande/gonode/modules/api"
"github.com/rande/gonode/modules/config"
"github.com/rande/gonode/modules/base"

"fmt"
)
Expand Down Expand Up @@ -55,10 +55,10 @@ func (c *DevListNodeTypesCommand) Run(args []string) int {

l.Run(func(app *goapp.App, state *goapp.GoroutineState) error {

handlers := app.Get("gonode.handler_collection").(core.HandlerCollection)
handlers := app.Get("gonode.handler_collection").(base.HandlerCollection)

for _, k := range handlers.GetKeys() {
c.Ui.Info(fmt.Sprintf(" > % -40s - %T", k, handlers.GetByCode(k)))
c.Ui.Info(fmt.Sprintf(" > %-40s - %T", k, handlers.GetByCode(k)))
}

c.Ui.Info(fmt.Sprintf("Found %d node types", len(app.GetKeys())))
Expand Down
2 changes: 1 addition & 1 deletion commands/dev/dev_list_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/rande/gonode/modules/api"

"fmt"
"github.com/rande/gonode/modules/config"
"github.com/rande/gonode/core/config"
)

type DevListServicesCommand struct {
Expand Down
16 changes: 8 additions & 8 deletions commands/server/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import (
"net/http"

log "github.com/Sirupsen/logrus"
"github.com/rande/gonode/core/bindata"
"github.com/rande/gonode/core/config"
"github.com/rande/gonode/core/logger"
"github.com/rande/gonode/core/router"
"github.com/rande/gonode/core/security"
"github.com/rande/gonode/modules/api"
"github.com/rande/gonode/modules/bindata"
"github.com/rande/gonode/modules/config"
"github.com/rande/gonode/modules/base"
"github.com/rande/gonode/modules/guard"
"github.com/rande/gonode/modules/logger"
"github.com/rande/gonode/modules/node"
"github.com/rande/gonode/modules/prism"
"github.com/rande/gonode/modules/router"
"github.com/rande/gonode/modules/search"
"github.com/rande/gonode/modules/security"
"github.com/rande/gonode/modules/setup"
"github.com/zenazn/goji/bind"
"github.com/zenazn/goji/graceful"
Expand Down Expand Up @@ -69,10 +69,10 @@ func (c *ServerCommand) Run(args []string) int {
security.ConfigureServer(l, conf)
search.ConfigureServer(l, conf)
api.ConfigureServer(l, conf)
guard.ConfigureServer(l, conf)
node_guard.ConfigureServer(l, conf)
prism.ConfigureServer(l, conf)
router.ConfigureServer(l, conf)
node.ConfigureServer(l, conf)
base.ConfigureServer(l, conf)

// must be last for now
bindata.ConfigureServer(l, conf)
Expand Down
42 changes: 21 additions & 21 deletions commands/server/cli_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import (
sq "github.com/lann/squirrel"
pq "github.com/lib/pq"
"github.com/rande/goapp"
"github.com/rande/gonode/core"
"github.com/rande/gonode/core/config"
"github.com/rande/gonode/core/vault"
"github.com/rande/gonode/modules/api"
"github.com/rande/gonode/modules/base"
"github.com/rande/gonode/modules/blog"
"github.com/rande/gonode/modules/config"
"github.com/rande/gonode/modules/debug"
"github.com/rande/gonode/modules/feed"
"github.com/rande/gonode/modules/media"
"github.com/rande/gonode/modules/raw"
"github.com/rande/gonode/modules/search"
"github.com/rande/gonode/modules/user"
"github.com/rande/gonode/modules/vault"
"github.com/zenazn/goji/web"
"github.com/zenazn/goji/web/middleware"
"net/http"
Expand Down Expand Up @@ -68,7 +68,7 @@ func ConfigureServer(l *goapp.Lifecycle, conf *config.ServerConfig) {
})

app.Set("gonode.handler_collection", func(app *goapp.App) interface{} {
return core.HandlerCollection{
return base.HandlerCollection{
"default": &debug.DefaultHandler{},
"media.image": &media.ImageHandler{
Vault: app.Get("gonode.vault.fs").(*vault.Vault),
Expand All @@ -83,16 +83,16 @@ func ConfigureServer(l *goapp.Lifecycle, conf *config.ServerConfig) {
})

app.Set("gonode.view_handler_collection", func(app *goapp.App) interface{} {
return core.ViewHandlerCollection{
return base.ViewHandlerCollection{
"default": &debug.DefaultViewHandler{},
"core.index": &search.IndexViewHandler{
Search: app.Get("gonode.search.pgsql").(*search.SearchPGSQL),
Manager: app.Get("gonode.manager").(*core.PgNodeManager),
Manager: app.Get("gonode.manager").(*base.PgNodeManager),
MaxResult: 128,
},
"feed.index": &feed.FeedViewHandler{
Search: app.Get("gonode.search.pgsql").(*search.SearchPGSQL),
Manager: app.Get("gonode.manager").(*core.PgNodeManager),
Manager: app.Get("gonode.manager").(*base.PgNodeManager),
},
"core.raw": &raw.RawViewHandler{},
"media.image": &media.MediaViewHandler{
Expand All @@ -104,11 +104,11 @@ func ConfigureServer(l *goapp.Lifecycle, conf *config.ServerConfig) {
})

app.Set("gonode.manager", func(app *goapp.App) interface{} {
return &core.PgNodeManager{
return &base.PgNodeManager{
Logger: app.Get("logger").(*log.Logger),
Db: app.Get("gonode.postgres.connection").(*sql.DB),
ReadOnly: false,
Handlers: app.Get("gonode.handler_collection").(core.Handlers),
Handlers: app.Get("gonode.handler_collection").(base.Handlers),
Prefix: conf.Databases["master"].Prefix,
}
})
Expand All @@ -134,22 +134,22 @@ func ConfigureServer(l *goapp.Lifecycle, conf *config.ServerConfig) {

app.Set("gonode.api", func(app *goapp.App) interface{} {
return &api.Api{
Manager: app.Get("gonode.manager").(*core.PgNodeManager),
Manager: app.Get("gonode.manager").(*base.PgNodeManager),
Version: "1.0.0",
Serializer: app.Get("gonode.node.serializer").(*core.Serializer),
Serializer: app.Get("gonode.node.serializer").(*base.Serializer),
Logger: app.Get("logger").(*log.Logger),
}
})

app.Set("gonode.node.serializer", func(app *goapp.App) interface{} {
s := core.NewSerializer()
s.Handlers = app.Get("gonode.handler_collection").(core.Handlers)
s := base.NewSerializer()
s.Handlers = app.Get("gonode.handler_collection").(base.Handlers)

return s
})

app.Set("gonode.postgres.subscriber", func(app *goapp.App) interface{} {
return core.NewSubscriber(
return base.NewSubscriber(
conf.Databases["master"].DSN,
app.Get("logger").(*log.Logger),
)
Expand All @@ -175,27 +175,27 @@ func ConfigureServer(l *goapp.Lifecycle, conf *config.ServerConfig) {

l.Prepare(func(app *goapp.App) error {
// need to find a way to trigger the handler registration
sub := app.Get("gonode.postgres.subscriber").(*core.Subscriber)
sub := app.Get("gonode.postgres.subscriber").(*base.Subscriber)

sub.ListenMessage("media_youtube_update", func(app *goapp.App) core.SubscriberHander {
manager := app.Get("gonode.manager").(*core.PgNodeManager)
sub.ListenMessage("media_youtube_update", func(app *goapp.App) base.SubscriberHander {
manager := app.Get("gonode.manager").(*base.PgNodeManager)
listener := app.Get("gonode.listener.youtube").(*media.YoutubeListener)

return func(notification *pq.Notification) (int, error) {
return listener.Handle(notification, manager)
}
}(app))

sub.ListenMessage("media_file_download", func(app *goapp.App) core.SubscriberHander {
manager := app.Get("gonode.manager").(*core.PgNodeManager)
sub.ListenMessage("media_file_download", func(app *goapp.App) base.SubscriberHander {
manager := app.Get("gonode.manager").(*base.PgNodeManager)
listener := app.Get("gonode.listener.file_downloader").(*media.ImageDownloadListener)

return func(notification *pq.Notification) (int, error) {
return listener.Handle(notification, manager)
}
}(app))

sub.ListenMessage("core_sleep", func(app *goapp.App) core.SubscriberHander {
sub.ListenMessage("core_sleep", func(app *goapp.App) base.SubscriberHander {
return func(notification *pq.Notification) (int, error) {

logger := app.Get("logger").(*log.Logger)
Expand All @@ -208,7 +208,7 @@ func ConfigureServer(l *goapp.Lifecycle, conf *config.ServerConfig) {

logger.Printf("[core_sleep] wake up ...")

return core.PubSubListenContinue, nil
return base.PubSubListenContinue, nil
}
}(app))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/flosch/pongo2"
"github.com/rande/goapp"
"github.com/rande/gonode/assets"
"github.com/rande/gonode/modules/config"
"github.com/rande/gonode/core/config"
"github.com/zenazn/goji/web"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions core/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// The documentation should go there ...

package node
16 changes: 10 additions & 6 deletions modules/guard/guard.go → core/guard/guard.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,31 @@ type GuardAuthenticator interface {
// This method is call on each request.
// If the method return nil as interface{} value, it means the authenticator
// cannot handle the request
getCredentials(req *http.Request) (interface{}, error)
GetCredentials(req *http.Request) (interface{}, error)

// Return the user from the credentials
getUser(credentials interface{}) (GuardUser, error)
GetUser(credentials interface{}) (GuardUser, error)

// Check if the provided credentials are valid for the current user
checkCredentials(credentials interface{}, user GuardUser) error
CheckCredentials(credentials interface{}, user GuardUser) error

// Return a security token related to the user
createAuthenticatedToken(u GuardUser) (GuardToken, error)
CreateAuthenticatedToken(u GuardUser) (GuardToken, error)

// Action when the authentication fail.
// On a default form login, it can be used to redirect the user to login page
// return true if the workflows must be stopped (ie, the authenticator was written
// bytes on the response. false if not.
onAuthenticationFailure(req *http.Request, res http.ResponseWriter, err error) bool
OnAuthenticationFailure(req *http.Request, res http.ResponseWriter, err error) bool

// Action when the authentication success
// On a default form login, it can be used to redirect the user to protected page
// or the homepage
// return true if the workflows must be stopped (ie, the authenticator was written
// bytes on the response. false if not.
onAuthenticationSuccess(req *http.Request, res http.ResponseWriter, token GuardToken) bool
OnAuthenticationSuccess(req *http.Request, res http.ResponseWriter, token GuardToken) bool
}

type GuardManager interface {
GetUser(username string) (GuardUser, error)
}
Loading