Trying to optimize
This commit is contained in:
parent
0dd54351e4
commit
5293240b89
|
@ -125,6 +125,10 @@ WebDAV client code to work with anything else I found.
|
|||
* Keycloak - Didn't try it, looked way too complicated.
|
||||
|
||||
|
||||
# Todo
|
||||
|
||||
* [ ] Performance testing: somehow this takes more CPU than caddy?
|
||||
|
||||
# Project Home
|
||||
|
||||
The canonical home for this project is
|
||||
|
|
|
@ -91,16 +91,17 @@ func rootHandler(w http.ResponseWriter, req *http.Request) {
|
|||
status = "succeeded"
|
||||
w.Header().Set("X-Simpleauth-Username", username)
|
||||
|
||||
if !login {
|
||||
if login {
|
||||
// Send back a token; this will turn into a cookie
|
||||
t := token.New(secret, username, time.Now().Add(lifespan))
|
||||
w.Header().Set("X-Simpleauth-Cookie", fmt.Sprintf("%s=%s", CookieName, t.String()))
|
||||
w.Header().Set("X-Simpleauth-Token", t.String())
|
||||
} else {
|
||||
// This is the only time simpleauth returns 200
|
||||
// That will cause Caddy to proceed with the original request
|
||||
http.Error(w, "Success", http.StatusOK)
|
||||
return
|
||||
}
|
||||
// Send back a token; this will turn into a cookie
|
||||
t := token.New(secret, username, time.Now().Add(lifespan))
|
||||
w.Header().Set("X-Simpleauth-Cookie", fmt.Sprintf("%s=%s", CookieName, t.String()))
|
||||
w.Header().Set("X-Simpleauth-Token", t.String())
|
||||
// Fall through to the 401 response, though,
|
||||
// so that Caddy will send our response back to the client,
|
||||
// which needs these headers to set the cookie and try again.
|
||||
|
@ -119,10 +120,12 @@ func rootHandler(w http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
|
||||
// Log the request
|
||||
if false {
|
||||
log.Printf("%s %s %s login:%v %s",
|
||||
clientIP, forwardedMethod, forwardedURL.String(),
|
||||
login, status,
|
||||
)
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Header().Set("X-Simpleauth-Authentication", status)
|
||||
|
|
Loading…
Reference in New Issue