backend

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func HashPassword(password string) (string, error)

HashPassword hashes the password using bcrypt.

func HashToken added in v0.6.0

func HashToken(token string) string

HashToken hashes the token using sha256.

func LatestFile

func LatestFile(r proto.Repository, pattern string) (string, string, error)

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

func VerifyPassword(password, hash string) bool

VerifyPassword verifies the password against the hash.

func WithContext added in v0.5.3

func WithContext(ctx context.Context, b *Backend) context.Context

WithContext returns a new context with the backend attached.

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

func FromContext(ctx context.Context) *Backend

FromContext returns the backend from a context.

func New added in v0.6.0

func New(ctx context.Context, cfg *config.Config, db *db.DB) *Backend

New returns a new Soft Serve backend.

func (*Backend) AccessLevel added in v0.6.0

func (d *Backend) AccessLevel(ctx context.Context, repo string, username string) access.AccessLevel

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

func (d *Backend) AddPublicKey(ctx context.Context, username string, pk ssh.PublicKey) error

AddPublicKey adds a public key to a user.

It implements backend.Backend.

func (*Backend) AllowKeyless added in v0.6.0

func (b *Backend) AllowKeyless(ctx context.Context) bool

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

func (d *Backend) Collaborators(ctx context.Context, repo string) ([]string, error)

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

func (b *Backend) DeleteAccessToken(ctx context.Context, user proto.User, id int64) error

DeleteAccessToken deletes an access token for a user.

func (*Backend) DeleteRepository added in v0.6.0

func (d *Backend) DeleteRepository(ctx context.Context, name string) error

DeleteRepository deletes a repository.

It implements backend.Backend.

func (*Backend) DeleteUser added in v0.6.0

func (d *Backend) DeleteUser(ctx context.Context, username string) error

DeleteUser deletes a user.

It implements backend.Backend.

func (*Backend) DeleteUserRepositories added in v0.6.0

func (d *Backend) DeleteUserRepositories(ctx context.Context, username string) error

DeleteUserRepositories deletes all user repositories.

func (*Backend) Description added in v0.6.0

func (d *Backend) Description(ctx context.Context, name string) (string, error)

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

func (d *Backend) IsHidden(ctx context.Context, name string) (bool, error)

IsHidden returns true if the repository is hidden.

It implements backend.Backend.

func (*Backend) IsMirror added in v0.6.0

func (d *Backend) IsMirror(ctx context.Context, name string) (bool, error)

IsMirror returns true if the repository is a mirror.

It implements backend.Backend.

func (*Backend) IsPrivate added in v0.6.0

func (d *Backend) IsPrivate(ctx context.Context, name string) (bool, error)

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

func (d *Backend) ListPublicKeys(ctx context.Context, username string) ([]ssh.PublicKey, error)

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

func (d *Backend) ProjectName(ctx context.Context, name string) (string, error)

ProjectName returns the project name of a repository.

It implements backend.Backend.

func (*Backend) RemoveCollaborator added in v0.6.0

func (d *Backend) RemoveCollaborator(ctx context.Context, repo string, username string) error

RemoveCollaborator removes a collaborator from a repository.

It implements backend.Backend.

func (*Backend) RemovePublicKey added in v0.6.0

func (d *Backend) RemovePublicKey(ctx context.Context, username string, pk ssh.PublicKey) error

RemovePublicKey removes a public key from a user.

It implements backend.Backend.

func (*Backend) RenameRepository added in v0.6.0

func (d *Backend) RenameRepository(ctx context.Context, oldName string, newName string) error

RenameRepository renames a repository.

It implements backend.Backend.

func (*Backend) Repositories added in v0.6.0

func (d *Backend) Repositories(ctx context.Context) ([]proto.Repository, error)

Repositories returns a list of repositories per page.

It implements backend.Backend.

func (*Backend) Repository added in v0.6.0

func (d *Backend) Repository(ctx context.Context, name string) (proto.Repository, error)

Repository returns a repository by name.

It implements backend.Backend.

func (*Backend) SetAdmin added in v0.6.0

func (d *Backend) SetAdmin(ctx context.Context, username string, admin bool) error

SetAdmin sets the admin flag of a user.

It implements backend.Backend.

func (*Backend) SetAllowKeyless added in v0.6.0

func (b *Backend) SetAllowKeyless(ctx context.Context, allow bool) error

SetAllowKeyless sets whether or not keyless access is allowed.

It implements backend.Backend.

func (*Backend) SetAnonAccess added in v0.6.0

func (b *Backend) SetAnonAccess(ctx context.Context, level access.AccessLevel) error

SetAnonAccess sets the level of anonymous access.

It implements backend.Backend.

func (*Backend) SetDescription added in v0.6.0

func (d *Backend) SetDescription(ctx context.Context, name string, desc string) error

SetDescription sets the description of a repository.

It implements backend.Backend.

func (*Backend) SetHidden added in v0.6.0

func (d *Backend) SetHidden(ctx context.Context, name string, hidden bool) error

SetHidden sets the hidden flag of a repository.

It implements backend.Backend.

func (*Backend) SetPassword added in v0.6.0

func (d *Backend) SetPassword(ctx context.Context, username string, rawPassword string) error

SetPassword sets the password of a user.

func (*Backend) SetPrivate added in v0.6.0

func (d *Backend) SetPrivate(ctx context.Context, name string, private bool) error

SetPrivate sets the private flag of a repository.

It implements backend.Backend.

func (*Backend) SetProjectName added in v0.6.0

func (d *Backend) SetProjectName(ctx context.Context, repo string, name string) error

SetProjectName sets the project name of a repository.

It implements backend.Backend.

func (*Backend) SetUsername added in v0.6.0

func (d *Backend) SetUsername(ctx context.Context, username string, newUsername string) error

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

func (d *Backend) User(ctx context.Context, username string) (proto.User, error)

User finds a user by username.

It implements backend.Backend.

func (*Backend) UserByAccessToken added in v0.6.0

func (d *Backend) UserByAccessToken(ctx context.Context, token string) (proto.User, error)

UserByAccessToken finds a user by access token. This also validates the token for expiration and returns proto.ErrTokenExpired.

func (*Backend) UserByID added in v0.6.0

func (d *Backend) UserByID(ctx context.Context, id int64) (proto.User, error)

UserByID finds a user by ID.

func (*Backend) UserByPublicKey added in v0.6.0

func (d *Backend) UserByPublicKey(ctx context.Context, pk ssh.PublicKey) (proto.User, error)

UserByPublicKey finds a user by public key.

It implements backend.Backend.

func (*Backend) Users added in v0.6.0

func (d *Backend) Users(ctx context.Context) ([]string, error)

Users returns all users.

It implements backend.Backend.

Jump to

Keyboard shortcuts

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