Documentation
¶
Index ¶
- type Authenticator
- func (a *Authenticator) GenerateJWT(appID int64, privateKeyPath string) (string, error)
- func (a *Authenticator) GenerateJWTForApp(app *config.GitHubApp) (string, error)
- func (a *Authenticator) GetCredentials(app *config.GitHubApp, repoURL string) (token, username string, err error)
- func (a *Authenticator) GetInstallationToken(jwtToken string, installationID int64, repoURL string) (string, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator handles GitHub App authentication.
func NewAuthenticator ¶
func NewAuthenticator() *Authenticator
NewAuthenticator creates a new authenticator.
func (*Authenticator) GenerateJWT ¶
func (a *Authenticator) GenerateJWT(appID int64, privateKeyPath string) (string, error)
GenerateJWT generates a JWT token for the GitHub App (legacy file-based method).
func (*Authenticator) GenerateJWTForApp ¶
func (a *Authenticator) GenerateJWTForApp(app *config.GitHubApp) (string, error)
GenerateJWTForApp generates a JWT token using the app's configured private key source.
func (*Authenticator) GetCredentials ¶
func (a *Authenticator) GetCredentials(app *config.GitHubApp, repoURL string) (token, username string, err error)
GetCredentials returns username and token for git credential helper.
Example ¶
Example showing the authentication flow
// This example shows the expected flow for GetCredentials
// Real implementation requires GitHub API mock server
fmt.Println("Authentication flow:")
fmt.Println("1. Check cache for existing token")
fmt.Println("2. If not cached, generate JWT")
fmt.Println("3. Exchange JWT for installation token")
fmt.Println("4. Cache the installation token")
fmt.Println("5. Return token and username")
Output: Authentication flow: 1. Check cache for existing token 2. If not cached, generate JWT 3. Exchange JWT for installation token 4. Cache the installation token 5. Return token and username
func (*Authenticator) GetInstallationToken ¶
func (a *Authenticator) GetInstallationToken(jwtToken string, installationID int64, repoURL string) (string, error)
GetInstallationToken exchanges JWT for an installation access token.
Click to show internal directories.
Click to hide internal directories.