Skip to content

Commit 3f2998d

Browse files
committed
print OIDC debug logs
1 parent 367a139 commit 3f2998d

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

general/token/oidctokenexchange.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/jfrog/jfrog-client-go/utils/log"
1111
"os"
1212
"strings"
13-
"time"
1413
)
1514

1615
const (
@@ -163,13 +162,11 @@ func (otc *OidcTokenExchangeCommand) Run() (err error) {
163162
// Update the config server details with the exchanged token
164163
otc.serverDetails.AccessToken = otc.response.AccessToken
165164

166-
// Safe to log token details for easier debugging
167-
log.Debug("Token Scope: ", otc.response.Scope)
168-
if otc.response.ExpiresIn != nil {
169-
expirationTime := time.Now().Add(time.Duration(*otc.response.ExpiresIn) * time.Second)
170-
log.Debug("Token Expiration Date: ", expirationTime)
165+
// Log token details
166+
if err = otc.logTokenDetails(); err != nil {
167+
log.Warn("Failed to log token details, error: ", err)
171168
}
172-
log.Debug("Token Audience: ", otc.response.Audience)
169+
173170
return
174171
}
175172

@@ -187,3 +184,17 @@ func (otc *OidcTokenExchangeCommand) getOidcTokenParams() services.CreateOidcTok
187184
oidcTokenParams.ProviderName = otc.ProviderName
188185
return oidcTokenParams
189186
}
187+
188+
// logTokenDetails logs the token details (scope and expiry) for debugging purposes.
189+
func (otc *OidcTokenExchangeCommand) logTokenDetails() error {
190+
expiry, err := auth.ExtractExpiryFromAccessToken(otc.response.AccessToken)
191+
if err != nil {
192+
return err
193+
}
194+
scope, err := auth.ExtractScopeFromAccessToken(otc.response.AccessToken)
195+
if err != nil {
196+
return err
197+
}
198+
log.Debug("Debug OIDC token values: scope: ", scope, ", expiry: ", expiry)
199+
return nil
200+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ require (
114114
sigs.k8s.io/yaml v1.4.0 // indirect
115115
)
116116

117-
replace github.com/jfrog/jfrog-client-go => github.com/eyalDelarea/jfrog-client-go v1.28.1-0.20250403122513-763f90022e24
117+
replace github.com/jfrog/jfrog-client-go => github.com/eyalDelarea/jfrog-client-go v1.28.1-0.20250406091418-22e4da0e8f72
118118

119119
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20250226091544-c803cbbc5495
120120

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o
5454
github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE=
5555
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
5656
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
57-
github.com/eyalDelarea/jfrog-client-go v1.28.1-0.20250403122513-763f90022e24 h1:6TajSkKorO4j0qYCTCfr1k+f+OTCzfrer7a7S+w2+sc=
58-
github.com/eyalDelarea/jfrog-client-go v1.28.1-0.20250403122513-763f90022e24/go.mod h1:uRmT8Q1SJymIzId01v0W1o8mGqrRfrwUF53CgEMsH0U=
57+
github.com/eyalDelarea/jfrog-client-go v1.28.1-0.20250406091418-22e4da0e8f72 h1:2FVWrTG/YcpfHQP/pQJbnC7IRPfxJU4Jmll9RfzQbhw=
58+
github.com/eyalDelarea/jfrog-client-go v1.28.1-0.20250406091418-22e4da0e8f72/go.mod h1:uRmT8Q1SJymIzId01v0W1o8mGqrRfrwUF53CgEMsH0U=
5959
github.com/forPelevin/gomoji v1.3.0 h1:WPIOLWB1bvRYlKZnSSEevLt3IfKlLs+tK+YA9fFYlkE=
6060
github.com/forPelevin/gomoji v1.3.0/go.mod h1:mM6GtmCgpoQP2usDArc6GjbXrti5+FffolyQfGgPboQ=
6161
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=

0 commit comments

Comments
 (0)