Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidRepo = errors.New("invalid repo")
ErrInvalidRepo represents an attempt to access a non-existent repo.
var ErrNotAuthed = errors.New("you are not authorized to do this")
ErrNotAuthed represents unauthorized access.
var ErrSystemMalfunction = errors.New("something went wrong")
ErrSystemMalfunction represents a general system error returned to clients.
Functions ¶
func EnsureRepo ¶ added in v1.3.0
EnsureRepo makes sure the given repo exists within the given dir, and that it is git repository.
If path does not exist, it'll be created. If the path is not a git repo, it will be git init-ed as a bare repository.
func Middleware ¶
func Middleware(repoDir string, gh Hooks) wish.Middleware
Middleware adds Git server functionality to the ssh.Server. Repos are stored in the specified repo directory. The provided Hooks implementation will be checked for access on a per repo basis for a ssh.Session public key. Hooks.Push and Hooks.Fetch will be called on successful completion of their commands.
Types ¶
type AccessLevel ¶
type AccessLevel int
AccessLevel is the level of access allowed to a repo.
const ( // NoAccess does not allow access to the repo. NoAccess AccessLevel = iota // ReadOnlyAccess allows read-only access to the repo. ReadOnlyAccess // ReadWriteAccess allows read and write access to the repo. ReadWriteAccess // AdminAccess allows read, write, and admin access to the repo. AdminAccess )
type GitHooks
deprecated
type GitHooks = Hooks // nolint: revive
GitHooks is an interface that allows for custom authorization implementations and post push/fetch notifications. Prior to git access, AuthRepo will be called with the ssh.Session public key and the repo name. Implementers return the appropriate AccessLevel.
Deprecated: use Hooks instead.
type Hooks ¶ added in v0.2.0
type Hooks interface { AuthRepo(string, ssh.PublicKey) AccessLevel Push(string, ssh.PublicKey) Fetch(string, ssh.PublicKey) }
Hooks is an interface that allows for custom authorization implementations and post push/fetch notifications. Prior to git access, AuthRepo will be called with the ssh.Session public key and the repo name. Implementers return the appropriate AccessLevel.