1package git
2
3import "github.com/gliderlabs/ssh"
4
5// AccessLevel is the level of access allowed to a repo.
6type AccessLevel int
7
8const (
9 // NoAccess does not allow access to the repo.
10 NoAccess AccessLevel = iota
11
12 // ReadOnlyAccess allows read-only access to the repo.
13 ReadOnlyAccess
14
15 // ReadWriteAccess allows read and write access to the repo.
16 ReadWriteAccess
17
18 // AdminAccess allows read, write, and admin access to the repo.
19 AdminAccess
20)
21
22// String implements the Stringer interface for AccessLevel.
23func (a AccessLevel) String() string {
24 switch a {
25 case NoAccess:
26 return "no-access"
27 case ReadOnlyAccess:
28 return "read-only"
29 case ReadWriteAccess:
30 return "read-write"
31 case AdminAccess:
32 return "admin-access"
33 default:
34 return ""
35 }
36}
37
38// Hooks is an interface that allows for custom authorization
39// implementations and post push/fetch notifications. Prior to git access,
40// AuthRepo will be called with the ssh.Session public key and the repo name.
41// Implementers return the appropriate AccessLevel.
42type Hooks interface {
43 AuthRepo(string, ssh.PublicKey) AccessLevel
44 Push(string, ssh.PublicKey)
45 Fetch(string, ssh.PublicKey)
46}