auth

package
v0.0.0-...-a6f4648 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package auth provides common authentication utilities for Git platforms.

Package auth provides comprehensive authentication validation and management for various Git hosting platforms and service integrations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimitInfo

type RateLimitInfo struct {
	Limit     int       `json:"limit"`
	Remaining int       `json:"remaining"`
	ResetTime time.Time `json:"resetTime"`
}

RateLimitInfo contains rate limiting information.

type TokenInfo

type TokenInfo struct {
	Type        TokenType              `json:"type"`
	Valid       bool                   `json:"valid"`
	Username    string                 `json:"username,omitempty"`
	Scopes      []string               `json:"scopes,omitempty"`
	ExpiresAt   *time.Time             `json:"expiresAt,omitempty"`
	RateLimit   *RateLimitInfo         `json:"rateLimit,omitempty"`
	Permissions map[string]bool        `json:"permissions,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

TokenInfo contains information about a validated token.

type TokenManager

type TokenManager struct {
	// contains filtered or unexported fields
}

TokenManager handles common token authentication logic across Git platforms.

func NewTokenManager

func NewTokenManager(environment env.Environment) *TokenManager

NewTokenManager creates a new token manager.

func (*TokenManager) SetupTokenAuth

func (tm *TokenManager) SetupTokenAuth(token, platform string) (*provider.Credentials, error)

SetupTokenAuth sets up token authentication for a Git platform.

type TokenType

type TokenType string

TokenType represents different authentication token types.

const (
	// TokenTypeGitHub represents GitHub authentication tokens.
	TokenTypeGitHub TokenType = "github"
	// TokenTypeGitLab represents GitLab authentication tokens.
	TokenTypeGitLab TokenType = "gitlab"
	// TokenTypeGitea represents Gitea authentication tokens.
	TokenTypeGitea TokenType = "gitea"
	// TokenTypeGogs represents Gogs authentication tokens.
	TokenTypeGogs TokenType = "gogs"
	// TokenTypeBitbucket represents Bitbucket authentication tokens.
	TokenTypeBitbucket TokenType = "bitbucket"
	// TokenTypeAzureDevOps represents Azure DevOps authentication tokens.
	TokenTypeAzureDevOps TokenType = "azuredevops"
	// TokenTypeGeneric represents generic authentication tokens.
	TokenTypeGeneric TokenType = "generic"
)

Supported token types for various Git hosting platforms.

type ValidationResult

type ValidationResult struct {
	Valid       bool            `json:"valid"`
	TokenInfo   *TokenInfo      `json:"tokenInfo,omitempty"`
	Errors      []string        `json:"errors,omitempty"`
	Warnings    []string        `json:"warnings,omitempty"`
	Suggestions []string        `json:"suggestions,omitempty"`
	TestResults map[string]bool `json:"testResults,omitempty"`
	Duration    time.Duration   `json:"duration"`
	Timestamp   time.Time       `json:"timestamp"`
}

ValidationResult contains comprehensive validation results.

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator provides comprehensive authentication validation.

func NewValidator

func NewValidator() *Validator

NewValidator creates a new authentication validator.

func (*Validator) SecureTokenComparison

func (av *Validator) SecureTokenComparison(token1, token2 string) bool

SecureTokenComparison compares tokens using constant-time comparison.

func (*Validator) ValidateToken

func (av *Validator) ValidateToken(ctx context.Context, token string, tokenType TokenType) (*ValidationResult, error)

ValidateToken performs comprehensive token validation.

Jump to

Keyboard shortcuts

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