git

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAuthed = fmt.Errorf("you are not authorized to do this")

ErrNotAuthed represents unauthorized access.

View Source
var ErrSystemMalfunction = fmt.Errorf("something went wrong")

ErrSystemMalfunction represents a general system error returned to clients.

Functions

func Middleware

func Middleware(repoDir string, gh GitHooks) wish.Middleware

Middleware adds Git server functionality to the ssh.Server. Repos are stored in the specified repo directory. The provided GitHooks implementation will be checked for access on a per repo basis for a ssh.Session public key. GitHooks.Push and GitHooks.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 AccessLevel = iota
	ReadOnlyAccess
	ReadWriteAccess
	AdminAccess
)

type GitHooks

type GitHooks interface {
	AuthRepo(string, ssh.PublicKey) AccessLevel
	Push(string, ssh.PublicKey)
	Fetch(string, ssh.PublicKey)
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL