grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Remove the explicit write access of admins to the hgkeeper repo.
23 months ago, Gary Kramlich
5389b17b4002
Remove the explicit write access of admins to the hgkeeper repo.
Fixes HGKEEPER-21
package
access
import
(
"path/filepath"
"sync"
"github.com/casbin/casbin/v2"
log
"github.com/sirupsen/logrus"
)
var
(
enforcer
*
casbin
.
Enforcer
enforcerLock
sync
.
Mutex
)
func
refreshEnforcer
()
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
,
err
:=
casbin
.
NewEnforcer
(
modelFile
,
policyFile
)
if
err
!=
nil
{
log
.
Errorf
(
"failed to create new enforcer: %v"
,
err
)
return
err
}
enforcer
=
e
return
nil
}