Skip to content

Commit

Permalink
Update deps and fix example (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahParks authored Jan 14, 2025
1 parent 54c2a0a commit b9d5f65
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
12 changes: 3 additions & 9 deletions examples/advanced/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"log/slog"
"net/http"
"net/http/httptest"
"net/url"
"time"

"github.com/MicahParks/jwkset"
Expand Down Expand Up @@ -70,10 +69,6 @@ func main() {
// Create the JWK Set HTTP clients.
remoteJWKSets := make(map[string]jwkset.Storage)
for _, u := range []string{s1.URL, s2.URL} {
ur, err := url.ParseRequestURI(u)
if err != nil {
log.Fatalf("Failed to parse given URL %q: %s", u, err)
}
jwksetHTTPStorageOptions := jwkset.HTTPClientStorageOptions{
Client: http.DefaultClient, // Could be replaced with a custom client.
Ctx: ctx, // Used to end background refresh goroutine.
Expand All @@ -84,17 +79,16 @@ func main() {
RefreshErrorHandler: func(ctx context.Context, err error) {
slog.Default().ErrorContext(ctx, "Failed to refresh HTTP JWK Set from remote HTTP resource.",
"error", err,
"url", ur.String(),
"url", u,
)
},
RefreshInterval: time.Hour,
Storage: nil,
}
store, err := jwkset.NewStorageFromHTTP(ur, jwksetHTTPStorageOptions)
store, err := jwkset.NewStorageFromHTTP(u, jwksetHTTPStorageOptions)
if err != nil {
log.Fatalf("Failed to create HTTP client storage for %q: %s", u, err)
}
remoteJWKSets[ur.String()] = store
remoteJWKSets[u] = store
}

// Create the JWK Set containing HTTP clients and given keys.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/MicahParks/keyfunc/v3
go 1.21

require (
github.com/MicahParks/jwkset v0.7.0
github.com/MicahParks/jwkset v0.8.0
github.com/golang-jwt/jwt/v5 v5.2.1
golang.org/x/time v0.9.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/MicahParks/jwkset v0.7.0 h1:CXWuiYBk5NuTl+N/3UI3UcYNH79yWuKAZWZkc/y+7Ok=
github.com/MicahParks/jwkset v0.7.0/go.mod h1:fVrj6TmG1aKlJEeceAz7JsXGTXEn72zP1px3us53JrA=
github.com/MicahParks/jwkset v0.8.0 h1:jHtclI38Gibmu17XMI6+6/UB59srp58pQVxePHRK5o8=
github.com/MicahParks/jwkset v0.8.0/go.mod h1:fVrj6TmG1aKlJEeceAz7JsXGTXEn72zP1px3us53JrA=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
Expand Down

0 comments on commit b9d5f65

Please sign in to comment.