Documentation
¶
Overview ¶
Package gitlabpat contains a Veles Secret type and a Detector for Gitlab Personal Access Tokens (prefix `glpat-`).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDetector ¶
NewDetector returns a new Detector that matches Gitlab Personal Access Tokens.
Types ¶
type GitlabPAT ¶
type GitlabPAT struct {
Pat string
}
GitlabPAT is a Veles Secret that holds relevant information for a Gitlab Personal Access Tokens (prefix `glpat-`). GitlabPAT represents PAT and used to authenticate requests
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates Gitlab PATs via the Gitlab API endpoint.
func NewValidator ¶
func NewValidator(opts ...ValidatorOption) *Validator
NewValidator creates a new Validator with the given ValidatorOptions.
func (*Validator) Validate ¶
Validate checks whether the given GitlabPAT is valid.
It performs a GET request to the gitlab.com access token endpoint using the PAT in the PRIVATE-TOKEN header. If the request returns HTTP 200, the key is considered valid. If 401 Unauthorized, the key is invalid. Other errors return ValidationFailed.
type ValidatorOption ¶
type ValidatorOption func(*Validator)
ValidatorOption configures a Validator when creating it via NewValidator.
func WithClient ¶
func WithClient(c *http.Client) ValidatorOption
WithClient configures the http.Client that the Validator uses.
By default, it uses http.DefaultClient.