service

package
v0.0.75 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package service contains the GitHubProviderService

Index

Constants

View Source
const TypeGitHubOrganization = "Organization"

TypeGitHubOrganization is the type returned from the GitHub API when the owner is an organization

Variables

View Source
var ErrInvalidTokenIdentity = errors.New("invalid token identity")

ErrInvalidTokenIdentity is returned when the user identity in the token does not match the expected user identity from the state

Functions

This section is empty.

Types

type GitHubAppInstallationDeletedPayload

type GitHubAppInstallationDeletedPayload struct {
	InstallationID int64 `json:"installation_id"`
}

GitHubAppInstallationDeletedPayload represents the payload of a GitHub App installation deleted event

type GitHubProviderService

type GitHubProviderService interface {
	// CreateGitHubAppProvider creates a GitHub App provider with an installation ID in a known project
	CreateGitHubAppProvider(ctx context.Context, token oauth2.Token, stateData db.GetProjectIDBySessionStateRow,
		installationID int64, state string) (*db.Provider, error)
	// CreateGitHubAppWithoutInvitation either creates a new project for the selected app, or stores
	// the installation in preparation for creating a new project when the authorizing user logs in.
	//
	// Note that this function may return nil, nil if the installation user is not known to Minder.
	CreateGitHubAppWithoutInvitation(ctx context.Context, qtx db.Querier, userID int64,
		installationID int64) (*db.Project, error)
	// ValidateGitHubInstallationId checks if the supplied GitHub token has access to the installation ID
	ValidateGitHubInstallationId(ctx context.Context, token *oauth2.Token, installationID int64) error
	// DeleteGitHubAppInstallation deletes the GitHub App installation and provider from the database.
	DeleteGitHubAppInstallation(ctx context.Context, installationID int64) error
	// ValidateGitHubAppWebhookPayload validates the payload of a GitHub App webhook.
	ValidateGitHubAppWebhookPayload(r *http.Request) (payload []byte, err error)
	// DeleteInstallation deletes the installation from GitHub, if the provider has an associated installation
	DeleteInstallation(ctx context.Context, providerID uuid.UUID) error
	VerifyProviderTokenIdentity(ctx context.Context, remoteUser string, accessToken string) error
	// ValidateOrgMembershipForToken checks if the token user is a member of the organization
	ValidateOrgMembershipForToken(ctx context.Context, token *oauth2.Token, org string) (bool, error)
}

GitHubProviderService encapsulates methods for creating and updating providers

func NewGithubProviderService

func NewGithubProviderService(
	store db.Store,
	cryptoEngine crypto.Engine,
	mt metrics.Metrics,
	config *server.ProviderConfig,
	projectFactory ProjectFactory,
	ghClientFactory clients.GitHubClientFactory,
) GitHubProviderService

NewGithubProviderService creates an instance of GitHubProviderService

type ProjectFactory

type ProjectFactory func(
	ctx context.Context, qtx db.Querier, name string, user int64) (*db.Project, error)

ProjectFactory may create a project named name for the specified userid if present in the system. If a db.Project is returned, it should be used as the location to create a Provider corresponding to the GitHub App installation.

Directories

Path Synopsis
Package mock_service is a generated GoMock package.
Package mock_service is a generated GoMock package.

Jump to

Keyboard shortcuts

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