documentation (authorisation): example of authorisation plugin

This commit is contained in:
Mickael Kerjean 2022-01-15 15:36:56 +11:00
parent ebb4247a77
commit f2ba98bf4a

View file

@ -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
}