Feature #322
closedFastCGI Authorizer support for Variable-name variable passing
Description
The FastCGI Spec states that authorizers can emit headers of the format Variable-name: value and those variables will be placed into the environment of all subsequent authorized requests as name: value. It would be great if lighttpd supported this.
See http://www.fastcgi.com/devkit/doc/fcgi-spec.html#S6.3 for further information.
-- cpisto
Files
Updated by maherb over 18 years ago
I agree, this support would be excellent, especially if {{{mod@mod_accesslog@ allowed you to print these environment variables in your access log. For example, the most common use case for an authorizer FastCGI process is when you want to set the REMOTE_USER cgi environment variable, and most people will want to log the contents of that environment variable.
Updated by maherb over 18 years ago
Updated by Anonymous almost 18 years ago
This is excellent news. When can this be applied to the main trunk?
-- André Cruz
Updated by EDevil almost 18 years ago
I think that with this patch we still have to opt between serving static content or another fcgi application, by configuring or not a docroot.
Why can't we serve both? If I protect the / URL with an authorizer I want to serve static content, the site CSS, and process the PHP files using a fcgi application.
I enabled this by setting con->status = 0 on line 3114 of mod_fastcgi.c (after the patch). This way mod_staticfile catches the request.
Is there something I am forgetting with this small change?
Updated by maherb almost 18 years ago
Replying to EDevil:
I think that with this patch we still have to opt between serving static content or
another fcgi application, by configuring or not a docroot.
This should not be the case. I've used this patch successfully for many months to serve static content, cgi content, and fastcgi content "behind" a fastcgi authorizer.
Why can't we serve both? If I protect the / URL with an authorizer I want to serve
static content, the site CSS, and process the PHP files using a fcgi application.I enabled this by setting con->status = 0 on line 3114 of mod_fastcgi.c (after the
patch). This way mod_staticfile catches the request.
The connection struct (typedef struct defined in base.h) does not have a status field. It does have an http_status field. Perhaps you tried to apply the patch against an older version of lighttpd? I've applied the patch against svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x/.
Is there something I am forgetting with this small change?
Updated by Anonymous over 16 years ago
FYI, this patch does not apply cleanly since 1.4.15. It's about time this patch is integrated.
Updated by EDevil over 16 years ago
You're right, it's http_status.
It ends up like this:
con->http_status == 0)) { /* * If we are here in AUTHORIZER mode then a request for autorizer * was proceeded already, and status 200 has been returned. We need * now to handle autorized request. */ con->http_status = 0; if ( ! buffer_is_empty(host->docroot) ) { /* * Serve local file if they specified * a docroot */
Updated by stbuehler over 16 years ago
An enhancement with severity "blocker"? you are funny...
I think we shouldn't use con->authed_user to decide if we should do a authorizer request - that would mean every authorizer behind mod_auth gets broken, which is not acceptable imho.
Updated by stbuehler about 16 years ago
- Target version changed from 1.4.20 to 1.4.21
Updated by icy about 16 years ago
- Priority changed from Urgent to Normal
- Patch available set to No
Updated by icy almost 16 years ago
- Target version changed from 1.4.21 to 1.4.22
Updated by stbuehler over 15 years ago
- Target version changed from 1.4.22 to 1.4.23
Updated by stbuehler over 15 years ago
- Assignee deleted (
jan) - Target version changed from 1.4.23 to 1.4.x
Updated by EDevil over 15 years ago
This bug has a patch available. It is attached.
Updated by mimic about 15 years ago
I have tried to patch a more recent version but it seems authorizer does not work for FastCGI URL prefix based content. Could somebody provide an example of configuration for using FastCGI in both authorizer and responder for URL prefix? Could somebody provide an updated patch?
Updated by EDevil about 15 years ago
- File Lighty1.patch Lighty1.patch added
- Target version changed from 1.4.x to 1.4.25
- % Done changed from 0 to 90
Attached is the updated patch for 1.4.24.
Several people have been using this for years with 0 problems so I would appreciate it if this was included in trunk. If more changes are needed so that this patch is applied please state them so that this issue can finally be closed.
Best regards.
Updated by stbuehler about 15 years ago
- Target version changed from 1.4.25 to 1.4.26
- Missing in 1.5.x set to No
Updated by stbuehler almost 15 years ago
- Target version changed from 1.4.26 to 1.4.27
Updated by stbuehler over 14 years ago
- Target version changed from 1.4.27 to 1.4.x
Updated by ckreutzer almost 9 years ago
- File feature-322.patch feature-322.patch added
EDevil wrote:
Attached is the updated patch for 1.4.24.
In 1.4.33 there were massive changes to mod_fastcgi.c, and con->authed_user has been removed. I've now modified the current Debian stable version (1.4.35-4) using a custom environment variable. This works fine for me using the Shibboleth SP 2.5.3 and a lighttpd FastCGI configuration based on the one given in the SHIB2 wiki.
I've attached the patch. Maybe someone's interested, since the lighttpd2 snapshots don't seem the have any authorizer mode :/
Updated by gstrauss over 8 years ago
- Status changed from New to Need Feedback
@ckreutzer: this patch purportedly combines three different issues. Besides the feature for setting Variable-* in the environment, are the other two still valid? Please review the commits in the past few months which improve robustness of fastcgi in lighttpd. My read of the patch looks like it extends FastCGI authorizer mode to send static file (if authorized) if host->docroot is set (which is the current behavior), or else (if host->docroot is not set), create a new behavior which sets an environment variable and restarts request processing so that any module can handle the subsequent request, such as mod_cgi.
To apply to current master, the patch needs to be updated to at least
- array search for "FastCGI-Authorizer" should be lifted outside loop
(auth_cnt = (data_string *)array_get_element(con->environment, "FastCGI-Authorizer");
)
- access to buffer->used
member should be modified to employ buffer.h interfaces instead.
- ... possibly other changes
@ckreutzer: Would you be interested in explaining what the patch is trying to accomplish and to help redo the patch? Thanks.
Updated by ckreutzer over 8 years ago
Sorry for the late response, didn't watched this issue until now.
gstrauss wrote:
@ckreutzer: this patch purportedly combines three different issues. Besides the feature for setting Variable-* in the environment, are the other two still valid? Please review the commits in the past few months which improve robustness of fastcgi in lighttpd. My read of the patch looks like it extends FastCGI authorizer mode to send static file (if authorized) if host->docroot is set (which is the current behavior), or else (if host->docroot is not set), create a new behavior which sets an environment variable and restarts request processing so that any module can handle the subsequent request, such as mod_cgi.
That's correct. I added the decision on host->docroot to not totally reverse the original lighty way of handling.
For the issues:- as you pointed out, this handles #322
- #321 is also handled - as you pointed out -, because the request handling will be restarted and the fastcgi responder jumps in (in my case PHP)
- "(as well as a fix for infinite 301 redirection when specifying "/" as your authorizer)" - this should be fixed, too, I use it like this: "/" => (( [...] "mode" => "authorizer" )),
To apply to current master, the patch needs to be updated to at least
I would be happy if this could be contributed upstream!
@ckreutzer: Would you be interested in explaining what the patch is trying to accomplish and to help redo the patch? Thanks.
I will try to help. C is not my day to day job and I just digged into the lighty sources for this issue ;)
My objective was to use the Shibboleth SP as FastCGI Authorizer in front of a PHP FastCGI responder (like a lot of people here, I like it much more than Apache). I used a lot of code from EDevil's patch and just tried to mangle it in the much reworked fastcgi code. Things he did which weren't working any longer I just rewrote with workarounds I found screening the existing code.
I will review the changes between 1.4.39 and 1.4.40 in the next few days, I hope, and try to come up with a clean solution.
Updated by gstrauss over 8 years ago
Great to hear back!
I haven't looked at this patch in a while, but recently made a commit to mod_cgi to enable internal redirect from a subrequest handler. Take a look at 8861c2bb for some inspiration. :)
Updated by ckreutzer over 8 years ago
I started working on it yesterday and created a modified fastcgi-auth.conf and corresponding fcgi-auth.c, fcgi-responder.c, so I can check the results.
gstrauss wrote:
I haven't looked at this patch in a while, but recently made a commit to mod_cgi to enable internal redirect from a subrequest handler. Take a look at 8861c2bb for some inspiration. :)
Do I understand correctly that if cgi_handle_fdevent(server *srv, void *ctx, int revents) returns HANDLER_COMEBACK, the request will be restarted? Like it was done in the patch before using something like:+ fcgi_connection_close(srv, hctx);
+ con->mode = DIRECT;
+ con->file_started = 0;
+ con->file_finished = 0;
+ buffer_reset(con->physical.path);
Then it should be possible to use the same behavior in fcgi_handle_fdevent?
I need to study the old patch and the new mod_fastcgi.c more closely in the evening.
Updated by gstrauss over 8 years ago
Yes. It sounds like you're on the right track. The handler needs to fully clean up if the request is to be restarted, since a new handler might be used, or a new fastcgi handler might be used.
Updated by ckreutzer over 8 years ago
Hi,
I opened a PR on GitHub: https://github.com/lighttpd/lighttpd1.4/pull/70
If there are any improvements needed, feel free to comment in the diffs :)
Regards,
Christoph
Updated by gstrauss about 8 years ago
sorry, I haven't had a chance to dive into this again. I'll try to do so the weekend of Sep 10.
Updated by ckreutzer about 8 years ago
No problem, take your time. Looking forward to your feedback ;)
Updated by gstrauss about 8 years ago
- Status changed from Need Feedback to Patch Pending
- Target version changed from 1.4.x to 1.4.42
Updated by gstrauss about 8 years ago
- Status changed from Patch Pending to Fixed
- % Done changed from 90 to 100
Applied in changeset 2dcfe1733ec729af0fa3477e91617ce60bc5ecad.
Also available in: Atom