Skip to content

Commit

Permalink
don't check errors generated by current token (#6)
Browse files Browse the repository at this point in the history
refresh instead
  • Loading branch information
baptiste-b-pegasys authored Aug 16, 2022
1 parent 59ffe11 commit b9c5eda
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,11 @@ func (h *QlightTokenManagerPluginImpl) TokenRefresh(ctx context.Context, req *pr
split := strings.Split(token, ".")
log.Printf("split=%v\n", split)

data, err := base64.RawStdEncoding.DecodeString(split[1])
if err != nil {
return nil, err
}
data, _ := base64.RawStdEncoding.DecodeString(split[1]) // ignore error, we will refresh anyway in this case
log.Printf("json=%s\n", string(data))

jwt := &JWT{}
err = json.Unmarshal(data, jwt)
if err != nil {
return nil, err
}
json.Unmarshal(data, jwt) // ignore error, we will refresh anyway in this case

log.Printf("expireAt=%v\n", jwt.ExpireAt)
expireAt := time.Unix(jwt.ExpireAt, 0)
Expand Down Expand Up @@ -175,7 +169,7 @@ func (h *QlightTokenManagerPluginImpl) TokenRefresh(ctx context.Context, req *pr
}
}

err = writer.Close()
err := writer.Close()
if err != nil {
return nil, err
}
Expand All @@ -190,7 +184,7 @@ func (h *QlightTokenManagerPluginImpl) TokenRefresh(ctx context.Context, req *pr
for key, template := range h.cfg.Parameters {
m[key] = strings.Replace(template, "${PSI}", req.Psi, -1)
}
err = json.NewEncoder(body).Encode(m)
err := json.NewEncoder(body).Encode(m)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b9c5eda

Please sign in to comment.