Skip to content

Commit

Permalink
clean the clode
Browse files Browse the repository at this point in the history
  • Loading branch information
chang-you committed Jul 6, 2023
1 parent 7fdd47d commit 49fe984
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions examples/spire_producer.example/spire_producer.example.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/spiffe/go-spiffe/v2/workloadapi"
"os"
"os/signal"
"regexp"
"syscall"
"time"

Expand All @@ -16,25 +15,6 @@ import (
_ "github.com/spiffe/go-spiffe/v2/svid/jwtsvid"
)

var (
// Regex for sasl.oauthbearer.config, which constrains it to be
// 1 or more name=value pairs with optional ignored whitespace
oauthbearerConfigRegex = regexp.MustCompile("^(\\s*(\\w+)\\s*=\\s*(\\w+))+\\s*$")
// Regex used to extract name=value pairs from sasl.oauthbearer.config
oauthbearerNameEqualsValueRegex = regexp.MustCompile("(\\w+)\\s*=\\s*(\\w+)")
)

const (
principalClaimNameKey = "principalClaimName"
principalKey = "principal"
joseHeaderEncoded = "eyJhbGciOiJub25lIn0" // {"alg":"none"}
)

type tokenAuth struct {
audience []string
tokenSource *workloadapi.JWTSource
}

// handleJWTTokenRefreshEvent retrieves JWT from the SPIRE workload API and
// sets the token on the client for use in any future authentication attempt.
// It must be invoked whenever kafka.OAuthBearerTokenRefresh appears on the client's event channel,
Expand All @@ -61,7 +41,7 @@ func retrieveJWTToken(ctx context.Context, principal, socketPath string, audienc
ctx,
workloadapi.WithClientOptions(workloadapi.WithAddr(socketPath)),
)
//workloadapi.ValidateJWTSVID()

if err != nil {
return kafka.OAuthBearerToken{}, nil, fmt.Errorf("unable to create JWTSource: %w", err)
}
Expand Down

0 comments on commit 49fe984

Please sign in to comment.