--- a/access/access.go Thu Sep 12 05:54:15 2019 -0500
+++ b/access/access.go Thu Sep 12 05:55:03 2019 -0500
@@ -1,6 +1,7 @@
@@ -10,16 +11,27 @@
-func Setup(adminRepo string) error {
- adminRepoPath = adminRepo
+func Setup(reposPath, adminRepo string) error { + adminRepoName = adminRepo + adminRepoPath = filepath.Join(reposPath, adminRepo) +func AdminRepo() string { +func AdminRepoPath() string { // Refresh will try to reload the casbin model and policies followed by SSH
// keys. If there is an error it's possible that the casbin model and polcies
// could have been updated but the ssh keys were not.
--- a/serve/command.go Thu Sep 12 05:54:15 2019 -0500
+++ b/serve/command.go Thu Sep 12 05:55:03 2019 -0500
@@ -1,8 +1,6 @@
"bitbucket.org/rw_grim/hgkeeper/access"
"bitbucket.org/rw_grim/hgkeeper/globals"
"bitbucket.org/rw_grim/hgkeeper/ssh"
@@ -14,12 +12,11 @@
func (c *Command) Run(g *globals.Globals) error {
- adminRepoPath := filepath.Join(g.ReposPath, g.AdminRepo)
- if err := access.Setup(adminRepoPath); err != nil {
+ if err := access.Setup(g.ReposPath, g.AdminRepo); err != nil { - s, err := ssh.NewServer(c.SSHHostKeysPath, g.ReposPath, g.AdminRepo)
+ s, err := ssh.NewServer(c.SSHHostKeysPath, g.ReposPath, access.AdminRepoPath()) --- a/ssh/commands/serve.go Thu Sep 12 05:54:15 2019 -0500
+++ b/ssh/commands/serve.go Thu Sep 12 05:55:03 2019 -0500
@@ -4,6 +4,7 @@
+ log "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh"
"bitbucket.org/rw_grim/hgkeeper/access"
@@ -29,7 +30,17 @@
writeable := access.CanWrite(username, "/"+s.repoName)
- return run(hg.Serve(s.repoPath, writeable), conn, serverConn, req)
+ if err := run(hg.Serve(s.repoPath, writeable), conn, serverConn, req); err != nil { + if s.repoName == access.AdminRepo() { + log.Info("admin repo updated, refreshing access control") + return access.Refresh() func (s *Serve) String() string {