Documentation
¶
Overview ¶
Package policy holds access-control and naming rules.
Index ¶
- Constants
- func CanAdmin(user store.User, repo store.Repo, grant string) bool
- func CanRead(user store.User, repo store.Repo, grant string) bool
- func CanWrite(user store.User, repo store.Repo, grant string) bool
- func CheckPush(repo store.Repo, updates []RefUpdate) string
- func DeployScopeAllows(scope string, repoID int64, write bool) bool
- func IsDeployScope(scope string) bool
- func OwnersFor(rules []CodeownersRule, filePath string) []string
- func Reserved(name string) bool
- func ScopeAllowsGit(scope, repoPath string, write bool) bool
- func ValidateName(name string) error
- func ValidateOwnerName(name string) error
- func ValidateTopic(topic string) error
- type CodeownersRule
- type RefUpdate
Constants ¶
const MaxTopics = 20
MaxTopics caps topics per repository.
Variables ¶
This section is empty.
Functions ¶
func CanAdmin ¶
CanAdmin reports whether user may change repo settings and access.
func CanRead ¶
CanRead reports whether user may read repo over an authenticated channel. Public repos are readable by any authenticated user; private repos require ownership or an explicit grant.
func CanWrite ¶
CanWrite reports whether user may push to repo.
func CheckPush ¶
CheckPush applies ref policy for a push by a user with write access already established. It returns a denial message, or "" to allow.
func DeployScopeAllows ¶ added in v0.2.0
DeployScopeAllows authorizes a deploy key purely by its scope: the key is bound to a repository ID (rename- and transfer-proof), grants nothing anywhere else, and never inherits the access of whoever registered it.
func IsDeployScope ¶ added in v0.2.0
IsDeployScope reports whether a key scope is a deploy binding.
func OwnersFor ¶ added in v0.2.0
func OwnersFor(rules []CodeownersRule, filePath string) []string
OwnersFor returns the owners of a path: the last matching rule wins, CODEOWNERS convention. nil means unowned.
func Reserved ¶
Reserved reports whether name is a reserved route word. Exported so the httpd tests can assert route/reserved-list agreement.
func ScopeAllowsGit ¶
ScopeAllowsGit reports whether an account-scoped SSH key permits git transport at all. Deploy scopes are decided by DeployScopeAllows instead.
func ValidateName ¶
ValidateName checks a repo name (reserved words are allowed for repos; routes are namespaced under the owner).
func ValidateOwnerName ¶
ValidateOwnerName checks a username or org name.
Types ¶
type CodeownersRule ¶ added in v0.2.0
CodeownersRule is one line of a CODEOWNERS file: a pattern and the users who own paths matching it.
func ParseCodeowners ¶ added in v0.2.0
func ParseCodeowners(content string) []CodeownersRule
ParseCodeowners reads CODEOWNERS content: one rule per line, gitignore- style pattern followed by @user owners; #-comments and blanks ignored.
type RefUpdate ¶
type RefUpdate struct {
Ref string `json:"ref"`
Old string `json:"old"`
New string `json:"new"`
IsDelete bool `json:"is_delete"`
IsForce bool `json:"is_force"`
}
RefUpdate is one proposed ref change, with git facts computed by the hook process (which can see quarantined objects; the daemon cannot).
Source Files
¶
- access.go
- codeowners.go
- names.go
- topic.go