Add Basic Auth per Frontend for Rancher & Docker Dynamic Provider
This commit is contained in:
parent
4e0f131fcd
commit
8a892b21e1
11 changed files with 78 additions and 2 deletions
|
@ -88,6 +88,13 @@ func (p *Provider) getFrontendRule(service rancherData) string {
|
|||
return "Host:" + strings.ToLower(strings.Replace(service.Name, "/", ".", -1)) + "." + p.Domain
|
||||
}
|
||||
|
||||
func (p *Provider) getBasicAuth(service rancherData) []string {
|
||||
if basicAuth, err := getServiceLabel(service, "traefik.frontend.auth.basic"); err == nil {
|
||||
return strings.Split(basicAuth, ",")
|
||||
}
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func (p *Provider) getFrontendName(service rancherData) string {
|
||||
// Replace '.' with '-' in quoted keys because of this issue https://github.com/BurntSushi/toml/issues/78
|
||||
return provider.Normalize(p.getFrontendRule(service))
|
||||
|
@ -411,6 +418,7 @@ func (p *Provider) loadRancherConfig(services []rancherData) *types.Configuratio
|
|||
"getPassHostHeader": p.getPassHostHeader,
|
||||
"getPriority": p.getPriority,
|
||||
"getEntryPoints": p.getEntryPoints,
|
||||
"getBasicAuth": p.getBasicAuth,
|
||||
"getFrontendRule": p.getFrontendRule,
|
||||
"hasCircuitBreakerLabel": p.hasCircuitBreakerLabel,
|
||||
"getCircuitBreakerExpression": p.getCircuitBreakerExpression,
|
||||
|
|
|
@ -396,7 +396,8 @@ func TestRancherLoadRancherConfig(t *testing.T) {
|
|||
{
|
||||
Name: "test/service",
|
||||
Labels: map[string]string{
|
||||
"traefik.port": "80",
|
||||
"traefik.port": "80",
|
||||
"traefik.frontend.auth.basic": "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/,test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
|
||||
},
|
||||
Health: "healthy",
|
||||
Containers: []string{"127.0.0.1"},
|
||||
|
@ -407,6 +408,7 @@ func TestRancherLoadRancherConfig(t *testing.T) {
|
|||
Backend: "backend-test-service",
|
||||
PassHostHeader: true,
|
||||
EntryPoints: []string{},
|
||||
BasicAuth: []string{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
|
||||
Priority: 0,
|
||||
|
||||
Routes: map[string]types.Route{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue