Documentation ¶
Index ¶
- Variables
- func CtxExtract(ctx context.Context) (*zerolog.Logger, *Config, *User)
- func CtxLogger(ctx context.Context) *zerolog.Logger
- func CtxPublicKey(ctx context.Context) *models.PublicKey
- func CtxSetConfig(parent ssh.Context, config *Config)
- func CtxSetLogger(parent ssh.Context, logger *zerolog.Logger)
- func CtxSetPublicKey(parent ssh.Context, pk *models.PublicKey)
- func CtxSetUser(parent ssh.Context, user *User)
- func WithLogger(parent context.Context, logger *zerolog.Logger) context.Context
- type AccessLevel
- type Config
- func (c *Config) EnsureAdminUser(username string, pubKey *models.PublicKey) error
- func (c *Config) EnsureConfig() error
- func (c *Config) Load() error
- func (c *Config) LookupRepoAccess(user *User, path string) (*RepoLookup, error)
- func (c *Config) LookupUserFromInvite(invite string) (*User, error)
- func (c *Config) LookupUserFromKey(pk models.PublicKey, remoteUser string) (*User, error)
- func (c *Config) LookupUserFromUsername(username string) (*User, error)
- func (c *Config) RunHook(hook string, repoPath string, pk *models.PublicKey, args []string, ...) error
- func (c *Config) SetHash(hash string) error
- func (c *Config) SetOrgHash(orgName, hash string) error
- func (c *Config) SetUserHash(username, hash string) error
- func (c *Config) Validate(user *User, pk *models.PublicKey) error
- type RepoLookup
- type RepoType
- type Server
- type User
Constants ¶
This section is empty.
Variables ¶
var AnonymousUser = &User{ Username: "<anonymous>", IsAnonymous: true, IsAdmin: false, }
AnonymousUser is the user that is returned when no user is available.
var ErrInvalidRepoFormat = errors.New("invalid repo format")
ErrInvalidRepoFormat is returned when a repo is looked up which cannot exist based on the parsed format.
var ErrRepoDoesNotExist = errors.New("repo does not exist")
ErrRepoDoesNotExist is returned when a repo is looked up which cannot exist based on the config.
var ErrUserNotFound = errors.New("user not found")
ErrUserNotFound is returned from LookupUser commands when the user is not found.
Functions ¶
func CtxExtract ¶
CtxExtract is a convenience wrapper around the other context convenience methods to pull out everything you'd want from a request.
func CtxPublicKey ¶
CtxPublicKey pulls the public key out of the context, or nil if not found.
func CtxSetConfig ¶
CtxSetConfig puts the given Config into the ssh.Context.
func CtxSetLogger ¶
CtxSetLogger puts the given logger into the ssh.Context.
func CtxSetPublicKey ¶
CtxSetPublicKey puts the given public key into the ssh.Context.
func CtxSetUser ¶
CtxSetUser puts the given User into the ssh.Context.
Types ¶
type AccessLevel ¶
type AccessLevel int
AccessLevel represents the level of access being requested and the level of access a user has.
const ( AccessLevelNone AccessLevel = iota AccessLevelRead AccessLevelWrite AccessLevelAdmin )
AccessLevel defaults to AccessLevelNone for security. A repo lookup returns the level of permissions a user has and if it's not explicitly set, they don't have any.
type Config ¶
type Config struct { Invites map[string]string Groups map[string][]string Orgs map[string]*models.OrgConfig Users map[string]*models.AdminConfigUser Repos map[string]*models.RepoConfig Options models.AdminConfigOptions PrivateKeys []models.PrivateKey // contains filtered or unexported fields }
Config represents the config which has been loaded from all repos.
func CtxConfig ¶
CtxConfig pulls the current Config out of the context, or a blank Config if not set.
func NewConfig ¶
func NewConfig(fs billy.Filesystem) *Config
NewConfig returns an empty config, attached to the given fs. In general, Load should be called after creating a new config at a bare minimum.
func (*Config) EnsureAdminUser ¶
EnsureUser will load the current admin config and ensure the given user exists.
func (*Config) EnsureConfig ¶
func (*Config) LookupRepoAccess ¶
func (c *Config) LookupRepoAccess(user *User, path string) (*RepoLookup, error)
LookupRepoAccess checks to see if path points to a valid repo and attaches the access level this user has on that repository.
func (*Config) LookupUserFromInvite ¶
LookupUserFromInvite looks up a user object given an invite code.
func (*Config) LookupUserFromKey ¶
LookupUserFromKey looks up a user object given their PublicKey.
func (*Config) LookupUserFromUsername ¶
LookupUserFromUsername looks up a user objects given their username.
func (*Config) RunHook ¶
func (c *Config) RunHook( hook string, repoPath string, pk *models.PublicKey, args []string, stdin io.Reader, ) error
RunHook will run the given hook.
func (*Config) SetOrgHash ¶
SetOrgHash will set the hash of the given org repo to use when loading.
func (*Config) SetUserHash ¶
SetUserHash will set the hash of the given user repo to use when loading.
type RepoLookup ¶
type RepoLookup struct { Type RepoType PathParts []string Access AccessLevel }
RepoLookup represents a repository that has been confirmed in the config and the access level the given user has.
func (RepoLookup) Path ¶
func (repo RepoLookup) Path() string
Path returns the full path to this repository on disk. This is relative to the gitdir root.
type RepoType ¶
type RepoType int
RepoType represents the different types of repositories that can be accessed.
type Server ¶
type Server struct { Addr string // contains filtered or unexported fields }
Server represents a gitdir server.
func NewServer ¶
func NewServer(fs billy.Filesystem) (*Server, error)
NewServer configures a new gitdir server and attempts to load the config from the admin repo.
func (*Server) EnsureAdminUser ¶
func (*Server) GetAdminConfig ¶
GetAdminConfig returns the current admin config in a thread-safe manner. The config should not be modified.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the Addr set on the server struct for new SSH connections.