Documentation
¶
Index ¶
- Variables
- func IsValidTokenPrefix(token string) bool
- type Repository
- type Service
- func (s *Service) DeleteToken(ctx context.Context) error
- func (s *Service) GetClient() *github.Client
- func (s *Service) GetToken() string
- func (s *Service) HasToken() bool
- func (s *Service) IsFineGrained() bool
- func (s *Service) Load(ctx context.Context) error
- func (s *Service) SaveToken(ctx context.Context, plaintext string) error
Constants ¶
This section is empty.
Variables ¶
var ErrTokenNotFound = errors.New("github token not found")
ErrTokenNotFound is returned when no GitHub token is stored.
Functions ¶
func IsValidTokenPrefix ¶
IsValidTokenPrefix checks whether a token has a recognised GitHub PAT prefix.
Types ¶
type Repository ¶
type Repository interface {
UpsertGitHubToken(ctx context.Context, encryptedToken string, now time.Time) error
ReadGitHubToken(ctx context.Context) (string, error)
DeleteGitHubToken(ctx context.Context) error
}
Repository defines the data access methods for the encrypted GitHub token.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages the GitHub token lifecycle: encryption, storage, and in-memory caching of the decrypted token and GitHub client.
func NewService ¶
func NewService(repo Repository, encryptionKey []byte, insecureSkipVerify bool) *Service
NewService creates a new GitHubTokenService.
func (*Service) DeleteToken ¶
DeleteToken removes the token from the database and clears the in-memory cache.
func (*Service) GetClient ¶
GetClient returns the cached GitHub client. Returns nil if no token is configured.
func (*Service) GetToken ¶
GetToken returns the cached decrypted token. Returns empty string if no token is configured.
func (*Service) IsFineGrained ¶
IsFineGrained reports whether the configured token is a fine-grained PAT.