Code cleanup modules updated
This commit is contained in:
38
main.go
38
main.go
@@ -9,13 +9,8 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
//audience string
|
||||
//domain string
|
||||
)
|
||||
|
||||
func main() {
|
||||
//setAuth0Variables()
|
||||
|
||||
fmt.Println("Hallo")
|
||||
r := gin.Default()
|
||||
r.Use(CORSMiddleware())
|
||||
@@ -28,10 +23,7 @@ func main() {
|
||||
c.File("./ui/dist/ui/" + path.Join(dir, file))
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
//authorized := r.Group("/")
|
||||
//authorized.Use(authRequired())
|
||||
r.GET("/besucher", handlers.GetBesucherListHandler)
|
||||
r.POST("/besucher", handlers.AddBesucherHandler)
|
||||
r.DELETE("/besucher/:id", handlers.DeleteBesucherHandler)
|
||||
@@ -43,7 +35,6 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func CORSMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
@@ -58,31 +49,8 @@ func CORSMiddleware() gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
/*func setAuth0Variables() {
|
||||
audience = "https://hochzeit-api" //os.Getenv("AUTH0_API_IDENTIFIER")
|
||||
domain = "dev-uzlaiuax.eu.auth0.com/" //os.Getenv("AUTH0_DOMAIN")
|
||||
}
|
||||
|
||||
func authRequired() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
var auth0Domain = "https://" + domain + "/"
|
||||
client := auth0.NewJWKClient(auth0.JWKClientOptions{URI: auth0Domain + ".well-known/jwks.json"}, nil)
|
||||
configuration := auth0.NewConfiguration(client, []string{audience}, auth0Domain, jose.RS256)
|
||||
validator := auth0.NewValidator(configuration, 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) {
|
||||
/*func terminateWithError(statusCode int, message string, c *gin.Context) {
|
||||
c.JSON(statusCode, gin.H{"error": message})
|
||||
c.Abort()
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user