mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
refactor(api): update the way keyFile parameter is managed
This commit is contained in:
parent
c5ddae12cf
commit
0ec20d3093
2 changed files with 5 additions and 5 deletions
|
@ -8,10 +8,10 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
const authKeyFile = "authKey.dat"
|
||||
const keyFile = "authKey.dat"
|
||||
|
||||
// newAuthKey reuses an existing CSRF authkey if present or generates a new one
|
||||
func newAuthKey(path string, keyFile string) []byte {
|
||||
func newAuthKey(path string) []byte {
|
||||
var authKey []byte
|
||||
authKeyPath := path + "/" + keyFile
|
||||
data, err := ioutil.ReadFile(authKeyPath)
|
||||
|
@ -30,8 +30,8 @@ func newAuthKey(path string, keyFile string) []byte {
|
|||
}
|
||||
|
||||
// newCSRF initializes a new CSRF handler
|
||||
func newCSRFHandler(path string, keyFile string) func(h http.Handler) http.Handler {
|
||||
authKey := newAuthKey(path, keyFile)
|
||||
func newCSRFHandler(keyPath string) func(h http.Handler) http.Handler {
|
||||
authKey := newAuthKey(keyPath)
|
||||
return csrf.Protect(
|
||||
authKey,
|
||||
csrf.HttpOnly(false),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue