From f2ba98bf4a4b9ee13ddf2e1602e67706245d00d5 Mon Sep 17 00:00:00 2001 From: Mickael Kerjean Date: Sat, 15 Jan 2022 15:36:56 +1100 Subject: [PATCH] documentation (authorisation): example of authorisation plugin --- .../plugin/plg_authorisation_example/index.go | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 server/plugin/plg_authorisation_example/index.go diff --git a/server/plugin/plg_authorisation_example/index.go b/server/plugin/plg_authorisation_example/index.go new file mode 100644 index 00000000..4368e95f --- /dev/null +++ b/server/plugin/plg_authorisation_example/index.go @@ -0,0 +1,46 @@ +package plg_authorisation_example + +import ( + . "github.com/mickael-kerjean/filestash/server/common" +) + +func init() { + Hooks.Register.AuthorisationMiddleware(AuthM{}) +} + +type AuthM struct{} + +func (this AuthM) Ls(ctx App, path string) error { + Log.Stdout("LS %+v", ctx.Session) + return nil +} + +func (this AuthM) Cat(ctx App, path string) error { + Log.Stdout("CAT %+v", ctx.Session) + return nil +} + +func (this AuthM) Mkdir(ctx App, path string) error { + Log.Stdout("MKDIR %+v", ctx.Session) + return ErrNotAllowed +} + +func (this AuthM) Rm(ctx App, path string) error { + Log.Stdout("RM %+v", ctx.Session) + return ErrNotAllowed +} + +func (this AuthM) Mv(ctx App, from string, to string) error { + Log.Stdout("MV %+v", ctx.Session) + return ErrNotAllowed +} + +func (this AuthM) Save(ctx App, path string) error { + Log.Stdout("SAVE %+v", ctx.Session) + return ErrNotAllowed +} + +func (this AuthM) Touch(ctx App, path string) error { + Log.Stdout("TOUCH %+v", ctx.Session) + return ErrNotAllowed +}