grim/hgkeeper

auto reload the access model and policy if the admin repo is accessed. This does both push and pulls right now.
package access
import (
"path/filepath"
"sync"
"github.com/casbin/casbin"
log "github.com/sirupsen/logrus"
)
var (
enforcer *casbin.Enforcer
enforcerLock sync.Mutex
)
func refreshEnforcer(adminRepoPath string) error {
enforcerLock.Lock()
defer enforcerLock.Unlock()
modelFile := filepath.Join(adminRepoPath, modelFilename)
policyFile := filepath.Join(adminRepoPath, policyFilename)
log.Debugf("reading model from %q", modelFile)
log.Debugf("reading policy from %q", policyFile)
e := casbin.NewEnforcer(modelFile, policyFile)
enforcer = e
return nil
}