-
Notifications
You must be signed in to change notification settings - Fork 362
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
unable to find source related to: "github.com/auth0-community/go-auth0" #300
Comments
Could you provide more information: how you produce the error exactly? What's your OS? lib or command-line? Thanks. |
package main
import (
"fmt"
"github.com/auth0-community/go-auth0"
"github.com/gin-gonic/gin"
jose "gopkg.in/square/go-jose.v2"
"log"
"net/http"
"github.com/gin-contrib/cors"
"time"
)
var (
audience string
domain string
)
type Response struct{
Status string
}
func test(c *gin.Context){
var response Response
response.Status = "Ok"
c.JSON(http.StatusOK,response)
}
func setAuth0Variables() {
audience = "tsure--api"
domain = "t-trove.eu.auth0.com"
}
func authRequired() gin.HandlerFunc {
return func(c *gin.Context) {
var auth0Domain = "https://" + domain + "/"
jwkClient := auth0.NewJWKClient(auth0.JWKClientOptions{URI: fmt.Sprintf("%s.well-known/jwks.json", auth0Domain)}, nil)
validator := auth0.NewValidator(auth0.NewConfiguration(jwkClient, []string{}, auth0Domain, jose.RS256), nil)
_, err := validator.ValidateRequest(c.Request)
if err != nil {
log.Println(err)
terminateWithError(http.StatusUnauthorized, "token is not valid", c)
return
}
c.Next()
}
}
func terminateWithError(statusCode int, message string, c *gin.Context) {
c.JSON(statusCode, gin.H{"error": message})
c.Abort()
}
func main() {
setAuth0Variables()
r := gin.Default()
//r.Use(cors.Default())
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"},
AllowMethods: []string{"PUT", "PATCH","POST","OPTIONS"},
AllowHeaders: []string{"Origin,Authorization,Token"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
AllowOriginFunc: func(origin string) bool {
return origin == "*"
},
MaxAge: 12 * time.Hour,
}))
authorized := r.Group("/")
authorized.Use(authRequired())
authorized.POST("test/", test)
authorized.GET("test/", test)
authorized.OPTIONS("test/", test)
r.Run((":8200")) // listen and serve on 0.0.0.0:8080
} |
Simpler repro:
Which seems to show that the original issue is fixed, but that we now have a different problem:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following program
sample.go
triggers a panic:It seems to have a problem with thos package when i try to run a program with this pckage.
regards
The text was updated successfully, but these errors were encountered: