diff --git a/.docker/Dockerfile b/.docker/Dockerfile index be995fd17efd..ef1fa687ea40 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.11 +FROM alpine:3.12 RUN addgroup -S ory; \ adduser -S ory -G ory -D -h /home/ory -s /bin/nologin; \ diff --git a/.docker/Dockerfile-build b/.docker/Dockerfile-build index 4a13000ae6f0..8024701c1094 100644 --- a/.docker/Dockerfile-build +++ b/.docker/Dockerfile-build @@ -1,4 +1,4 @@ -FROM golang:1.14-alpine AS builder +FROM golang:1.15-alpine AS builder RUN apk -U --no-cache add build-base git gcc bash @@ -14,10 +14,9 @@ RUN go mod download ADD . . -RUN make pack -RUN go build -tags sqlite -a -o /usr/bin/kratos +RUN make pack && go build -tags sqlite -o /usr/bin/kratos -FROM alpine:3.11 +FROM alpine:3.12 RUN addgroup -S ory; \ adduser -S ory -G ory -D -h /home/ory -s /bin/nologin; \ diff --git a/.docker/Dockerfile-sqlite b/.docker/Dockerfile-sqlite index 4bc74e38779f..cccca3c60228 100644 --- a/.docker/Dockerfile-sqlite +++ b/.docker/Dockerfile-sqlite @@ -1,4 +1,4 @@ -FROM alpine:3.11 +FROM alpine:3.12 # Because this image is built for SQLite, we create /home/ory and /home/ory/sqlite which is owned by the ory user # and declare /home/ory/sqlite a volume. diff --git a/.dockerignore b/.dockerignore index d56b2ce0858b..0b8e6ae040cd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -13,3 +13,4 @@ node_modules/ ./quickstart-*.yml .bin/ test/ +pgked.go diff --git a/Makefile b/Makefile index 33a3be1e32fe..1d52b82c7ddb 100644 --- a/Makefile +++ b/Makefile @@ -136,4 +136,4 @@ migratest-refresh: .PHONY: pack pack: .bin/pkger - pkger -exclude node_modules -exclude docs -exclude .bin -exclude test -exclude script -exclude contrib + pkger -exclude node_modules -exclude docs -exclude .git -exclude .github -exclude .bin -exclude test -exclude script -exclude contrib diff --git a/go.sum b/go.sum index fcc7da788693..89f1cb5fb025 100644 --- a/go.sum +++ b/go.sum @@ -352,8 +352,6 @@ github.com/gobuffalo/events v1.4.1/go.mod h1:SjXgWKpeSuvQDvGhgMz5IXx3Czu+IbL+XPL github.com/gobuffalo/fizz v1.0.12/go.mod h1:C0sltPxpYK8Ftvf64kbsQa2yiCZY4RZviurNxXdAKwc= github.com/gobuffalo/fizz v1.9.8/go.mod h1:w1FEn1yKNVCc49KnADGyYGRPH7jFON3ak4Bj1yUudHo= github.com/gobuffalo/fizz v1.10.0/go.mod h1:J2XGPO0AfJ1zKw7+2BA+6FEGAkyEsdCOLvN93WCT2WI= -github.com/gobuffalo/fizz v1.13.0 h1:XzcBh8DLZH2BgEH77p6q+EKbd8FZyyUXgokUmKXk5ow= -github.com/gobuffalo/fizz v1.13.0/go.mod h1:cXLjhE5p3iuIes6AGZ/9+dfyOkehlB2Vldj0Iw2Uu38= github.com/gobuffalo/fizz v1.13.1-0.20200903094245-046abeb7de46 h1:lkv+5YiQOlOhXaYyD2PtN/E0BT87G/I0iCL7gqxTKBg= github.com/gobuffalo/fizz v1.13.1-0.20200903094245-046abeb7de46/go.mod h1:cXLjhE5p3iuIes6AGZ/9+dfyOkehlB2Vldj0Iw2Uu38= github.com/gobuffalo/flect v0.0.0-20180907193754-dc14d8acaf9f/go.mod h1:rCiQgmAE4axgBNl3jZWzS5rETRYTGOsrixTRaCPzNdA= @@ -1046,8 +1044,6 @@ github.com/openzipkin/zipkin-go v0.2.2 h1:nY8Hti+WKaP0cRsSeQ026wU03QsM762XBeCXBb github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/analytics-go/v4 v4.0.0 h1:KQ2P00j9dbj4lDC/Albw/zn/scK67041RhqeW5ptsbw= github.com/ory/analytics-go/v4 v4.0.0/go.mod h1:FMx9cLRD9xN+XevPvZ5FDMfignpmcqPP6FUKnJ9/MmE= -github.com/ory/cli v0.0.27 h1:4dfDDqSzIGUcR/LXzmqI6bnMa/c0Ao0S4Uw3PI2ACWw= -github.com/ory/cli v0.0.27/go.mod h1:DrhqIZ67p55fetGyczTpU+amx3WGIMKOj75mSSbYJ+U= github.com/ory/cli v0.0.28-0.20200903094455-e203529bf12b h1:YY/QfVyxo4RB1/J5BTC+XJ/LPI70+246XnGlH930fE8= github.com/ory/cli v0.0.28-0.20200903094455-e203529bf12b/go.mod h1:PqijULTsktU0v2STwzZRXTEYRK5ZEJb0NGkdXLFy/BE= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= diff --git a/selfservice/strategy/link/schema.go b/selfservice/strategy/link/schema.go index 21dd9b748f80..d7e79886380a 100644 --- a/selfservice/strategy/link/schema.go +++ b/selfservice/strategy/link/schema.go @@ -2,14 +2,6 @@ package link import ( "github.com/markbates/pkger" - - "github.com/ory/kratos/x" ) var _ = pkger.Dir("/selfservice/strategy/link/.schema") - -var emailSchema []byte - -func init() { - emailSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/link/.schema/email.schema.json")) -} diff --git a/selfservice/strategy/link/strategy_recovery.go b/selfservice/strategy/link/strategy_recovery.go index a7380c8bf55e..2229ec4c6e87 100644 --- a/selfservice/strategy/link/strategy_recovery.go +++ b/selfservice/strategy/link/strategy_recovery.go @@ -7,6 +7,7 @@ import ( "github.com/gofrs/uuid" "github.com/julienschmidt/httprouter" + "github.com/markbates/pkger" "github.com/pkg/errors" "github.com/ory/x/decoderx" @@ -484,7 +485,9 @@ func (s *Strategy) decodeRecovery(r *http.Request, decodeBody bool) (*completeSe if decodeBody { if err := s.dx.Decode(r, &body, - decoderx.MustHTTPRawJSONSchemaCompiler(emailSchema), + decoderx.MustHTTPRawJSONSchemaCompiler( + x.MustPkgerRead(pkger.Open("/selfservice/strategy/link/.schema/email.schema.json")), + ), decoderx.HTTPDecoderSetValidatePayloads(false), decoderx.HTTPDecoderJSONFollowsFormFormat()); err != nil { return nil, err diff --git a/selfservice/strategy/link/strategy_verification.go b/selfservice/strategy/link/strategy_verification.go index 9a2a6861e1f1..b18e914316d1 100644 --- a/selfservice/strategy/link/strategy_verification.go +++ b/selfservice/strategy/link/strategy_verification.go @@ -7,6 +7,7 @@ import ( "github.com/gofrs/uuid" "github.com/julienschmidt/httprouter" + "github.com/markbates/pkger" "github.com/pkg/errors" "github.com/ory/x/decoderx" @@ -57,7 +58,9 @@ func (s *Strategy) decodeVerification(r *http.Request, decodeBody bool) (*comple if decodeBody { if err := s.dx.Decode(r, &body, - decoderx.MustHTTPRawJSONSchemaCompiler(emailSchema), + decoderx.MustHTTPRawJSONSchemaCompiler( + x.MustPkgerRead(pkger.Open("/selfservice/strategy/link/.schema/email.schema.json")), + ), decoderx.HTTPDecoderSetValidatePayloads(false), decoderx.HTTPDecoderJSONFollowsFormFormat()); err != nil { return nil, err diff --git a/selfservice/strategy/password/login.go b/selfservice/strategy/password/login.go index 50fba3963650..9cf6b94d7e1a 100644 --- a/selfservice/strategy/password/login.go +++ b/selfservice/strategy/password/login.go @@ -6,6 +6,7 @@ import ( "net/http" "github.com/julienschmidt/httprouter" + "github.com/markbates/pkger" "github.com/pkg/errors" "github.com/ory/x/decoderx" @@ -105,7 +106,8 @@ func (s *Strategy) handleLogin(w http.ResponseWriter, r *http.Request, _ httprou } var p CompleteSelfServiceLoginFlowWithPasswordMethod - if err := s.hd.Decode(r, &p, decoderx.MustHTTPRawJSONSchemaCompiler(loginSchema)); err != nil { + if err := s.hd.Decode(r, &p, decoderx.MustHTTPRawJSONSchemaCompiler(x.MustPkgerRead( + pkger.Open("/selfservice/strategy/password/.schema/login.schema.json")))); err != nil { s.handleLoginError(w, r, ar, &p, err) return } diff --git a/selfservice/strategy/password/registration.go b/selfservice/strategy/password/registration.go index fcd96d48d76e..da0626fe8de0 100644 --- a/selfservice/strategy/password/registration.go +++ b/selfservice/strategy/password/registration.go @@ -5,6 +5,7 @@ import ( "net/http" "github.com/julienschmidt/httprouter" + "github.com/markbates/pkger" "github.com/pkg/errors" "github.com/tidwall/sjson" @@ -74,7 +75,8 @@ func (s *Strategy) handleRegistrationError(w http.ResponseWriter, r *http.Reques } func (s *Strategy) decode(p *RegistrationFormPayload, r *http.Request) error { - raw, err := sjson.SetBytes(registrationSchema, "properties.traits.$ref", s.c.DefaultIdentityTraitsSchemaURL().String()+"#/properties/traits") + raw, err := sjson.SetBytes(x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/registration.schema.json")), + "properties.traits.$ref", s.c.DefaultIdentityTraitsSchemaURL().String()+"#/properties/traits") if err != nil { return errors.WithStack(err) } diff --git a/selfservice/strategy/password/schema.go b/selfservice/strategy/password/schema.go index 66533665c23f..d3ba3faa46cc 100644 --- a/selfservice/strategy/password/schema.go +++ b/selfservice/strategy/password/schema.go @@ -2,16 +2,6 @@ package password import ( "github.com/markbates/pkger" - - "github.com/ory/kratos/x" ) var _ = pkger.Dir("/selfservice/strategy/password/.schema") - -var loginSchema, registrationSchema, settingsSchema []byte - -func init() { - loginSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/login.schema.json")) - registrationSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/registration.schema.json")) - settingsSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/settings.schema.json")) -} diff --git a/selfservice/strategy/password/settings.go b/selfservice/strategy/password/settings.go index 5997ba6f9248..4c090942b3a7 100644 --- a/selfservice/strategy/password/settings.go +++ b/selfservice/strategy/password/settings.go @@ -8,6 +8,7 @@ import ( "github.com/gofrs/uuid" "github.com/julienschmidt/httprouter" + "github.com/markbates/pkger" "github.com/pkg/errors" "github.com/ory/herodot" @@ -137,7 +138,7 @@ func (s *Strategy) submitSettingsFlow(w http.ResponseWriter, r *http.Request, ps } func (s *Strategy) decodeSettingsFlow(r *http.Request, dest interface{}) error { - compiler, err := decoderx.HTTPRawJSONSchemaCompiler(settingsSchema) + compiler, err := decoderx.HTTPRawJSONSchemaCompiler( x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/settings.schema.json"))) if err != nil { return errors.WithStack(err) } diff --git a/selfservice/strategy/profile/schema.go b/selfservice/strategy/profile/schema.go index 64a6e5e82ce1..76a0922f626a 100644 --- a/selfservice/strategy/profile/schema.go +++ b/selfservice/strategy/profile/schema.go @@ -2,14 +2,6 @@ package profile import ( "github.com/markbates/pkger" - - "github.com/ory/kratos/x" ) var _ = pkger.Dir("/selfservice/strategy/profile/.schema") - -var settingsSchema []byte - -func init() { - settingsSchema = x.MustPkgerRead(pkger.Open("/selfservice/strategy/password/.schema/settings.schema.json")) -} diff --git a/selfservice/strategy/profile/strategy.go b/selfservice/strategy/profile/strategy.go index 5d58c605bc39..532b4eeb7960 100644 --- a/selfservice/strategy/profile/strategy.go +++ b/selfservice/strategy/profile/strategy.go @@ -8,6 +8,7 @@ import ( "github.com/gofrs/uuid" "github.com/julienschmidt/httprouter" + "github.com/markbates/pkger" "github.com/pkg/errors" "github.com/tidwall/sjson" @@ -317,7 +318,9 @@ func (s *Strategy) newSettingsProfileDecoder(i *identity.Identity) (decoderx.HTT if err != nil { return nil, err } - raw, err := sjson.SetBytes(settingsSchema, "properties.traits.$ref", ss.URL.String()+"#/properties/traits") + raw, err := sjson.SetBytes(x.MustPkgerRead(pkger.Open( + "/selfservice/strategy/password/.schema/settings.schema.json")), + "properties.traits.$ref", ss.URL.String()+"#/properties/traits") if err != nil { return nil, errors.WithStack(err) } diff --git a/x/config.go b/x/config.go index ce661fbd391a..cb13f3dbff87 100644 --- a/x/config.go +++ b/x/config.go @@ -2,13 +2,12 @@ package x import ( "github.com/markbates/pkger" - "github.com/ory/x/logrusx" "github.com/ory/x/viperx" ) -var schema = MustPkgerRead(pkger.Open("/.schema/config.schema.json")) - func WatchAndValidateViper(log *logrusx.Logger) { - viperx.WatchAndValidateViper(log, schema, "ORY Kratos", []string{"serve", "profiling", "log"}, "") + schema := MustPkgerRead(pkger.Open("/.schema/config.schema.json")) + viperx.WatchAndValidateViper(log, schema, + "ORY Kratos", []string{"serve", "profiling", "log"}, "") }