Skip to content

Commit

Permalink
Returned CSRF token with profile for ease of use by frontend and remo…
Browse files Browse the repository at this point in the history
…ved cdnjs.cloudflare.com from default CDN whitelist
  • Loading branch information
Jonathan Cooper committed Jul 13, 2020
1 parent 4cbde23 commit a2276ce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cmd/wireguardhttps.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ func main() {
Required: true,
},
&cli.StringSliceFlag{
Name: "allowed-cdn",
Usage: "whitelisted CDNs for the CSP",
Value: cli.NewStringSlice("cdnjs.cloudflare.com"),
Name: "allowed-cdn",
Usage: "whitelisted CDNs for the CSP",
Required: false,
},
},
Action: actionServe,
Expand Down
2 changes: 2 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"

"github.com/gin-gonic/gin"
"github.com/gorilla/csrf"
"github.com/joncooperworks/wgrpcd"
"github.com/markbates/goth/gothic"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
Expand Down Expand Up @@ -244,6 +245,7 @@ func (wh *WireguardHandlers) ListUserDevicesHandler(c *gin.Context) {

func (wh *WireguardHandlers) UserProfileInfoHandler(c *gin.Context) {
user := wh.user(c)
c.Header("X-CSRF-Token", csrf.Token(c.Request))
c.JSON(http.StatusOK, user)
}

Expand Down
2 changes: 0 additions & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"net/http"

"github.com/gin-gonic/gin"
"github.com/gorilla/csrf"
"github.com/gorilla/sessions"
"github.com/markbates/goth"
"github.com/markbates/goth/gothic"
Expand Down Expand Up @@ -48,7 +47,6 @@ func AuthenticationRequiredMiddleware(store sessions.Store, sessionName string)
}

c.Set("user", user)
c.Header("X-CSRF-Token", csrf.Token(c.Request))
c.Next()
}
}

0 comments on commit a2276ce

Please sign in to comment.