Repository: ory/kratos
Pull request #869 (2020-12-01 13:43:14)

Use working cache-control header for cdn/proxies/cache
## Related issue

#601 

## Proposed changes

Cache-control: 0 has, to my understanding, no specific meaning, and in the case of using a CDN such as CloudFront, doesn't actually limit caching of values - this leads to re-use of CSRF cookies and flow session ID's.

Using a more-specific set of cache-control directives prevents CloudFront from caching the result of those URL's that explicitly want no caching, including CDN's.

## Checklist

<!--
Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of
them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
-->

- [X] I have read the [contributing guidelines](../blob/master/CONTRIBUTING.md).
- [X] I have read the [security policy](../security/policy).
- [X] I confirm that this pull request does not address a security
      vulnerability. If this pull request addresses a security. vulnerability, I
      confirm that I got green light (please contact
      [security@ory.sh](mailto:security@ory.sh)) from the maintainers to push
      the changes.
- [ ] I have added tests that prove my fix is effective or that my feature
      works.
- [ ] I have added or changed [the documentation](docs/docs).

## Further comments

I've worked around this by setting up a specific non-caching behavior for ORY Kratos url's, but the patch above should work across CDN's and caching proxies.


Patch:
diff --git a/docs/sidebar.json b/docs/sidebar.json
index 5f7f8aa39..ccccde2d7 100644
--- a/docs/sidebar.json
+++ b/docs/sidebar.json
@@ -1,5 +1,5 @@
 {
-  "Introduction": ["index", "quickstart", "install", "configuring"],
+  "Introduction": ["index", "quickstart", "install", "configuring", "contributing"],
   "Concepts": [
     "concepts/index", 
     "concepts/terminology", 
diff --git a/go.mod b/go.mod
index 56067122d..7999e2bff 100644
--- a/go.mod
+++ b/go.mod
@@ -51,7 +51,6 @@ require (
 	github.com/jteeuwen/go-bindata v3.0.7+incompatible
 	github.com/julienschmidt/httprouter v1.2.0
 	github.com/leodido/go-urn v1.1.0 // indirect
-	github.com/luna-duclos/instrumentedsql/opentracing v0.0.0-20201015064105-f9d01e123f16 // indirect
 	github.com/markbates/pkger v0.17.1
 	github.com/mattn/goveralls v0.0.5
 	github.com/mikefarah/yq v1.15.0
@@ -69,7 +68,7 @@ require (
 	github.com/ory/mail/v3 v3.0.0
 	github.com/ory/nosurf v1.2.3
 	github.com/ory/viper v1.7.5
-	github.com/ory/x v0.0.164
+	github.com/ory/x v0.0.165
 	github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
 	github.com/pkg/errors v0.9.1
 	github.com/prometheus/client_golang v1.4.0
diff --git a/go.sum b/go.sum
index fc208a0b2..54fafc2c1 100644
--- a/go.sum
+++ b/go.sum
@@ -68,6 +68,7 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
 github.com/armon/go-metrics v0.3.3 h1:a9F4rlj7EWWrbj7BYw8J8+x+ZZkJeqzNyRk8hdPF+ro=
 github.com/armon/go-metrics v0.3.3/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
 github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
+github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
 github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
 github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf h1:eg0MeVzsP1G42dRafH3vf+al2vQIJU0YHX+1Tw87oco=
 github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
@@ -144,6 +145,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng
 github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
 github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
 github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/cucumber/godog v0.8.1 h1:lVb+X41I4YDreE+ibZ50bdXmySxgRviYFgKY6Aw4XE8=
 github.com/cucumber/godog v0.8.1/go.mod h1:vSh3r/lM+psC1BPXvdkSEuNjmXfpVqrMGYAElF6hxnA=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -171,7 +173,9 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn
 github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
 github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
+github.com/elastic/go-sysinfo v1.1.1 h1:ZVlaLDyhVkDfjwPGU55CQRCRolNpc7P0BbyhhQZQmMI=
 github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0=
+github.com/elastic/go-windows v1.0.0 h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY=
 github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU=
 github.com/elazarl/goproxy v0.0.0-20181003060214-f58a169a71a5/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
 github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
@@ -840,6 +844,7 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht
 github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0/go.mod h1:IiEW3SEiiErVyFdH8NTuWjSifiEQKUoyK3LNqr2kCHU=
 github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
 github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
+github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4=
 github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak=
 github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
 github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
@@ -910,8 +915,8 @@ github.com/luna-duclos/instrumentedsql v1.1.2 h1:AZdd9TU/kFArfxF0Wi8PLNzniBUgo/c
 github.com/luna-duclos/instrumentedsql v1.1.2/go.mod h1:4LGbEqDnopzNAiyxPPDXhLspyunZxgPTMJBKtC6U0BQ=
 github.com/luna-duclos/instrumentedsql v1.1.3 h1:t7mvC0z1jUt5A0UQ6I/0H31ryymuQRnJcWCiqV3lSAA=
 github.com/luna-duclos/instrumentedsql v1.1.3/go.mod h1:9J1njvFds+zN7y85EDhN9XNQLANWwZt2ULeIC8yMNYs=
-github.com/luna-duclos/instrumentedsql/opentracing v0.0.0-20201015064105-f9d01e123f16 h1:NHt31cVVNEP2nBJ2naM0BIl0y6wolONdoPXYXTUNpEQ=
-github.com/luna-duclos/instrumentedsql/opentracing v0.0.0-20201015064105-f9d01e123f16/go.mod h1:YnZVBK+MxEr2sn1rbf4UMqsBd0uKaCOq52UtmbfDKNM=
+github.com/luna-duclos/instrumentedsql/opentracing v0.0.0-20201103091713-40d03108b6f4 h1:b8Uu5JfweuhcXIqANFs9dOw5zanFj89GYOGlyys37ds=
+github.com/luna-duclos/instrumentedsql/opentracing v0.0.0-20201103091713-40d03108b6f4/go.mod h1:YnZVBK+MxEr2sn1rbf4UMqsBd0uKaCOq52UtmbfDKNM=
 github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
 github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
 github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
@@ -1111,10 +1116,8 @@ github.com/ory/x v0.0.127 h1:goEspwhiKRoKRMBb6T6nDiv5L2mMU4EQUGwu90WM+Ao=
 github.com/ory/x v0.0.127/go.mod h1:FwUujfFuCj5d+xgLn4fGMYPnzriR5bdAIulFXMtnK0M=
 github.com/ory/x v0.0.148 h1:LLTGOS0gVcNgqFN1Nmq5CgfJEwhI8wnvDhpKXMreCWE=
 github.com/ory/x v0.0.148/go.mod h1:kYT14ajKGfDV8pRPRzQD3begYqRISZq1IQUgOVliQCE=
-github.com/ory/x v0.0.160 h1:tw1y6jowJuQEX7Rjjd5KGYzpOwdUqO41Q2MZThAW500=
-github.com/ory/x v0.0.160/go.mod h1:mus/BnwbF0EzobY8uP3tsCB+1zNgDMH1yQmfGI/oN3E=
-github.com/ory/x v0.0.164 h1:5wQHAfow9opVXfCdU6KjOngYz1eeVHnjwe/jV0P8kEI=
-github.com/ory/x v0.0.164/go.mod h1:sj3z/MeCrAyNFFTfN6yK1nTmHXGSFnw+QwIIQ/Rowec=
+github.com/ory/x v0.0.165 h1:PdLzbWj95+1hIkclBVeOchzIv3n/wSYJqRHQeEWueWA=
+github.com/ory/x v0.0.165/go.mod h1:OmHWAMal8+FhNJgDh1KkN8ik24ubjPSJQNdnTj6tzCQ=
 github.com/parnurzeal/gorequest v0.2.15/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE=
 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
 github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
@@ -1193,6 +1196,7 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
 github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
 github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
+github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis=
 github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4=
 github.com/santhosh-tekuri/jsonschema/v2 v2.1.0 h1:7KOtBzox6l1PbyZCuQfo923yIBpoMtGCDOD78P9lv9g=
 github.com/santhosh-tekuri/jsonschema/v2 v2.1.0/go.mod h1:yzJzKUGV4RbWqWIBBP4wSOBqavX5saE02yirLS0OTyg=
@@ -1349,9 +1353,13 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
 github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
 github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
 github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
+go.elastic.co/apm v1.8.0 h1:AWEKpHwRal0yCMd4K8Oxy1HAa7xid+xq1yy+XjgoVU0=
 go.elastic.co/apm v1.8.0/go.mod h1:tCw6CkOJgkWnzEthFN9HUP1uL3Gjc/Ur6m7gRPLaoH0=
+go.elastic.co/apm/module/apmhttp v1.8.0 h1:5AJPefWJzWDLX/47XIDfaloGiYWkkOQEULvlrI6Ieaw=
 go.elastic.co/apm/module/apmhttp v1.8.0/go.mod h1:9LPFlEON51/lRbnWDfqAWErihIiAFDUMfMV27YjoWQ8=
+go.elastic.co/apm/module/apmot v1.8.0 h1:7r8b5RGDN5gAUG7FoegzJ24+jFSZF7FvY2ODODaKFYk=
 go.elastic.co/apm/module/apmot v1.8.0/go.mod h1:Q5Xzabte8G/fkvDjr1jlDuOSUt9hkVWNZEHh6ZNaTjI=
+go.elastic.co/fastjson v1.0.0 h1:ooXV/ABvf+tBul26jcVViPT3sBir0PvXgibYB1IQQzg=
 go.elastic.co/fastjson v1.0.0/go.mod h1:PmeUOMMtLHQr9ZS9J9owrAVg0FkaZDRZJEFTTGHtchs=
 go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
 go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
@@ -1791,6 +1799,7 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh
 honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
+howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
 howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
 modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
 modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
diff --git a/persistence/sql/persister.go b/persistence/sql/persister.go
index 239d4a824..e7e1db4b0 100644
--- a/persistence/sql/persister.go
+++ b/persistence/sql/persister.go
@@ -4,6 +4,8 @@ import (
 	"context"
 	"io"
 
+	"github.com/ory/x/pkgerx"
+
 	"github.com/gobuffalo/pop/v5"
 	"github.com/markbates/pkger"
 	"github.com/pkg/errors"
@@ -27,7 +29,7 @@ type (
 	}
 	Persister struct {
 		c        *pop.Connection
-		mb       x.MigrationPkger
+		mb       *pkgerx.MigrationBox
 		r        persisterDependencies
 		cf       configuration.Provider
 		isSQLite bool
@@ -35,9 +37,9 @@ type (
 )
 
 func NewPersister(r persisterDependencies, conf configuration.Provider, c *pop.Connection) (*Persister, error) {
-	m, err := x.NewPkgerMigration(migrations, c, r)
+	m, err := pkgerx.NewMigrationBox(migrations, c, r.Logger())
 	if err != nil {
-		return nil, errors.WithStack(err)
+		return nil, err
 	}
 
 	return &Persister{c: c, mb: m, cf: conf, r: r, isSQLite: c.Dialect.Name() == "sqlite3"}, nil
diff --git a/x/migration_box.go b/x/migration_box.go
deleted file mode 100644
index 0f7b740ea..000000000
--- a/x/migration_box.go
+++ /dev/null
@@ -1,102 +0,0 @@
-package x
-
-import (
-	"bytes"
-	"io"
-	"io/ioutil"
-	"os"
-	"strings"
-
-	"github.com/gobuffalo/pop/v5"
-	"github.com/markbates/pkger"
-	"github.com/pkg/errors"
-)
-
-// MigrationPkger is a wrapper around pkger.Dir and Migrator.
-// This will allow you to run migrations from migrations packed
-// inside of a compiled binary.
-type MigrationPkger struct {
-	pop.Migrator
-	Dir pkger.Dir
-	r   LoggingProvider
-}
-
-// NewPkgerMigration from a packr.Box and a Connection.
-//
-//	migrations, err := NewPkgerMigration(pkger.Dir("/migrations"))
-//
-func NewPkgerMigration(dir pkger.Dir, c *pop.Connection, r LoggingProvider) (MigrationPkger, error) {
-	fm := MigrationPkger{
-		Migrator: pop.NewMigrator(c),
-		Dir:      dir,
-		r:        r,
-	}
-
-	runner := func(f io.Reader) func(mf pop.Migration, tx *pop.Connection) error {
-		return func(mf pop.Migration, tx *pop.Connection) error {
-			content, err := pop.MigrationContent(mf, tx, f, true)
-			if err != nil {
-				return errors.Wrapf(err, "error processing %s", mf.Path)
-			}
-			if content == "" {
-				return nil
-			}
-			err = tx.RawQuery(content).Exec()
-			if err != nil {
-				return errors.Wrapf(err, "error executing %s, sql: %s", mf.Path, content)
-			}
-			return nil
-		}
-	}
-
-	err := fm.findMigrations(runner)
-	if err != nil {
-		return fm, err
-	}
-
-	return fm, nil
-}
-
-func (fm *MigrationPkger) findMigrations(runner func(f io.Reader) func(mf pop.Migration, tx *pop.Connection) error) error {
-	return pkger.Walk(string(fm.Dir), func(p string, info os.FileInfo, err error) error {
-		if err != nil {
-			return err
-		}
-
-		match, err := pop.ParseMigrationFilename(info.Name())
-		if err != nil {
-			if strings.HasPrefix(err.Error(), "unsupported dialect") {
-				fm.r.Logger().Debugf("Ignoring migration file because dialect is not supported: %s", err.Error())
-				return nil
-			}
-			return err
-		}
-
-		if match == nil {
-			return nil
-		}
-
-		file, err := pkger.Open(p)
-		if err != nil {
-			return err
-		}
-		defer file.Close()
-
-		content, err := ioutil.ReadAll(file)
-		if err != nil {
-			return err
-		}
-
-		mf := pop.Migration{
-			Path:      p,
-			Version:   match.Version,
-			Name:      match.Name,
-			DBType:    match.DBType,
-			Direction: match.Direction,
-			Type:      match.Type,
-			Runner:    runner(bytes.NewReader(content)),
-		}
-		fm.Migrations[mf.Direction] = append(fm.Migrations[mf.Direction], mf)
-		return nil
-	})
-}
diff --git a/x/nocache.go b/x/nocache.go
index 324e80c8e..60ee086f9 100644
--- a/x/nocache.go
+++ b/x/nocache.go
@@ -6,12 +6,12 @@ import (
 	"github.com/julienschmidt/httprouter"
 )
 
-// NoCache adds `Cache-Control: 0` to the response header.
+// NoCache adds `Cache-Control: private, no-cache, no-store, must-revalidate` to the response header.
 func NoCache(w http.ResponseWriter) {
-	w.Header().Set("Cache-Control", "0")
+	w.Header().Set("Cache-Control", "private, no-cache, no-store, must-revalidate")
 }
 
-// NoCacheHandler wraps httprouter.Handle with `Cache-Control: 0` headers.
+// NoCacheHandler wraps httprouter.Handle with `Cache-Control: private, no-cache, no-store, must-revalidate` headers.
 func NoCacheHandler(handle httprouter.Handle) httprouter.Handle {
 	return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
 		NoCache(w)


Test patch:
diff --git a/persistence/sql/persister_hmac_test.go b/persistence/sql/persister_hmac_test.go
index afe7f8b5a..a76f5c040 100644
--- a/persistence/sql/persister_hmac_test.go
+++ b/persistence/sql/persister_hmac_test.go
@@ -3,6 +3,9 @@ package sql
 import (
 	"testing"
 
+	"github.com/ory/kratos/identity"
+	"github.com/ory/kratos/schema"
+
 	"github.com/gobuffalo/pop/v5"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
@@ -13,11 +16,36 @@ import (
 	"github.com/ory/kratos/driver/configuration"
 )
 
+type logRegistryOnly struct {
+	l *logrusx.Logger
+}
+
+func (l *logRegistryOnly) IdentityTraitsSchemas() schema.Schemas {
+	panic("implement me")
+}
+
+func (l *logRegistryOnly) IdentityValidator() *identity.Validator {
+	panic("implement me")
+}
+
+func (l *logRegistryOnly) Logger() *logrusx.Logger {
+	if l.l == nil {
+		l.l = logrusx.New("kratos", "testing")
+	}
+	return l.l
+}
+
+func (l *logRegistryOnly) Audit() *logrusx.Logger {
+	panic("implement me")
+}
+
+var _ persisterDependencies = &logRegistryOnly{}
+
 func TestPersisterHMAC(t *testing.T) {
 	viper.Set(configuration.ViperKeySecretsDefault, []string{"foobarbaz"})
 	c, err := pop.NewConnection(&pop.ConnectionDetails{URL: "sqlite://foo?mode=memory"})
 	require.NoError(t, err)
-	p, err := NewPersister(nil, configuration.NewViperProvider(logrusx.New("", ""), false), c)
+	p, err := NewPersister(&logRegistryOnly{}, configuration.NewViperProvider(logrusx.New("", ""), false), c)
 	require.NoError(t, err)
 
 	assert.True(t, p.hmacConstantCompare("hashme", p.hmacValue("hashme")))