parent
5dcf889efe
commit
df81be1147
@ -37,7 +37,8 @@
|
|||||||
address = ":80"
|
address = ":80"
|
||||||
|
|
||||||
[entryPoints.http.auth.forward]
|
[entryPoints.http.auth.forward]
|
||||||
address = "http://forward-oauth:4181"
|
address = "http://traefik-forward-auth:4181"
|
||||||
|
authResponseHeaders = ["X-Forwarded-User"]
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Traefik logs configuration
|
# Traefik logs configuration
|
||||||
|
1
main.go
1
main.go
@ -70,6 +70,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Valid request
|
// Valid request
|
||||||
|
w.Header().Set("X-Forwarded-User", email)
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
main_test.go
15
main_test.go
@ -15,6 +15,9 @@ import (
|
|||||||
"github.com/op/go-logging"
|
"github.com/op/go-logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities
|
||||||
|
*/
|
||||||
|
|
||||||
type TokenServerHandler struct {}
|
type TokenServerHandler struct {}
|
||||||
func (t *TokenServerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (t *TokenServerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -79,6 +82,10 @@ func qsDiff(one, two url.Values) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests
|
||||||
|
*/
|
||||||
|
|
||||||
func TestHandler(t *testing.T) {
|
func TestHandler(t *testing.T) {
|
||||||
fw = &ForwardAuth{
|
fw = &ForwardAuth{
|
||||||
Path: "_oauth",
|
Path: "_oauth",
|
||||||
@ -138,6 +145,14 @@ func TestHandler(t *testing.T) {
|
|||||||
if res.StatusCode != 200 {
|
if res.StatusCode != 200 {
|
||||||
t.Error("Valid request should be allowed, got:", res.StatusCode)
|
t.Error("Valid request should be allowed, got:", res.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Should pass through user
|
||||||
|
users := res.Header["X-Forwarded-User"];
|
||||||
|
if len(users) != 1 {
|
||||||
|
t.Error("Valid request missing X-Forwarded-User header")
|
||||||
|
} else if users[0] != "test@example.com" {
|
||||||
|
t.Error("X-Forwarded-User should match user, got: ", users)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCallback(t *testing.T) {
|
func TestCallback(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user