@@ -178,7 +178,7 @@ type executableResponse struct {
178
178
Message string `json:"message,omitempty"`
179
179
}
180
180
181
- func parseSubjectTokenFromSource (response []byte , source string , now int64 ) (string , error ) {
181
+ func ( cs executableCredentialSource ) parseSubjectTokenFromSource (response []byte , source string , now int64 ) (string , error ) {
182
182
var result executableResponse
183
183
if err := json .Unmarshal (response , & result ); err != nil {
184
184
return "" , jsonParsingError (source , string (response ))
@@ -203,15 +203,15 @@ func parseSubjectTokenFromSource(response []byte, source string, now int64) (str
203
203
return "" , unsupportedVersionError (source , result .Version )
204
204
}
205
205
206
- if result .ExpirationTime == 0 {
206
+ if result .ExpirationTime == 0 && cs . OutputFile != "" {
207
207
return "" , missingFieldError (source , "expiration_time" )
208
208
}
209
209
210
210
if result .TokenType == "" {
211
211
return "" , missingFieldError (source , "token_type" )
212
212
}
213
213
214
- if result .ExpirationTime < now {
214
+ if result .ExpirationTime != 0 && result . ExpirationTime < now {
215
215
return "" , tokenExpiredError ()
216
216
}
217
217
@@ -259,7 +259,7 @@ func (cs executableCredentialSource) getTokenFromOutputFile() (token string, err
259
259
return "" , nil
260
260
}
261
261
262
- token , err = parseSubjectTokenFromSource (data , outputFileSource , cs .env .now ().Unix ())
262
+ token , err = cs . parseSubjectTokenFromSource (data , outputFileSource , cs .env .now ().Unix ())
263
263
if err != nil {
264
264
if _ , ok := err .(nonCacheableError ); ok {
265
265
// If the cached token is expired we need a new token,
@@ -304,5 +304,5 @@ func (cs executableCredentialSource) getTokenFromExecutableCommand() (string, er
304
304
if err != nil {
305
305
return "" , err
306
306
}
307
- return parseSubjectTokenFromSource (output , executableSource , cs .env .now ().Unix ())
307
+ return cs . parseSubjectTokenFromSource (output , executableSource , cs .env .now ().Unix ())
308
308
}
0 commit comments