Resource-Based Access
How to enable the editor for relationship-based access control (ReBAC) and declare a migration with the migration system.
package main
import (
"context"
"log/slog"
"time"
"github.com/worldiety/option"
"go.wdy.de/nago/application"
cfgflow "go.wdy.de/nago/application/flow/cfg"
cfginspector "go.wdy.de/nago/application/inspector/cfg"
"go.wdy.de/nago/application/migration"
cfgmigration "go.wdy.de/nago/application/migration/cfg"
cfgrebac "go.wdy.de/nago/application/rebac/cfg"
"go.wdy.de/nago/application/user"
"go.wdy.de/nago/presentation/core"
"go.wdy.de/nago/presentation/ui"
"go.wdy.de/nago/web/vuejs"
)
func main() {
application.Configure(func(cfg *application.Configurator) {
cfg.SetApplicationID("de.worldiety.tutorial_88")
cfg.Serve(vuejs.Dist())
option.MustZero(cfg.StandardSystems())
option.Must(option.Must(cfg.UserManagement()).UseCases.EnableBootstrapAdmin(time.Now().Add(time.Hour), "%6UbRsCuM8N$auy"))
cfg.SetDecorator(cfg.NewScaffold().Decorator())
option.Must(cfginspector.Enable(cfg))
modMig := option.Must(cfgmigration.Enable(cfg)) // see, we have a migration system
_, _ = cfg.RDB() // see, we have a rebac system, this is the database and it is always available ...
option.Must(cfgrebac.Enable(cfg)) // ... but at least the UI for it is optional
option.Must(cfgflow.Enable(cfg, cfgflow.Options{}))
option.MustZero(modMig.Migrations.Declare(MyTestMigration{}, migration.Options{}))
cfg.RootViewWithDecoration(".", func(wnd core.Window) core.View {
dsp, ok := core.FromContext[user.DisplayName](wnd.Context(), "")
if !ok {
return ui.Text("no display name service")
}
return ui.Text("hello world " + dsp(wnd.Subject().ID()).Displayname)
})
}).Run()
}
type MyTestMigration struct {
}
func (m MyTestMigration) Version() migration.Version {
return migration.NewVersion(2026, time.January, 14, 16, 19, "TestMigration")
}
func (m MyTestMigration) Migrate(ctx context.Context) error {
slog.Info("executed")
return nil
}
View on GitHub ↗
· run it with go run go.wdy.de/nago/example/cmd/tutorial-88-resource-based-access@latest