Documentation ¶
Index ¶
- Variables
- func GenerateToken() string
- func HashPassword(password string) (string, error)
- func HashToken(token string) string
- func LatestFile(r proto.Repository, pattern string) (string, string, error)
- func Readme(r proto.Repository) (readme string, path string, err error)
- func StoreRepoMissingLFSObjects(ctx context.Context, repo proto.Repository, dbx *db.DB, store store.Store, ...) error
- func VerifyPassword(password, hash string) bool
- func WithContext(ctx context.Context, b *Backend) context.Context
- type Backend
- func (d *Backend) AccessLevel(ctx context.Context, repo string, username string) access.AccessLevel
- func (d *Backend) AccessLevelByPublicKey(ctx context.Context, repo string, pk ssh.PublicKey) access.AccessLevel
- func (d *Backend) AccessLevelForUser(ctx context.Context, repo string, user proto.User) access.AccessLevel
- func (d *Backend) AddCollaborator(ctx context.Context, repo string, username string, level access.AccessLevel) error
- func (d *Backend) AddPublicKey(ctx context.Context, username string, pk ssh.PublicKey) error
- func (b *Backend) AllowKeyless(ctx context.Context) bool
- func (b *Backend) AnonAccess(ctx context.Context) access.AccessLevel
- func (d *Backend) Collaborators(ctx context.Context, repo string) ([]string, error)
- func (b *Backend) CreateAccessToken(ctx context.Context, user proto.User, name string, expiresAt time.Time) (string, error)
- func (d *Backend) CreateRepository(ctx context.Context, name string, user proto.User, ...) (proto.Repository, error)
- func (d *Backend) CreateUser(ctx context.Context, username string, opts proto.UserOptions) (proto.User, error)
- func (b *Backend) DeleteAccessToken(ctx context.Context, user proto.User, id int64) error
- func (d *Backend) DeleteRepository(ctx context.Context, name string) error
- func (d *Backend) DeleteUser(ctx context.Context, username string) error
- func (d *Backend) DeleteUserRepositories(ctx context.Context, username string) error
- func (d *Backend) Description(ctx context.Context, name string) (string, error)
- func (d *Backend) ImportRepository(_ context.Context, name string, user proto.User, remote string, ...) (proto.Repository, error)
- func (d *Backend) IsCollaborator(ctx context.Context, repo string, username string) (access.AccessLevel, bool, error)
- func (d *Backend) IsHidden(ctx context.Context, name string) (bool, error)
- func (d *Backend) IsMirror(ctx context.Context, name string) (bool, error)
- func (d *Backend) IsPrivate(ctx context.Context, name string) (bool, error)
- func (b *Backend) ListAccessTokens(ctx context.Context, user proto.User) ([]proto.AccessToken, error)
- func (d *Backend) ListPublicKeys(ctx context.Context, username string) ([]ssh.PublicKey, error)
- func (d *Backend) PostReceive(_ context.Context, _ io.Writer, _ io.Writer, repo string, args []hooks.HookArg)
- func (d *Backend) PostUpdate(ctx context.Context, _ io.Writer, _ io.Writer, repo string, args ...string)
- func (d *Backend) PreReceive(_ context.Context, _ io.Writer, _ io.Writer, repo string, args []hooks.HookArg)
- func (d *Backend) ProjectName(ctx context.Context, name string) (string, error)
- func (d *Backend) RemoveCollaborator(ctx context.Context, repo string, username string) error
- func (d *Backend) RemovePublicKey(ctx context.Context, username string, pk ssh.PublicKey) error
- func (d *Backend) RenameRepository(ctx context.Context, oldName string, newName string) error
- func (d *Backend) Repositories(ctx context.Context) ([]proto.Repository, error)
- func (d *Backend) Repository(ctx context.Context, name string) (proto.Repository, error)
- func (d *Backend) SetAdmin(ctx context.Context, username string, admin bool) error
- func (b *Backend) SetAllowKeyless(ctx context.Context, allow bool) error
- func (b *Backend) SetAnonAccess(ctx context.Context, level access.AccessLevel) error
- func (d *Backend) SetDescription(ctx context.Context, name string, desc string) error
- func (d *Backend) SetHidden(ctx context.Context, name string, hidden bool) error
- func (d *Backend) SetPassword(ctx context.Context, username string, rawPassword string) error
- func (d *Backend) SetPrivate(ctx context.Context, name string, private bool) error
- func (d *Backend) SetProjectName(ctx context.Context, repo string, name string) error
- func (d *Backend) SetUsername(ctx context.Context, username string, newUsername string) error
- func (d *Backend) Update(_ context.Context, _ io.Writer, _ io.Writer, repo string, arg hooks.HookArg)
- func (d *Backend) User(ctx context.Context, username string) (proto.User, error)
- func (d *Backend) UserByAccessToken(ctx context.Context, token string) (proto.User, error)
- func (d *Backend) UserByID(ctx context.Context, id int64) (proto.User, error)
- func (d *Backend) UserByPublicKey(ctx context.Context, pk ssh.PublicKey) (proto.User, error)
- func (d *Backend) Users(ctx context.Context) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var ContextKey = &struct{ string }{"backend"}
ContextKey is the key for the backend in the context.
Functions ¶
func GenerateToken ¶ added in v0.6.0
func GenerateToken() string
GenerateToken returns a random unique token.
func HashPassword ¶ added in v0.6.0
HashPassword hashes the password using bcrypt.
func LatestFile ¶
LatestFile returns the contents of the latest file at the specified path in the repository and its file path.
func Readme ¶
func Readme(r proto.Repository) (readme string, path string, err error)
Readme returns the repository's README.
func StoreRepoMissingLFSObjects ¶ added in v0.6.0
func StoreRepoMissingLFSObjects(ctx context.Context, repo proto.Repository, dbx *db.DB, store store.Store, lfsClient lfs.Client) error
StoreRepoMissingLFSObjects stores missing LFS objects for a repository.
func VerifyPassword ¶ added in v0.6.0
VerifyPassword verifies the password against the hash.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is the Soft Serve backend that handles users, repositories, and server settings management and operations.
func FromContext ¶ added in v0.5.3
FromContext returns the backend from a context.
func (*Backend) AccessLevel ¶ added in v0.6.0
AccessLevel returns the access level of a user for a repository.
It implements backend.Backend.
func (*Backend) AccessLevelByPublicKey ¶ added in v0.6.0
func (d *Backend) AccessLevelByPublicKey(ctx context.Context, repo string, pk ssh.PublicKey) access.AccessLevel
AccessLevelByPublicKey returns the access level of a user's public key for a repository.
It implements backend.Backend.
func (*Backend) AccessLevelForUser ¶ added in v0.6.0
func (d *Backend) AccessLevelForUser(ctx context.Context, repo string, user proto.User) access.AccessLevel
AccessLevelForUser returns the access level of a user for a repository. TODO: user repository ownership
func (*Backend) AddCollaborator ¶ added in v0.6.0
func (d *Backend) AddCollaborator(ctx context.Context, repo string, username string, level access.AccessLevel) error
AddCollaborator adds a collaborator to a repository.
It implements backend.Backend.
func (*Backend) AddPublicKey ¶ added in v0.6.0
AddPublicKey adds a public key to a user.
It implements backend.Backend.
func (*Backend) AllowKeyless ¶ added in v0.6.0
AllowKeyless returns whether or not keyless access is allowed.
It implements backend.Backend.
func (*Backend) AnonAccess ¶ added in v0.6.0
func (b *Backend) AnonAccess(ctx context.Context) access.AccessLevel
AnonAccess returns the level of anonymous access.
It implements backend.Backend.
func (*Backend) Collaborators ¶ added in v0.6.0
Collaborators returns a list of collaborators for a repository.
It implements backend.Backend.
func (*Backend) CreateAccessToken ¶ added in v0.6.0
func (b *Backend) CreateAccessToken(ctx context.Context, user proto.User, name string, expiresAt time.Time) (string, error)
CreateAccessToken creates an access token for user.
func (*Backend) CreateRepository ¶ added in v0.6.0
func (d *Backend) CreateRepository(ctx context.Context, name string, user proto.User, opts proto.RepositoryOptions) (proto.Repository, error)
CreateRepository creates a new repository.
It implements backend.Backend.
func (*Backend) CreateUser ¶ added in v0.6.0
func (d *Backend) CreateUser(ctx context.Context, username string, opts proto.UserOptions) (proto.User, error)
CreateUser creates a new user.
It implements backend.Backend.
func (*Backend) DeleteAccessToken ¶ added in v0.6.0
DeleteAccessToken deletes an access token for a user.
func (*Backend) DeleteRepository ¶ added in v0.6.0
DeleteRepository deletes a repository.
It implements backend.Backend.
func (*Backend) DeleteUser ¶ added in v0.6.0
DeleteUser deletes a user.
It implements backend.Backend.
func (*Backend) DeleteUserRepositories ¶ added in v0.6.0
DeleteUserRepositories deletes all user repositories.
func (*Backend) Description ¶ added in v0.6.0
Description returns the description of a repository.
It implements backend.Backend.
func (*Backend) ImportRepository ¶ added in v0.6.0
func (d *Backend) ImportRepository(_ context.Context, name string, user proto.User, remote string, opts proto.RepositoryOptions) (proto.Repository, error)
ImportRepository imports a repository from remote. XXX: This a expensive operation and should be run in a goroutine.
func (*Backend) IsCollaborator ¶ added in v0.6.0
func (d *Backend) IsCollaborator(ctx context.Context, repo string, username string) (access.AccessLevel, bool, error)
IsCollaborator returns the access level and true if the user is a collaborator of the repository.
It implements backend.Backend.
func (*Backend) IsHidden ¶ added in v0.6.0
IsHidden returns true if the repository is hidden.
It implements backend.Backend.
func (*Backend) IsMirror ¶ added in v0.6.0
IsMirror returns true if the repository is a mirror.
It implements backend.Backend.
func (*Backend) IsPrivate ¶ added in v0.6.0
IsPrivate returns true if the repository is private.
It implements backend.Backend.
func (*Backend) ListAccessTokens ¶ added in v0.6.0
func (b *Backend) ListAccessTokens(ctx context.Context, user proto.User) ([]proto.AccessToken, error)
ListAccessTokens lists access tokens for a user.
func (*Backend) ListPublicKeys ¶ added in v0.6.0
ListPublicKeys lists the public keys of a user.
func (*Backend) PostReceive ¶ added in v0.6.0
func (d *Backend) PostReceive(_ context.Context, _ io.Writer, _ io.Writer, repo string, args []hooks.HookArg)
PostReceive is called by the git post-receive hook.
It implements Hooks.
func (*Backend) PostUpdate ¶ added in v0.6.0
func (d *Backend) PostUpdate(ctx context.Context, _ io.Writer, _ io.Writer, repo string, args ...string)
PostUpdate is called by the git post-update hook.
It implements Hooks.
func (*Backend) PreReceive ¶ added in v0.6.0
func (d *Backend) PreReceive(_ context.Context, _ io.Writer, _ io.Writer, repo string, args []hooks.HookArg)
PreReceive is called by the git pre-receive hook.
It implements Hooks.
func (*Backend) ProjectName ¶ added in v0.6.0
ProjectName returns the project name of a repository.
It implements backend.Backend.
func (*Backend) RemoveCollaborator ¶ added in v0.6.0
RemoveCollaborator removes a collaborator from a repository.
It implements backend.Backend.
func (*Backend) RemovePublicKey ¶ added in v0.6.0
RemovePublicKey removes a public key from a user.
It implements backend.Backend.
func (*Backend) RenameRepository ¶ added in v0.6.0
RenameRepository renames a repository.
It implements backend.Backend.
func (*Backend) Repositories ¶ added in v0.6.0
Repositories returns a list of repositories per page.
It implements backend.Backend.
func (*Backend) Repository ¶ added in v0.6.0
Repository returns a repository by name.
It implements backend.Backend.
func (*Backend) SetAdmin ¶ added in v0.6.0
SetAdmin sets the admin flag of a user.
It implements backend.Backend.
func (*Backend) SetAllowKeyless ¶ added in v0.6.0
SetAllowKeyless sets whether or not keyless access is allowed.
It implements backend.Backend.
func (*Backend) SetAnonAccess ¶ added in v0.6.0
SetAnonAccess sets the level of anonymous access.
It implements backend.Backend.
func (*Backend) SetDescription ¶ added in v0.6.0
SetDescription sets the description of a repository.
It implements backend.Backend.
func (*Backend) SetHidden ¶ added in v0.6.0
SetHidden sets the hidden flag of a repository.
It implements backend.Backend.
func (*Backend) SetPassword ¶ added in v0.6.0
SetPassword sets the password of a user.
func (*Backend) SetPrivate ¶ added in v0.6.0
SetPrivate sets the private flag of a repository.
It implements backend.Backend.
func (*Backend) SetProjectName ¶ added in v0.6.0
SetProjectName sets the project name of a repository.
It implements backend.Backend.
func (*Backend) SetUsername ¶ added in v0.6.0
SetUsername sets the username of a user.
It implements backend.Backend.
func (*Backend) Update ¶ added in v0.6.0
func (d *Backend) Update(_ context.Context, _ io.Writer, _ io.Writer, repo string, arg hooks.HookArg)
Update is called by the git update hook.
It implements Hooks.
func (*Backend) User ¶ added in v0.6.0
User finds a user by username.
It implements backend.Backend.
func (*Backend) UserByAccessToken ¶ added in v0.6.0
UserByAccessToken finds a user by access token. This also validates the token for expiration and returns proto.ErrTokenExpired.
func (*Backend) UserByPublicKey ¶ added in v0.6.0
UserByPublicKey finds a user by public key.
It implements backend.Backend.