Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect hooks expected config doesn't validate #406

Closed
Nekuromento opened this issue May 12, 2020 · 3 comments
Closed

Redirect hooks expected config doesn't validate #406

Nekuromento opened this issue May 12, 2020 · 3 comments

Comments

@Nekuromento
Copy link

Describe the bug

Using redirect hooks either results in kratos failing to validate config schema or failing at runtime due to to hook code expecting a different config format.

Reproducing the bug

Steps to reproduce the behavior:

  • Add a before/after hook to any self-service endpoint

Server logs

time="2020-05-11T22:34:10Z" level=warning msg="Encountered login error." credentials_type=password details="rid=\nerror=An internal server error occurred, please contact the system administrator\nreason=A redirector hook was configured without a redirect_to value set.\ndetails=map[]\ndebug=\n\ngit.luolix.top/ory/kratos/selfservice/hook.(*Redirector).do\n\t/home/ory/selfservice/hook/redirector.go:80\ngit.luolix.top/ory/kratos/selfservice/hook.(*Redirector).ExecutePostRegistrationPrePersistHook\n\t/home/ory/selfservice/hook/redirector.go:57\ngit.luolix.top/ory/kratos/selfservice/flow/registration.(*HookExecutor).PostRegistrationHook\n\t/home/ory/selfservice/flow/registration/hook.go:77\ngit.luolix.top/ory/kratos/selfservice/strategy/password.(*Strategy).handleRegistration\n\t/home/ory/selfservice/strategy/password/registration.go:165\ngit.luolix.top/ory/kratos/session.(*Handler).IsNotAuthenticated.func1\n\t/home/ory/session/handler.go:111\ngit.luolix.top/julienschmidt/httprouter.(*Router).ServeHTTP\n\t/go/pkg/mod/github.com/julienschmidt/httprouter@v1.2.0/router.go:334\ngit.luolix.top/justinas/nosurf.(*CSRFHandler).handleSuccess\n\t/go/pkg/mod/github.com/justinas/nosurf@v1.1.0/handler.go:187\ngit.luolix.top/justinas/nosurf.(*CSRFHandler).ServeHTTP\n\t/go/pkg/mod/github.com/justinas/nosurf@v1.1.0/handler.go:180\ngit.luolix.top/urfave/negroni.Wrap.func1\n\t/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:46\ngit.luolix.top/urfave/negroni.HandlerFunc.ServeHTTP\n\t/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:29\ngit.luolix.top/urfave/negroni.middleware.ServeHTTP\n\t/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:38\ngit.luolix.top/ory/x/metricsx.(*Service).ServeHTTP\n\t/go/pkg/mod/github.com/ory/x@v0.0.116/metricsx/middleware.go:261\ngit.luolix.top/urfave/negroni.middleware.ServeHTTP\n\t/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:38\ngit.luolix.top/ory/x/reqlog.(*Middleware).ServeHTTP\n\t/go/pkg/mod/github.com/ory/x@v0.0.116/reqlog/middleware.go:140\ngit.luolix.top/urfave/negroni.middleware.ServeHTTP\n\t/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:38\ngit.luolix.top/urfave/negroni.(*Negroni).ServeHTTP\n\t/go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:96\ngit.luolix.top/gorilla/context.ClearHandler.func1\n\t/go/pkg/mod/github.com/gorilla/context@v1.1.1/context.go:141\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2012\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2807\nnet/http.(*conn).serve\n\t/usr/local/go/src/net/http/server.go:1895\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1373" error="An internal server error occurred, please contact the system administrator" login_request="&{56b58474-ca05-4483-ab20-069c4bbffb9a 2020-05-11 22:44:03.242921 +0000 +0000 2020-05-11 22:34:03.242921 +0000 +0000 http://localhost/self-service/browser/flows/registration?return_to=http%3A%2F%2Flocalhost%3A9090%2Fdashboard map[oidc:0xc000504460 password:0xc0005042a0] [] 2020-05-11 22:34:03.243409 +0000 +0000 2020-05-11 22:34:03.243412 +0000 +0000 e0BXqY0muQ9nOkTLH8Pw2U0mkejxxLZi+Yv0e1OaXLGIgHjxkdMURd6cisUpXYReDNbgCTsEbh8PFZIm1U/LJw==}"

time="2020-05-11T22:34:10Z" level=error msg="An error occurred and is being forwarded to the error user interface." code=500 debug= details="map[]" error="An internal server error occurred, please contact the system administrator" reason="A redirector hook was configured without a redirect_to value set." request-id= status="Internal Server Error"

Server configuration

selfservice:
  strategies:
    password:
      enabled: true
  registration:
    after:
      password:
        hooks:
          - hook: redirect
            config:
              default_redirect_url: http://localhost:9090/app/
              allow_user_defined_redirect: true

Expected behavior

A clear and concise description of what you expected to happen.

Environment

  • Version: v0.2.1-alpha.1
  • Environment: Docker
@aeneasr
Copy link
Member

aeneasr commented May 12, 2020

This changed in Kratos 0.2. See:

@fanky5g
Copy link

fanky5g commented May 16, 2020

@Nekuromento could you get this resolved? Looks like the issue still persists after following the new format:

selfservice:
registration:
after:
:
- hook: redirect
config:
to: https://url-to-redirect/to

Config validation fails with error:
The configuration is invalid and could not be loaded." [config_key=selfservice.registration.after.password]="doesn't validate with "#/definitions/selfServiceAfterRegistrationStrategy"" [config_key=selfservice.registration.after]="doesn't validate with "#/definitions/selfServiceAfterRegistration"

The config schema definition does not match the new config format

@aeneasr
Copy link
Member

aeneasr commented May 16, 2020

Hey, please check out kratos 0.3.0 which has better validation error output!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants