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

Is it possibile to use CorceRedirectTo200 in master? #251

Closed
frederikhors opened this issue Oct 1, 2019 · 6 comments
Closed

Is it possibile to use CorceRedirectTo200 in master? #251

frederikhors opened this issue Oct 1, 2019 · 6 comments

Comments

@frederikhors
Copy link
Contributor

frederikhors commented Oct 1, 2019

Issue opened for the creation of a wiki page that summarizes the doubts and problems for newbies (#210).


Is it possibile to use CorceRedirectTo200 in master?

I'm using it like this:

ab.Config.Paths.RootURL = os.Getenv("SITE_URL")
ab.Config.Storage.Server = database
ab.Config.Storage.SessionState = sessionStore
ab.Config.Storage.CookieState = cookieStore
ab.Config.Modules.LogoutMethod = "GET"
ab.Config.Core.ViewRenderer = defaults.JSONRenderer{}
ab.Config.Core.Redirector = &defaults.Redirector{CorceRedirectTo200: true}
defaults.SetCore(&ab.Config, true, false)

but still I have a GET -> localhost/auth/logout -> redirected to -> /.

Why?

How to disable redirect and just use 200?

@aarondl
Copy link
Member

aarondl commented Oct 9, 2019

Your problem is that the call to defaults.SetCore overrides your redirector you just set up :p

@aarondl aarondl closed this as completed Oct 9, 2019
@frederikhors
Copy link
Contributor Author

frederikhors commented Dec 29, 2019

@aarondl long time to respond I know.

I inverted lines from this:

ab.Config.Paths.RootURL = os.Getenv("SITE_URL")
ab.Config.Storage.Server = database
ab.Config.Storage.SessionState = sessionStore
ab.Config.Storage.CookieState = cookieStore
ab.Config.Modules.LogoutMethod = "GET"
ab.Config.Core.ViewRenderer = defaults.JSONRenderer{}
ab.Config.Core.Redirector = &defaults.Redirector{CorceRedirectTo200: true} // <--
defaults.SetCore(&ab.Config, true, false)

to this:

ab.Config.Paths.RootURL = os.Getenv("SITE_URL")
ab.Config.Storage.Server = database
ab.Config.Storage.SessionState = sessionStore
ab.Config.Storage.CookieState = cookieStore
ab.Config.Modules.LogoutMethod = "GET"
ab.Config.Core.ViewRenderer = defaults.JSONRenderer{}
defaults.SetCore(&ab.Config, true, false)
ab.Config.Core.Redirector = &defaults.Redirector{CorceRedirectTo200: true} // <--

and the problem is still there:

I still have a GET -> localhost/auth/logout -> redirected to -> /.

Why?

@frederikhors
Copy link
Contributor Author

frederikhors commented Dec 29, 2019

Isn't ab.Config.Core.Redirector = &defaults.Redirector{CorceRedirectTo200: true} setting a config in the &ab.Config which I will use after in defaults.SetCore(&ab.Config, true, false)?

Authboss is great but this config is sometimes too complicated for newbies and simple people like me. :(

@frederikhors
Copy link
Contributor Author

Ok. After small investigation I understood the problem is this line: https://github.com/volatiletech/authboss/blob/master/defaults/responder.go#L44.

The func isAPIRequest() because I was trying with Postman without Content-Type.

The problem now is I have errore on login, on logout (line 103 of responder.go: body, mime, err := r.Renderer.Render(req.Context(), "redirect", data)) because I think my Renderer struct is missing.

@frederikhors
Copy link
Contributor Author

Little news:

I was able to make it work like this:

defaults.SetCore(&ab.Config, true, false)
ab.Config.Core.Redirector = &defaults.Redirector{Renderer: &defaults.JSONRenderer{}, CorceRedirectTo200: true}

but still don't know why with defaults.SetCore() I have FormValueName: "redir".

Is there a doc somewhere?

I can write it if I can understand.

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

2 participants