Documentation
¶
Index ¶
- Variables
- func AuthenticateRequest(authenticationProvider AuthenticationProvider) func(http.Handler) http.Handler
- type AuthCtx
- type AuthenticationProvider
- type AuthenticationProviderType
- type Authorizer
- type BasicAuthConfig
- type CommitConfig
- type Config
- type GitLabAuthenticationProvider
- type GitLabClaims
- type Handler
- type RegoAuthorizer
- type RepositoriesConfig
- type RepositoryConfig
- type SignatureConfig
- type ViolationsResolver
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultConfig = Config{ Commit: CommitConfig{ DefaultMessage: "Automated patch by vignet", DefaultAuthor: SignatureConfig{ Name: "vignet", Email: "bot@vignet", }, }, }
DefaultConfig is the default configuration that will be overwritten by the configuration file.
Functions ¶
func AuthenticateRequest ¶
func AuthenticateRequest(authenticationProvider AuthenticationProvider) func(http.Handler) http.Handler
AuthenticateRequest is a middleware to set the AuthCtx from the given request on the request context.
Types ¶
type AuthCtx ¶
type AuthCtx struct {
// Error is set if the authentication failed.
Error error `json:"error"`
// GitLabClaims is set for GitLab authentication provider if no authenticated error occurred.
GitLabClaims *GitLabClaims `json:"gitLabClaims"`
}
type AuthenticationProvider ¶
type AuthenticationProvider interface {
// AuthCtxFromRequest builds an authentication context from the given requests.
//
// If a client error concerning the authentication is encountered or the request could not be authenticated, the error is set in AuthCtx.
// If an internal error is encountered, the error is returned as error return value.
AuthCtxFromRequest(r *http.Request) (AuthCtx, error)
}
type AuthenticationProviderType ¶
type AuthenticationProviderType string
const (
AuthenticationProviderGitLab AuthenticationProviderType = "gitlab"
)
func (AuthenticationProviderType) IsValid ¶
func (p AuthenticationProviderType) IsValid() bool
type Authorizer ¶
type BasicAuthConfig ¶
type CommitConfig ¶
type CommitConfig struct {
DefaultMessage string `yaml:"defaultMessage"`
DefaultAuthor SignatureConfig `yaml:"defaultAuthor"`
}
type Config ¶
type Config struct {
// AuthenticationProvider configures the authentication provider to use for authenticating requests.
AuthenticationProvider struct {
Type AuthenticationProviderType `yaml:"type"`
// GitLab must be set for type `gitlab`
GitLab *struct {
URL string `yaml:"url"`
} `yaml:"gitlab"`
} `yaml:"authenticationProvider"`
// Repositories indexed by an identifier.
Repositories RepositoriesConfig `yaml:"repositories"`
// Commit configures commit options when creating a new commit.
Commit CommitConfig `yaml:"commit"`
}
func (Config) BuildAuthenticationProvider ¶
func (c Config) BuildAuthenticationProvider(ctx context.Context) (AuthenticationProvider, error)
type GitLabAuthenticationProvider ¶
type GitLabAuthenticationProvider struct {
// contains filtered or unexported fields
}
func NewGitLabAuthenticationProvider ¶
func NewGitLabAuthenticationProvider(ctx context.Context, url string) (*GitLabAuthenticationProvider, error)
NewGitLabAuthenticationProvider creates a new GitLabAuthenticationProvider.
It takes the GitLab instance URL as an argument. The context is used to cancel the refreshing of keys.
func (*GitLabAuthenticationProvider) AuthCtxFromRequest ¶
func (p *GitLabAuthenticationProvider) AuthCtxFromRequest(r *http.Request) (AuthCtx, error)
type GitLabClaims ¶
type GitLabClaims struct {
jwt.RegisteredClaims
NamespaceID string `json:"namespace_id"`
NamespacePath string `json:"namespace_path"`
ProjectID string `json:"project_id"`
ProjectPath string `json:"project_path"`
UserID string `json:"user_id"`
UserLogin string `json:"user_login"`
UserEmail string `json:"user_email"`
PipelineID string `json:"pipeline_id"`
PipelineSource string `json:"pipeline_source"`
JobID string `json:"job_id"`
Ref string `json:"ref"`
RefType string `json:"ref_type"`
RefProtected string `json:"ref_protected"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler( authenticationProvider AuthenticationProvider, authorizer Authorizer, config Config, ) *Handler
type RegoAuthorizer ¶
type RegoAuthorizer struct {
// contains filtered or unexported fields
}
func NewRegoAuthorizer ¶
func (*RegoAuthorizer) AllowPatch ¶
type RepositoriesConfig ¶
type RepositoriesConfig map[string]RepositoryConfig
type RepositoryConfig ¶
type RepositoryConfig struct {
URL string `yaml:"url"`
BasicAuth *BasicAuthConfig `yaml:"basicAuth"`
}
type SignatureConfig ¶
func (SignatureConfig) Valid ¶
func (c SignatureConfig) Valid() error
type ViolationsResolver ¶
type ViolationsResolver interface {
Violations() []string
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.