POC for using the basic_auth provisions from caddy internals#147
POC for using the basic_auth provisions from caddy internals#147proofrock wants to merge 1 commit intocaddyserver:masterfrom
Conversation
|
This makes sense to me! What changes do you think would need to be made to Caddy's basicauth package? I think we can export some more things if necessary. Re |
|
Hi Francis!
Yes, this should do the trick, maybe it's also possible to create the two methods that I had to put in
That would be great; IMHO it should be done before merging this PR (if it will be merged, of course). Then I will "adapt" this PR. Thanks! PS: I'm running this version since December in my homelab, accessing it everyday, it seems to work reliably. Not conclusive for anything of course, but it reassures me 😁 |
See the Of course any API change to Caddy itself being necessary means this PR would be halted until those changes are in a tagged release of Caddy, at which point this can be merged. (Probably best to mark this PR as a draft for now) Thanks for working on it! |
Thanks!
But of course. This PR was never meant (in my mind) to be merged like this, too much duplicated code. I've changed it to draft. Thanks for your time! |
1. What does this change do, exactly?
Hello!
as suggested, I tried to modify the
forwardproxycurrent authentication to re-use caddy's (main) code. I think I am getting there, but there are a few things that - if you are interested - may need discussion.In the code, I marked the relevant parts with a
[POC]comment tag and a brief discussion.Some explanations:
AuthenticateandparseCaddyFileto do the authentication and parsing, but they do just a little bit too much - the logic is adherent to where they're originally used (of course). For instance,Authenticatewrites to theResponseWriterand I don't think we need that; andparseCaddyFileis internal, uses ahttpcaddyfile.Helperthat is not available, and expects a slightly different "position" in the config file layout.adapter.gofile.basicauth.go(as it is, basically) because it contains some internal fields and methods I need to access from those new methods.caddyfile.goandforwardproxy.go- should be quite straightforward; the changes in error messages are also marked with[POC]. Please mainly review if these files suits you, what I described in the earlier points are "just" to make these changes work and can be optimized, as I said.xcaddy run...compiles against the latest caddy and my code is done against that version,go testcompiles against v2.7.6, and there's a breaking change inbasicauth.go#Comparerthat makes things difficult.ctxI don't have available at initialization time. I tried to work around this, but the point before makes it really difficult; so I hope that it's possible to update the "base" version before (possibly, eventually) finalizing all this.To test:
caddyfileRun with
xcaddy run -- --config caddyfileTry with
Thanks for the great code and the fun ride! Even if this will go nowhere, which is of course ok, I definitely learned something.
2. Please link to the relevant issues.
None
3. Which documentation changes (if any) need to be made because of this PR?
README.md, breaking changes should be explained in thebasic_authsection(s).4. Checklist