This reverts commit 3713b793a3.
This commit is contained in:
committed by
GitHub Enterprise
parent
3713b793a3
commit
12ce39cb77
@@ -56,23 +56,6 @@ func (s *Server) createMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
whitelistedDomains := getWhitelistedDomains()
|
||||
|
||||
//cors handling
|
||||
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Headers", viper.GetString("allowed.custom.headers"))
|
||||
|
||||
origin := c.Request.Header.Get("Origin")
|
||||
if !whitelistedDomains[origin] {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
c.Writer.Header().Set("Access-Control-Allow-Origin", origin)
|
||||
|
||||
if c.Request.Method == "OPTIONS" {
|
||||
c.AbortWithStatus(http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
//auth handling
|
||||
isAuthEnabled := viper.GetBool("auth.enabled")
|
||||
if isAuthEnabled {
|
||||
@@ -83,6 +66,21 @@ func (s *Server) createMiddleware() gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
//cors handling
|
||||
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Headers", viper.GetString("allowed.custom.headers"))
|
||||
origin := c.Request.Header.Get("Origin")
|
||||
if !whitelistedDomains[origin] {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
c.Writer.Header().Set("Access-Control-Allow-Origin", origin)
|
||||
|
||||
if c.Request.Method == "OPTIONS" {
|
||||
c.AbortWithStatus(http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
startTime := time.Now()
|
||||
c.Next()
|
||||
endTime := float64(time.Since(startTime))
|
||||
|
||||
Reference in New Issue
Block a user