1package backend
2
3import "golang.org/x/crypto/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 returns the string representation of the access level.
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 "unknown"
35 }
36}
37
38// AccessMethod is an interface that handles repository authorization.
39type AccessMethod interface {
40 // AccessLevel returns the access level for the given repository and key.
41 AccessLevel(repo string, pk ssh.PublicKey) AccessLevel
42}