go: update most dependencies to the latest version

It's a lot of work for dependabot for our outdated deps, let's
help it by making one huge manual update.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2021-09-05 11:41:20 +02:00 committed by Tom Gundersen
parent 08a937c9c1
commit 19a3bdf450
595 changed files with 91597 additions and 21922 deletions

View file

@ -22,7 +22,7 @@ import (
"context"
"fmt"
"github.com/dgrijalva/jwt-go"
"github.com/golang-jwt/jwt"
)
// ContextWithToken creates a new context containing the given token.

View file

@ -35,8 +35,8 @@ import (
"sync"
"time"
"github.com/dgrijalva/jwt-go"
"github.com/ghodss/yaml"
"github.com/golang-jwt/jwt"
"github.com/openshift-online/ocm-sdk-go/errors"
"github.com/openshift-online/ocm-sdk-go/logging"
@ -828,18 +828,21 @@ func (h *Handler) checkToken(w http.ResponseWriter, r *http.Request,
// something is wrong it sends an error response to the client and returns false.
func (h *Handler) checkClaims(w http.ResponseWriter, r *http.Request,
claims jwt.MapClaims) bool {
value, ok := h.checkStringClaim(w, r, claims, "typ")
// Check the token type:
typ, ok := h.checkStringClaim(w, r, claims, "typ")
if !ok {
return false
}
if !strings.EqualFold(value, "Bearer") {
if !strings.EqualFold(typ, "Bearer") {
h.sendError(
w, r,
"Bearer token type '%s' isn't supported",
value,
typ,
)
return false
}
// Check the format of the issue and expiration date claims:
_, ok = h.checkTimeClaim(w, r, claims, "iat")
if !ok {
return false
@ -848,6 +851,27 @@ func (h *Handler) checkClaims(w http.ResponseWriter, r *http.Request,
if !ok {
return false
}
// Make sure that the impersonation flag claim doesn't exist, or is `false`:
value, ok := claims["impersonated"]
if ok {
flag, ok := value.(bool)
if !ok {
h.sendError(
w, r,
"Impersonation claim contains incorrect boolean value '%v'",
value,
)
return false
}
if flag {
h.sendError(
w, r,
"Impersonation isn't allowed",
)
return false
}
}
return true
}

View file

@ -22,7 +22,7 @@ import (
"fmt"
"time"
"github.com/dgrijalva/jwt-go"
"github.com/golang-jwt/jwt"
)
// tokenRemaining determines if the given token will eventually expire (offile access tokens, for

View file

@ -35,7 +35,7 @@ import (
//
"github.com/cenkalti/backoff/v4"
jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
"github.com/openshift-online/ocm-sdk-go/internal"
"github.com/openshift-online/ocm-sdk-go/logging"
"github.com/prometheus/client_golang/prometheus"
@ -612,14 +612,14 @@ func (w *TransportWrapper) Tokens(ctx context.Context, expiresIn ...time.Duratio
code, access, refresh, err = w.tokens(ctx, attempt, expiresDuration)
if err != nil {
if code >= http.StatusInternalServerError {
w.logger.Error(
w.logger.Debug(
ctx,
"Can't get tokens, got HTTP code %d, will retry: %v",
code, err,
)
return err
}
w.logger.Error(
w.logger.Debug(
ctx,
"Can't get tokens, got HTTP code %d, will not retry: %v",
code, err,
@ -628,7 +628,7 @@ func (w *TransportWrapper) Tokens(ctx context.Context, expiresIn ...time.Duratio
}
if attempt > 1 {
w.logger.Info(ctx, "Got tokens on attempt %d", attempt)
w.logger.Debug(ctx, "Got tokens on attempt %d", attempt)
} else {
w.logger.Debug(ctx, "Got tokens on first attempt")
}