Refactor JWT implementation
This commit is contained in:
@@ -7,34 +7,37 @@ import (
|
||||
"github.com/cortezaproject/corteza-server/pkg/auth"
|
||||
)
|
||||
|
||||
func MountRoutes(r chi.Router) {
|
||||
var (
|
||||
namespace = Namespace{}.New()
|
||||
module = Module{}.New()
|
||||
record = Record{}.New()
|
||||
page = Page{}.New()
|
||||
chart = Chart{}.New()
|
||||
notification = Notification{}.New()
|
||||
attachment = Attachment{}.New()
|
||||
automation = Automation{}.New()
|
||||
)
|
||||
func MountRoutes(mv auth.MiddlewareValidator) func(r chi.Router) {
|
||||
return func(r chi.Router) {
|
||||
var (
|
||||
namespace = Namespace{}.New()
|
||||
module = Module{}.New()
|
||||
record = Record{}.New()
|
||||
page = Page{}.New()
|
||||
chart = Chart{}.New()
|
||||
notification = Notification{}.New()
|
||||
attachment = Attachment{}.New()
|
||||
automation = Automation{}.New()
|
||||
)
|
||||
|
||||
// Initialize handlers & controllers.
|
||||
r.Group(func(r chi.Router) {
|
||||
// Use alternative handlers that support file serving
|
||||
handlers.NewAttachment(attachment).MountRoutes(r)
|
||||
})
|
||||
// Initialize handlers & controllers.
|
||||
r.Group(func(r chi.Router) {
|
||||
// Use alternative handlers that support file serving
|
||||
handlers.NewAttachment(attachment).MountRoutes(r)
|
||||
})
|
||||
|
||||
// Protect all _private_ routes
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(auth.MiddlewareValidOnly)
|
||||
handlers.NewPermissions(Permissions{}.New()).MountRoutes(r)
|
||||
handlers.NewNamespace(namespace).MountRoutes(r)
|
||||
handlers.NewPage(page).MountRoutes(r)
|
||||
handlers.NewAutomation(automation).MountRoutes(r)
|
||||
handlers.NewModule(module).MountRoutes(r)
|
||||
handlers.NewRecord(record).MountRoutes(r)
|
||||
handlers.NewChart(chart).MountRoutes(r)
|
||||
handlers.NewNotification(notification).MountRoutes(r)
|
||||
})
|
||||
// Protect all _private_ routes
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(mv.HttpValidator("api"))
|
||||
|
||||
handlers.NewPermissions(Permissions{}.New()).MountRoutes(r)
|
||||
handlers.NewNamespace(namespace).MountRoutes(r)
|
||||
handlers.NewPage(page).MountRoutes(r)
|
||||
handlers.NewAutomation(automation).MountRoutes(r)
|
||||
handlers.NewModule(module).MountRoutes(r)
|
||||
handlers.NewRecord(record).MountRoutes(r)
|
||||
handlers.NewChart(chart).MountRoutes(r)
|
||||
handlers.NewNotification(notification).MountRoutes(r)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
3
compose/types/locale.gen.go
generated
3
compose/types/locale.gen.go
generated
@@ -14,9 +14,8 @@ package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/locale"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
16
compose/types/type_labels.gen.go
generated
16
compose/types/type_labels.gen.go
generated
@@ -57,17 +57,17 @@ func (m Module) LabelResourceID() uint64 {
|
||||
}
|
||||
|
||||
// SetLabel adds new label to label map
|
||||
func (f *ModuleField) SetLabel(key string, value string) {
|
||||
if f.Labels == nil {
|
||||
f.Labels = make(map[string]string)
|
||||
func (m *ModuleField) SetLabel(key string, value string) {
|
||||
if m.Labels == nil {
|
||||
m.Labels = make(map[string]string)
|
||||
}
|
||||
|
||||
f.Labels[key] = value
|
||||
m.Labels[key] = value
|
||||
}
|
||||
|
||||
// GetLabels adds new label to label map
|
||||
func (f ModuleField) GetLabels() map[string]string {
|
||||
return f.Labels
|
||||
func (m ModuleField) GetLabels() map[string]string {
|
||||
return m.Labels
|
||||
}
|
||||
|
||||
// GetLabels adds new label to label map
|
||||
@@ -76,8 +76,8 @@ func (ModuleField) LabelResourceKind() string {
|
||||
}
|
||||
|
||||
// GetLabels adds new label to label map
|
||||
func (f ModuleField) LabelResourceID() uint64 {
|
||||
return f.ID
|
||||
func (m ModuleField) LabelResourceID() uint64 {
|
||||
return m.ID
|
||||
}
|
||||
|
||||
// SetLabel adds new label to label map
|
||||
|
||||
Reference in New Issue
Block a user