Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions components/backend/handlers/integrations_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package handlers
import (
"context"
"net/http"
"time"

"github.com/gin-gonic/gin"
)
Expand Down Expand Up @@ -63,13 +62,13 @@ func getGitHubStatusForUser(ctx context.Context, userID string) gin.H {
// Check GitHub PAT
patCreds, err := GetGitHubPATCredentials(ctx, userID)
if err == nil && patCreds != nil {
// Validate PAT token
valid, _ := ValidateGitHubToken(ctx, patCreds.Token)
// NOTE: Validation disabled - if credentials are stored, assume they're valid
// The integration will fail gracefully if credentials are actually invalid

status["pat"] = gin.H{
"configured": true,
"updatedAt": patCreds.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"),
"valid": valid,
"valid": true,
}
}

Expand All @@ -89,19 +88,15 @@ func getGoogleStatusForUser(ctx context.Context, userID string) gin.H {
return gin.H{"connected": false}
}

// Check if token is expired
isExpired := time.Now().After(creds.ExpiresAt)
valid := !isExpired

// If near expiry, could validate with Google API, but checking expiry is sufficient
// since backend auto-refreshes tokens
// NOTE: Validation disabled - if credentials are stored, assume they're valid
// The backend auto-refreshes tokens and the integration will fail gracefully if invalid

return gin.H{
"connected": true,
"email": creds.Email,
"expiresAt": creds.ExpiresAt.Format("2006-01-02T15:04:05Z07:00"),
"updatedAt": creds.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"),
"valid": valid,
"valid": true,
}
}

Expand Down Expand Up @@ -131,13 +126,13 @@ func getGitLabStatusForUser(ctx context.Context, userID string) gin.H {
return gin.H{"connected": false}
}

// Validate token
valid, _ := ValidateGitLabToken(ctx, creds.Token, creds.InstanceURL)
// NOTE: Validation disabled - if credentials are stored, assume they're valid
// The integration will fail gracefully if credentials are actually invalid

return gin.H{
"connected": true,
"instanceUrl": creds.InstanceURL,
"updatedAt": creds.UpdatedAt,
"valid": valid,
"valid": true,
}
}
18 changes: 15 additions & 3 deletions components/backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,25 @@ func main() {
// Initialize git package
git.GetProjectSettingsResource = k8s.GetProjectSettingsResource
git.GetGitHubInstallation = func(ctx context.Context, userID string) (interface{}, error) {
return github.GetInstallation(ctx, userID)
installation, err := github.GetInstallation(ctx, userID)
if installation == nil {
return nil, err
}
return installation, err
}
git.GetGitHubPATCredentials = func(ctx context.Context, userID string) (interface{}, error) {
return handlers.GetGitHubPATCredentials(ctx, userID)
creds, err := handlers.GetGitHubPATCredentials(ctx, userID)
if creds == nil {
return nil, err
}
return creds, err
}
git.GetGitLabCredentials = func(ctx context.Context, userID string) (interface{}, error) {
return handlers.GetGitLabCredentials(ctx, userID)
creds, err := handlers.GetGitLabCredentials(ctx, userID)
if creds == nil {
return nil, err
}
return creds, err
}
git.GitHubTokenManager = github.Manager
git.GetBackendNamespace = func() string {
Expand Down
Loading