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

Commit a8a85cb

Browse files
committed
Remove reference to remote user CtxKey so that this commit is compatible with Caddy 0.9.5. Note this shortcoming in the documentation.
1 parent 4b03d5f commit a8a85cb

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ 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+
198203
When a browser requests
199204

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

cgi.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ 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-
// 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)
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, "")
110109
cgiHnd.Stderr = &buf
111110
cgiHnd.ServeHTTP(w, r)
112111
if buf.Len() > 0 {

cgi.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ 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+
204209
When a browser requests
205210

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

doc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ 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+
193198
When a browser requests
194199
195200
http://192.168.1.2:8080/show/weekly?mode=summary

doc.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ 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+
217222
When a browser requests
218223

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

0 commit comments

Comments
 (0)