Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 473e48a

Browse files
committed
Reinstate remote user for versions of Caddy after 0.9.5
1 parent a8a85cb commit 473e48a

File tree

5 files changed

+4
-23
lines changed

5 files changed

+4
-23
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ script may use a different method to read POST content. Secondly, the
195195
and contains the entire command line, including all arguments, with which the
196196
CGI script was executed.
197197

198-
**Note**: The basicauth plugin for Caddy 0.9.5 and earlier does not provide
199-
remote user information to other middleware such as this CGI plugin. To use the
200-
REMOTE_USER environment variable, you need to wait for Caddy 0.10.0 or build
201-
your Caddy executable from the current source tree.
202-
203198
When a browser requests
204199

205200
http://192.168.1.2:8080/show/weekly?mode=summary

cgi.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ func (h handlerType) ServeHTTP(w http.ResponseWriter, r *http.Request) (code int
103103
ok, lfStr, rtStr := match(r.URL.Path, matchStr)
104104
if ok {
105105
var buf bytes.Buffer
106-
// Remote user is not available in Caddy 0.9.5. Use a blank string for
107-
// remote user until Caddy 0.10.0.
108-
cgiHnd := setupCall(h, rule, lfStr, rtStr, rep, "")
106+
// Retrieve name of remote user that was set by some downstream middleware,
107+
// possibly basicauth.
108+
remoteUser, _ := r.Context().Value(httpserver.RemoteUserCtxKey).(string) // Blank if not set
109+
cgiHnd := setupCall(h, rule, lfStr, rtStr, rep, remoteUser)
109110
cgiHnd.Stderr = &buf
110111
cgiHnd.ServeHTTP(w, r)
111112
if buf.Len() > 0 {

cgi.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,6 @@ script may use a different method to read POST content. Secondly, the
201201
and contains the entire command line, including all arguments, with which the
202202
CGI script was executed.
203203

204-
<mark class="block">**Note**: The basicauth plugin for Caddy 0.9.5 and earlier does not provide
205-
remote user information to other middleware such as this CGI plugin. To use the
206-
REMOTE_USER environment variable, you need to wait for Caddy 0.10.0 or build
207-
your Caddy executable from the current source tree.</mark>
208-
209204
When a browser requests
210205

211206
http://192.168.1.2:8080/show/weekly?mode=summary

doc.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,6 @@ SCRIPT_EXEC variable is not a CGI standard. It is provided by this middleware
190190
and contains the entire command line, including all arguments, with which the
191191
CGI script was executed.
192192
193-
Note: The basicauth plugin for Caddy 0.9.5 and earlier does not provide
194-
remote user information to other middleware such as this CGI plugin. To use the
195-
REMOTE_USER environment variable, you need to wait for Caddy 0.10.0 or build
196-
your Caddy executable from the current source tree.
197-
198193
When a browser requests
199194
200195
http://192.168.1.2:8080/show/weekly?mode=summary

doc.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,6 @@ script may use a different method to read POST content. Secondly, the
214214
and contains the entire command line, including all arguments, with which the
215215
CGI script was executed.
216216

217-
**Note**: The basicauth plugin for Caddy 0.9.5 and earlier does not provide
218-
remote user information to other middleware such as this CGI plugin. To use the
219-
REMOTE_USER environment variable, you need to wait for Caddy 0.10.0 or build
220-
your Caddy executable from the current source tree.
221-
222217
When a browser requests
223218

224219
http://192.168.1.2:8080/show/weekly?mode=summary

0 commit comments

Comments
 (0)