Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use keyFunc as type func(context.Context) #278

Open
6 tasks done
barrychapman-scout opened this issue Jul 25, 2024 · 1 comment
Open
6 tasks done

Cannot use keyFunc as type func(context.Context) #278

barrychapman-scout opened this issue Jul 25, 2024 · 1 comment
Labels
bug This issue reports a suspect bug or issue with the SDK itself

Comments

@barrychapman-scout
Copy link

barrychapman-scout commented Jul 25, 2024

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have upgraded to the latest version of this SDK and the issue still persists.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

I am following the example in the README, and am receiving the following error:

Cannot use 'keyFunc' (type func(ctx context.Context) (interface{}, error)) as the type func(context.Context) (interface{}, error)

The only thing I can surmise is that I am using beego, but from what I could tell - it is the same context.

	keyFunc := func(ctx context.Context) (interface{}, error) {
		// Our token must be signed using this data.
		return []byte("secret"), nil
	}

	// Set up the validator.
	jwtValidator, err := validator.New(
		keyFunc,             // error occurs here
		validator.HS256,
		"https://<issuer-url>/",
		[]string{"<audience>"},
	)
	if err != nil {
		log.Fatalf("failed to set up the validator: %v", err)
	}

	middleware := jwtmiddleware.New(jwtValidator.ValidateToken)

Reproduction

Using latest SDK, used github.com/form3tech-oss/jwt-go instead of the prior.

When copying the keyFunc declaration along with the validator creator, it throws that error.

Go JWT Middleware version

2 .2.1

Go version

1.22.5 darwin/arm64

@barrychapman-scout barrychapman-scout added the bug This issue reports a suspect bug or issue with the SDK itself label Jul 25, 2024
@barrychapman-scout
Copy link
Author

Does anyone have any idea about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue reports a suspect bug or issue with the SDK itself
Projects
None yet
Development

No branches or pull requests

1 participant