-
Notifications
You must be signed in to change notification settings - Fork 14
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
Using reauth with proxy #27
Comments
Have you tried adding |
I did, but that authorizes all traffic because the redirect for auth takes you to a login form that returns a 200. It seems to me that the failure line should generate a redirect response to the browser, not follow a redirect itself. |
right right, sorry, I've had an injection of coffee now.
So the problem probably is in the detection of kibana saying user needs auth. Seems like I need to patch to make it smarter, perhaps allow a match. eg Would allow it to decide the user needs logging in when it see's a 303 redirect to a url containing a login. I can do this patch for you tonight. |
so then, I'd be able to do |
76783e7 this should do it for you So your config should look something like
I've submitted the build to caddy but if you're impatient you can build it by hand :D edit: It seems that building it by hand might be the way to go
that's outside of my control :( |
Yeah, that's no problem I use https://github.com/abiosoft/caddy-docker to build a container of caddy anyway, and it pulls master of all selected plugins, so I'm building it now. I'll report back my outcome. |
Okay, so the auth works now, thanks! I'm still having issue on the redirect now, but just with the placeholder. Ideally, after the login, I'd like to get redirected back to the original URI. (I think) this is the relevant part of my Caddyfile:
The authentication check works as desired, and will send the browser a redirect. But the
I think this is happening because my site definition is using patch matching. I noticed that for the Here you're using the raw Is it crazy hard to use the Caddy placedholder functions to get the original context or get the original context through "magic means" like the Caddy replace function does? This is technically a different problem and I can open a different issue, if you'd prefer. Thanks again for being so quick to fix my redirect problem. That makes my use at least functional. |
No that's fine, and I suspect you've finally been able to help me figure out the issues the others were having. I'll have a look later it actually shouldn't be that hard. I have access to your original url elsewhere in the request I can store that and reuse it if I can't find it elsewhere |
Hmm, so I wrote a test case to check the reason I thought it was broken, but that doesn't seem to be it. I can cirtainly look at populating the url with 'OriginalURLCtxKey' but can you do me a quick check? try adding
to your reauth block so it doesn't try authenticating the /login call recursively |
@freman sorry, I thought I got back to you. This didn't change anything because |
Sorry, just been a little busy at work but I'll take another look and see if I can't replicate what's happening and get you a fix this week. |
Hey, man. No problem. I maintain an open source project too, and sometimes it just takes a bit. No biggie. Thanks for your work though. Super excited about the possibilities. |
I get a similar error:
When i add |
I'm trying to serve an application via proxy (in this case Kibana, but similar usecase is Django, Flask, or Rails. I'm relatively new to Caddy, so I could have some basic misunderstanding of the config as well.
I have static files stored under
/srv/app/static
that I would like protected by a reauth upstream authorization. To the user, it would appear that all the pages are protected by the application's login screen. Since it's all hosted on the same host endpoint, auth cookies will be passed, etcd.Here's my current config (I'm running this in docker):
When I browse to localhost:2015, Kibana correctly picks up the request via the proxy block above. When I am not authenticated, I get redirected to the Kibana login page (
/login?next=%2F
). However, when I browse tolocalhost:2015/app/static
, I get a status 500. I can see in the logs that Kibana is in fact receiving the auth request from Caddy.However, if I am already authenticated to Kibana, it places a cookie called
sid
(by default).I saw the error
follow redirects disabled
in the unauthenticated example, and so I thought maybe I need to apply redirects to the upstream backend. The problem here is that Kibana provides a redirect 302, and the login page/login
sends a 200.What am I doing wrong and/or how can I get more info?
Side note, my first attempt to do this was the following. I kept getting the 500 and was getting frustrated thinking I was doing something wrong. After doing the analysis above, I think the logic is effectively the same. The config below is nicer since I don't have to create an arbitrary dir structure in the root to support the URI subpath.
The text was updated successfully, but these errors were encountered: