Documentation ¶
Index ¶
- Variables
- func GenerateToken() string
- func HashPassword(password string) (string, error)
- func HashToken(token string) string
- func LatestFile(r proto.Repository, ref *git.Reference, pattern string) (string, string, error)
- func Readme(r proto.Repository, ref *git.Reference) (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) CreateWebhook(ctx context.Context, repo proto.Repository, url string, ...) 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 (b *Backend) DeleteWebhook(ctx context.Context, repo proto.Repository, id int64) 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 (b *Backend) ListWebhookDeliveries(ctx context.Context, id int64) ([]webhook.Delivery, error)
- func (b *Backend) ListWebhooks(ctx context.Context, repo proto.Repository) ([]webhook.Hook, 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 (b *Backend) RedeliverWebhookDelivery(ctx context.Context, repo proto.Repository, id int64, delID uuid.UUID) 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(ctx context.Context, _ io.Writer, _ io.Writer, repo string, arg hooks.HookArg)
- func (b *Backend) UpdateWebhook(ctx context.Context, repo proto.Repository, id int64, url string, ...) error
- 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)
- func (b *Backend) Webhook(ctx context.Context, repo proto.Repository, id int64) (webhook.Hook, error)
- func (b *Backend) WebhookDelivery(ctx context.Context, webhookID int64, id uuid.UUID) (webhook.Delivery, error)
Constants ¶
This section is empty.
Variables ¶
var ContextKey = &struct{ string }{"backend"}
ContextKey is the key for the backend in the context.
Functions ¶
func HashPassword ¶
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 StoreRepoMissingLFSObjects ¶
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 ¶
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 ¶
FromContext returns the backend from a context.
func (*Backend) AccessLevel ¶
AccessLevel returns the access level of a user for a repository.
It implements backend.Backend.
func (*Backend) AccessLevelByPublicKey ¶
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 ¶
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 ¶
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 ¶
AddPublicKey adds a public key to a user.
It implements backend.Backend.
func (*Backend) AllowKeyless ¶
AllowKeyless returns whether or not keyless access is allowed.
It implements backend.Backend.
func (*Backend) AnonAccess ¶
func (b *Backend) AnonAccess(ctx context.Context) access.AccessLevel
AnonAccess returns the level of anonymous access.
It implements backend.Backend.
func (*Backend) Collaborators ¶
Collaborators returns a list of collaborators for a repository.
It implements backend.Backend.
func (*Backend) CreateAccessToken ¶
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 ¶
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 ¶
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) CreateWebhook ¶
func (b *Backend) CreateWebhook(ctx context.Context, repo proto.Repository, url string, contentType webhook.ContentType, secret string, events []webhook.Event, active bool) error
CreateWebhook creates a webhook for a repository.
func (*Backend) DeleteAccessToken ¶
DeleteAccessToken deletes an access token for a user.
func (*Backend) DeleteRepository ¶
DeleteRepository deletes a repository.
It implements backend.Backend.
func (*Backend) DeleteUserRepositories ¶
DeleteUserRepositories deletes all user repositories.
func (*Backend) DeleteWebhook ¶
DeleteWebhook deletes a webhook for a repository.
func (*Backend) Description ¶
Description returns the description of a repository.
It implements backend.Backend.
func (*Backend) ImportRepository ¶
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 ¶
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 ¶
IsHidden returns true if the repository is hidden.
It implements backend.Backend.
func (*Backend) IsMirror ¶
IsMirror returns true if the repository is a mirror.
It implements backend.Backend.
func (*Backend) IsPrivate ¶
IsPrivate returns true if the repository is private.
It implements backend.Backend.
func (*Backend) ListAccessTokens ¶
func (b *Backend) ListAccessTokens(ctx context.Context, user proto.User) ([]proto.AccessToken, error)
ListAccessTokens lists access tokens for a user.
func (*Backend) ListPublicKeys ¶
ListPublicKeys lists the public keys of a user.
func (*Backend) ListWebhookDeliveries ¶
ListWebhookDeliveries lists webhook deliveries for a webhook.
func (*Backend) ListWebhooks ¶
ListWebhooks lists webhooks for a repository.
func (*Backend) PostReceive ¶
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 ¶
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 ¶
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 ¶
ProjectName returns the project name of a repository.
It implements backend.Backend.
func (*Backend) RedeliverWebhookDelivery ¶
func (b *Backend) RedeliverWebhookDelivery(ctx context.Context, repo proto.Repository, id int64, delID uuid.UUID) error
RedeliverWebhookDelivery redelivers a webhook delivery.
func (*Backend) RemoveCollaborator ¶
RemoveCollaborator removes a collaborator from a repository.
It implements backend.Backend.
func (*Backend) RemovePublicKey ¶
RemovePublicKey removes a public key from a user.
It implements backend.Backend.
func (*Backend) RenameRepository ¶
RenameRepository renames a repository.
It implements backend.Backend.
func (*Backend) Repositories ¶
Repositories returns a list of repositories per page.
It implements backend.Backend.
func (*Backend) Repository ¶
Repository returns a repository by name.
It implements backend.Backend.
func (*Backend) SetAllowKeyless ¶
SetAllowKeyless sets whether or not keyless access is allowed.
It implements backend.Backend.
func (*Backend) SetAnonAccess ¶
SetAnonAccess sets the level of anonymous access.
It implements backend.Backend.
func (*Backend) SetDescription ¶
SetDescription sets the description of a repository.
It implements backend.Backend.
func (*Backend) SetHidden ¶
SetHidden sets the hidden flag of a repository.
It implements backend.Backend.
func (*Backend) SetPassword ¶
SetPassword sets the password of a user.
func (*Backend) SetPrivate ¶
SetPrivate sets the private flag of a repository.
It implements backend.Backend.
func (*Backend) SetProjectName ¶
SetProjectName sets the project name of a repository.
It implements backend.Backend.
func (*Backend) SetUsername ¶
SetUsername sets the username of a user.
It implements backend.Backend.
func (*Backend) Update ¶
func (d *Backend) Update(ctx context.Context, _ io.Writer, _ io.Writer, repo string, arg hooks.HookArg)
Update is called by the git update hook.
It implements Hooks.
func (*Backend) UpdateWebhook ¶
func (b *Backend) UpdateWebhook(ctx context.Context, repo proto.Repository, id int64, url string, contentType webhook.ContentType, secret string, updatedEvents []webhook.Event, active bool) error
UpdateWebhook updates a webhook.
func (*Backend) UserByAccessToken ¶
UserByAccessToken finds a user by access token. This also validates the token for expiration and returns proto.ErrTokenExpired.
func (*Backend) UserByPublicKey ¶
UserByPublicKey finds a user by public key.
It implements backend.Backend.