Skip to content

Commit

Permalink
remove print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
kailashchoudhary11 committed Jul 4, 2024
1 parent 56208ed commit e84445a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion handlers/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func Webhook(w http.ResponseWriter, r *http.Request) {
fmt.Println("Inside webhook")
clientId := os.Getenv("CLIENT_ID")
jwtToken, err := services.GenerateJWTForApp(clientId, "repository-guard.2024-07-02.private-key.pem")
fmt.Println("Token", jwtToken)
if err != nil {
fmt.Println("Error: ", err)
return
Expand Down
13 changes: 7 additions & 6 deletions services/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ func CloseIssue(client *github.Client, repo models.Repository, issueNumber int,

func GenerateJWTForApp(clientId, filePath string) (string, error) {
// Read the private key
privatePem, err := os.ReadFile(filePath)
if err != nil {
return "", err
}
privatePem := os.Getenv("PRIVATE_KEY")

// Parse the PEM block
block, _ := pem.Decode(privatePem)
block, _ := pem.Decode([]byte(privatePem))
if block == nil || block.Type != "RSA PRIVATE KEY" {
return "", err
fmt.Println("block")
fmt.Println("Could not generate")
return "", nil
}

// Parse the RSA private key
privateKey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
if err != nil {
fmt.Println("No token")
return "", err
}

Expand All @@ -141,6 +141,7 @@ func GenerateJWTForApp(clientId, filePath string) (string, error) {
// Sign the token with the private key
tokenString, err := token.SignedString(privateKey)
if err != nil {
fmt.Println("No token")
return "", err
}

Expand Down

0 comments on commit e84445a

Please sign in to comment.