Skip to content

Commit

Permalink
Remove deprecated elements
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldcroes authored and traefiker committed Aug 6, 2018
1 parent e92b01c commit 015cd7a
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 204 deletions.
2 changes: 1 addition & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions docs/configuration/backends/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ Træfik can be configured with a file.
passTLSCert = true
priority = 42

# Use frontends.frontend1.auth.basic below instead
basicAuth = [
"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
]

[frontends.frontend1.auth]
headerField = "X-WebAuth-User"
[frontends.frontend1.auth.basic]
Expand Down
6 changes: 5 additions & 1 deletion integration/fixtures/tracing/simple.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ debug = true
[frontends.frontend3]
passHostHeader = true
backend = "backend3"
basicAuth = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
[frontends.frontend3.auth.basic]
users = [
"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
]
[frontends.frontend3.routes.test_auth]
rule = "Path:/auth"
11 changes: 0 additions & 11 deletions middlewares/accesslog/logdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ const (
RequestPath = "RequestPath"
// RequestProtocol is the map key used for the version of HTTP requested.
RequestProtocol = "RequestProtocol"
// RequestLine is the original request line
RequestLine = "RequestLine"
// RequestContentSize is the map key used for the number of bytes in the request entity (a.k.a. body) sent by the client.
RequestContentSize = "RequestContentSize"
// RequestRefererHeader is the Referer header in the request
Expand All @@ -55,14 +53,8 @@ const (
// OriginStatus is the map key used for the HTTP status code returned by the origin server.
// If the request was handled by this Traefik instance (e.g. with a redirect), then this value will be absent.
OriginStatus = "OriginStatus"
// OriginStatusLine is the map key used for the HTTP status code and corresponding descriptive string.
// If the request was handled by this Traefik instance (e.g. with a redirect), then this value will be absent.
// Note that the actual message string might be different to what is reported here, depending on server behaviour.
OriginStatusLine = "OriginStatusLine"
// DownstreamStatus is the map key used for the HTTP status code returned to the client.
DownstreamStatus = "DownstreamStatus"
// DownstreamStatusLine is the map key used for the HTTP status line returned to the client.
DownstreamStatusLine = "DownstreamStatusLine"
// DownstreamContentSize is the map key used for the number of bytes in the response entity returned to the client.
// This is in addition to the "Content-Length" header, which may be present in the origin response.
DownstreamContentSize = "DownstreamContentSize"
Expand Down Expand Up @@ -110,9 +102,6 @@ func init() {
allCoreKeys[BackendAddr] = struct{}{}
allCoreKeys[ClientAddr] = struct{}{}
allCoreKeys[RequestAddr] = struct{}{}
allCoreKeys[RequestLine] = struct{}{}
allCoreKeys[OriginStatusLine] = struct{}{}
allCoreKeys[DownstreamStatusLine] = struct{}{}
allCoreKeys[GzipRatio] = struct{}{}
allCoreKeys[StartLocal] = struct{}{}
allCoreKeys[Overhead] = struct{}{}
Expand Down
2 changes: 0 additions & 2 deletions middlewares/accesslog/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ func (l *LogHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request, next h
core[RequestMethod] = req.Method
core[RequestPath] = urlCopyString
core[RequestProtocol] = req.Proto
core[RequestLine] = fmt.Sprintf("%s %s %s", req.Method, urlCopyString, req.Proto)

core[ClientAddr] = req.RemoteAddr
core[ClientHost], core[ClientPort] = silentSplitHostPort(req.RemoteAddr)
Expand Down Expand Up @@ -262,7 +261,6 @@ func (l *LogHandler) logTheRoundTrip(logDataTable *LogData, crr *captureRequestR
core[Duration] = totalDuration

if l.keepAccessLog(crw.Status(), retryAttempts, totalDuration) {
core[DownstreamStatusLine] = fmt.Sprintf("%03d %s", crw.Status(), http.StatusText(crw.Status()))
core[DownstreamContentSize] = crw.Size()
if original, ok := core[OriginContentSize]; ok {
o64 := original.(int64)
Expand Down
2 changes: 0 additions & 2 deletions middlewares/accesslog/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ func TestLoggerJSON(t *testing.T) {
RequestPath: assertString(testPath),
RequestProtocol: assertString(testProto),
RequestPort: assertString("-"),
RequestLine: assertString(fmt.Sprintf("%s %s %s", testMethod, testPath, testProto)),
DownstreamStatus: assertFloat64(float64(testStatus)),
DownstreamStatusLine: assertString(fmt.Sprintf("%d ", testStatus)),
DownstreamContentSize: assertFloat64(float64(len(testContent))),
OriginContentSize: assertFloat64(float64(len(testContent))),
OriginStatus: assertFloat64(float64(testStatus)),
Expand Down
2 changes: 0 additions & 2 deletions middlewares/accesslog/save_backend.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package accesslog

import (
"fmt"
"net/http"
"time"

Expand Down Expand Up @@ -58,7 +57,6 @@ func serveSaveBackend(rw http.ResponseWriter, r *http.Request, backendName strin
// use UTC to handle switchover of daylight saving correctly
table.Core[OriginDuration] = time.Now().UTC().Sub(start)
table.Core[OriginStatus] = crw.Status()
table.Core[OriginStatusLine] = fmt.Sprintf("%03d %s", crw.Status(), http.StatusText(crw.Status()))
// make copy of headers so we can ensure there is no subsequent mutation during response processing
table.OriginResponse = make(http.Header)
utils.CopyHeaders(table.OriginResponse, crw.Header())
Expand Down
23 changes: 0 additions & 23 deletions provider/kubernetes/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,6 @@ const (
annotationKubernetesProtocol = "ingress.kubernetes.io/protocol"
)

// TODO [breaking] remove label support
var compatibilityMapping = map[string]string{
annotationKubernetesPreserveHost: "traefik.frontend.passHostHeader",
annotationKubernetesPassTLSCert: "traefik.frontend.passTLSCert",
annotationKubernetesFrontendEntryPoints: "traefik.frontend.entryPoints",
annotationKubernetesPriority: "traefik.frontend.priority",
annotationKubernetesCircuitBreakerExpression: "traefik.backend.circuitbreaker",
annotationKubernetesLoadBalancerMethod: "traefik.backend.loadbalancer.method",
annotationKubernetesAffinity: "traefik.backend.loadbalancer.stickiness",
annotationKubernetesSessionCookieName: "traefik.backend.loadbalancer.stickiness.cookieName",
annotationKubernetesRuleType: "traefik.frontend.rule.type",
annotationKubernetesRedirectEntryPoint: "traefik.frontend.redirect.entrypoint",
annotationKubernetesRedirectRegex: "traefik.frontend.redirect.regex",
annotationKubernetesRedirectReplacement: "traefik.frontend.redirect.replacement",
}

func getAnnotationName(annotations map[string]string, name string) string {
if _, ok := annotations[name]; ok {
return name
Expand All @@ -91,13 +75,6 @@ func getAnnotationName(annotations map[string]string, name string) string {
return label.Prefix + name
}

// TODO [breaking] remove label support
if lbl, compat := compatibilityMapping[name]; compat {
if _, ok := annotations[lbl]; ok {
return lbl
}
}

return name
}

Expand Down
8 changes: 0 additions & 8 deletions provider/kubernetes/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ func TestGetAnnotationName(t *testing.T) {
},
expected: label.Prefix + annotationKubernetesPreserveHost,
},
{
desc: "with label",
name: annotationKubernetesPreserveHost,
annotations: map[string]string{
label.TraefikFrontendPassHostHeader: "true",
},
expected: label.TraefikFrontendPassHostHeader,
},
}

for _, test := range testCases {
Expand Down
1 change: 0 additions & 1 deletion provider/kv/keynames.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const (
pathFrontendWhiteListSourceRange = "/whitelist/sourcerange"
pathFrontendWhiteListUseXForwardedFor = "/whitelist/usexforwardedfor"

pathFrontendBasicAuth = "/basicauth" // Deprecated
pathFrontendAuth = "/auth/"
pathFrontendAuthBasic = pathFrontendAuth + "basic/"
pathFrontendAuthBasicRemoveHeader = pathFrontendAuthBasic + "removeheader"
Expand Down
24 changes: 4 additions & 20 deletions provider/kv/kv_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (p *Provider) buildConfiguration() *types.Configuration {
"getPassHostHeader": p.getFuncBool(pathFrontendPassHostHeader, label.DefaultPassHostHeader),
"getPassTLSCert": p.getFuncBool(pathFrontendPassTLSCert, label.DefaultPassTLSCert),
"getEntryPoints": p.getFuncList(pathFrontendEntryPoints),
"getBasicAuth": p.getFuncList(pathFrontendBasicAuth), // Deprecated
"getAuth": p.getAuth,
"getRoutes": p.getRoutes,
"getRedirect": p.getRedirect,
Expand Down Expand Up @@ -320,20 +319,14 @@ func (p *Provider) getTLSSection(prefix string) []*tls.Configuration {
return tlsSection
}

// hasDeprecatedBasicAuth check if the frontend basic auth use the deprecated configuration
func (p *Provider) hasDeprecatedBasicAuth(rootPath string) bool {
return len(p.getList(rootPath, pathFrontendBasicAuth)) > 0
}

// GetAuth Create auth from path
func (p *Provider) getAuth(rootPath string) *types.Auth {
hasDeprecatedBasicAuth := p.hasDeprecatedBasicAuth(rootPath)
if p.hasPrefix(rootPath, pathFrontendAuth) || hasDeprecatedBasicAuth {
if p.hasPrefix(rootPath, pathFrontendAuth) {
auth := &types.Auth{
HeaderField: p.get("", rootPath, pathFrontendAuthHeaderField),
}

if p.hasPrefix(rootPath, pathFrontendAuthBasic) || hasDeprecatedBasicAuth {
if p.hasPrefix(rootPath, pathFrontendAuthBasic) {
auth.Basic = p.getAuthBasic(rootPath)
} else if p.hasPrefix(rootPath, pathFrontendAuthDigest) {
auth.Digest = p.getAuthDigest(rootPath)
Expand All @@ -348,20 +341,11 @@ func (p *Provider) getAuth(rootPath string) *types.Auth {

// getAuthBasic Create Basic Auth from path
func (p *Provider) getAuthBasic(rootPath string) *types.Basic {
basicAuth := &types.Basic{
return &types.Basic{
UsersFile: p.get("", rootPath, pathFrontendAuthBasicUsersFile),
RemoveHeader: p.getBool(false, rootPath, pathFrontendAuthBasicRemoveHeader),
Users: p.getList(rootPath, pathFrontendAuthBasicUsers),
}

// backward compatibility
if p.hasDeprecatedBasicAuth(rootPath) {
basicAuth.Users = p.getList(rootPath, pathFrontendBasicAuth)
log.Warnf("Deprecated configuration found: %s. Please use %s.", pathFrontendBasicAuth, pathFrontendAuthBasic)
} else {
basicAuth.Users = p.getList(rootPath, pathFrontendAuthBasicUsers)
}

return basicAuth
}

// getAuthDigest Create Digest Auth from path
Expand Down
102 changes: 0 additions & 102 deletions provider/kv/kv_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,38 +130,6 @@ func TestProviderBuildConfiguration(t *testing.T) {
},
},
},
{
desc: "basic auth (backward compatibility)",
kvPairs: filler("traefik",
frontend("frontend",
withPair(pathFrontendBackend, "backend"),
withList(pathFrontendBasicAuth, "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
),
backend("backend"),
),
expected: &types.Configuration{
Backends: map[string]*types.Backend{
"backend": {
LoadBalancer: &types.LoadBalancer{
Method: "wrr",
},
},
},
Frontends: map[string]*types.Frontend{
"frontend": {
Backend: "backend",
PassHostHeader: true,
EntryPoints: []string{},
Auth: &types.Auth{
Basic: &types.Basic{
Users: []string{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
},
},
},
},
},
},
{
desc: "digest auth",
kvPairs: filler("traefik",
Expand Down Expand Up @@ -281,7 +249,6 @@ func TestProviderBuildConfiguration(t *testing.T) {
withList(pathFrontendWhiteListSourceRange, "1.1.1.1/24", "1234:abcd::42/32"),
withPair(pathFrontendWhiteListUseXForwardedFor, "true"),

withList(pathFrontendBasicAuth, "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
withPair(pathFrontendAuthBasicRemoveHeader, "true"),
withList(pathFrontendAuthBasicUsers, "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
withPair(pathFrontendAuthBasicUsersFile, ".htpasswd"),
Expand Down Expand Up @@ -2163,20 +2130,6 @@ func TestProviderGetAuth(t *testing.T) {
},
},
},
{
desc: "should return a valid basic auth (backward compatibility)",
rootPath: "traefik/frontends/foo",
kvPairs: filler("traefik",
frontend("foo",
withPair(pathFrontendBasicAuth, "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/,test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
)),
expected: &types.Auth{
Basic: &types.Basic{
Users: []string{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
},
},
},
{
desc: "should return a valid digest auth",
rootPath: "traefik/frontends/foo",
Expand Down Expand Up @@ -2240,61 +2193,6 @@ func TestProviderGetAuth(t *testing.T) {
}
}

func TestProviderHasDeprecatedBasicAuth(t *testing.T) {
testCases := []struct {
desc string
rootPath string
kvPairs []*store.KVPair
expected bool
}{
{
desc: "should return nil when no data",
expected: false,
},
{
desc: "should return a valid basic auth",
rootPath: "traefik/frontends/foo",
kvPairs: filler("traefik",
frontend("foo",
withList(pathFrontendAuthBasicUsers, "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
)),
expected: false,
},
{
desc: "should return a valid basic auth",
rootPath: "traefik/frontends/foo",
kvPairs: filler("traefik",
frontend("foo",
withList(pathFrontendBasicAuth, "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
)),
expected: true,
},
{
desc: "should return a valid basic auth",
rootPath: "traefik/frontends/foo",
kvPairs: filler("traefik",
frontend("foo",
withList(pathFrontendAuthBasicUsers, "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
withList(pathFrontendBasicAuth, "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
)),
expected: true,
},
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

p := newProviderMock(test.kvPairs)

result := p.hasDeprecatedBasicAuth(test.rootPath)

assert.Equal(t, test.expected, result)
})
}
}

func TestProviderGetRoutes(t *testing.T) {
testCases := []struct {
desc string
Expand Down
7 changes: 5 additions & 2 deletions server/server_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ func TestServerLoadConfigEmptyBasicAuth(t *testing.T) {
"frontend": {
EntryPoints: []string{"http"},
Backend: "backend",
BasicAuth: []string{""},
},
},
Backends: map[string]*types.Backend{
Expand Down Expand Up @@ -248,7 +247,11 @@ func TestReuseBackend(t *testing.T) {
th.WithFrontendName("frontend1"),
th.WithEntryPoints("http"),
th.WithRoutes(th.WithRoute("/unauthorized", "Path: /unauthorized")),
th.WithBasicAuth("foo", "bar")),
th.WithFrontEndAuth(&types.Auth{
Basic: &types.Basic{
Users: []string{"foo:bar"},
},
})),
),
th.WithBackends(th.WithBackendNew("backend",
th.WithLBMethod("wrr"),
Expand Down
13 changes: 0 additions & 13 deletions server/server_middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,6 @@ func (s *Server) buildMiddlewares(frontendName string, frontend *types.Frontend,
middle = append(middle, handler)
}

// Basic auth
if len(frontend.BasicAuth) > 0 {
log.Debugf("Adding basic authentication for frontend %s", frontendName)

authMiddleware, err := s.buildBasicAuthMiddleware(frontend.BasicAuth)
if err != nil {
return nil, nil, nil, err
}

handler := s.wrapNegroniHandlerWithAccessLog(authMiddleware, fmt.Sprintf("Basic Auth for %s", frontendName))
middle = append(middle, handler)
}

// Authentication
if frontend.Auth != nil {
authMiddleware, err := mauth.NewAuthenticator(frontend.Auth, s.tracingMiddleware)
Expand Down

0 comments on commit 015cd7a

Please sign in to comment.