Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth support in frontends #3559

Merged
merged 28 commits into from
Jul 6, 2018
Merged

Conversation

jbdoumenjou
Copy link
Member

@jbdoumenjou jbdoumenjou commented Jul 4, 2018

What does this PR do?

Authentication support in frontends for the following providers:

Motivation

Fixes #2116, #2162, #2734
Related to #1465, #3460

More

  • Added/updated tests
  • Added/updated documentation

return basicAuth
}

//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this line.


// GetAuth Create auth from labels
func (p *Provider) getAuth(rootPath string) *types.Auth {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this empty line.

@@ -24,38 +24,188 @@ func TestProviderBuildConfiguration(t *testing.T) {
kvPairs []*store.KVPair
expected *types.Configuration
}{
//{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you uncomment or remove this test.


{{ $whitelist := getWhiteList $instance.TraefikLabels }}
{{ $whitelist := getWhiteList $instance.TraefikLabels }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you restore the previous line.


{{ $whitelist := getWhiteList $frontend }}
{{ $whitelist := getWhiteList $frontend }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you restore the previous line.


{{ $whitelist := getWhiteList $app.SegmentLabels }}
{{ $whitelist := getWhiteList $app.SegmentLabels }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you restore the previous line.


{{ $whitelist := getWhiteList $app.TraefikLabels }}
{{ $whitelist := getWhiteList $app.TraefikLabels }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you restore the previous line.


{{ $whitelist := getWhiteList $service.SegmentLabels }}
{{ $whitelist := getWhiteList $service.SegmentLabels }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you restore the previous line.

TrustForwardHeader: p.getBool(false, rootPath, pathFrontendAuthForwardTrustForwardHeader),
}

//TLS configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a whitespace.

// TLS configuration


return auth
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// GetAuth Create auth from labels
func GetAuth(labels map[string]string) *types.Auth {
	if !HasPrefix(labels, TraefikFrontendAuth) {
		return nil
	}

	auth := &types.Auth{
		HeaderField: GetStringValue(labels, TraefikFrontendAuthHeaderField, ""),
	}

	if HasPrefix(labels, TraefikFrontendAuthBasic) {
		auth.Basic = getAuthBasic(labels)
	} else if HasPrefix(labels, TraefikFrontendAuthDigest) {
		auth.Digest = getAuthDigest(labels)
	} else if HasPrefix(labels, TraefikFrontendAuthForward) {
		auth.Forward = getAuthForward(labels)
	}

	return auth
}

| `<prefix>.frontend.auth.digest.users=EXPR` | Sets digest authentication to this frontend in CSV format: `User:Realm:Hash,User:Realm:Hash`. |
| `<prefix>.frontend.auth.digest.usersfile=/path/.htdigest` | Sets digest authentication with an external file; if users and usersFile are provided, both are merged, with external file contents having precedence. |
| `<prefix>.frontend.auth.forward.address=https://example.com`| The URL of the authentication server. |
| `<prefix>.frontend.auth.forward.tls.ca=/path/ca.pem` | Set the Certificate Authority (CA) for the TLS connection with the authentication server. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets instead of Set

| `<prefix>.frontend.auth.forward.address=https://example.com`| The URL of the authentication server. |
| `<prefix>.frontend.auth.forward.tls.ca=/path/ca.pem` | Set the Certificate Authority (CA) for the TLS connection with the authentication server. |
| `<prefix>.frontend.auth.forward.tls.caOptional=true` | Check the certificates if present but do not force to be signed by a specified Certificate Authority (CA). |
| `<prefix>.frontend.auth.forward.tls.cert=/path/server.pem` | Set the Certificate for the TLS connection with the authentication server. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets instead of Set

| `<prefix>.frontend.auth.forward.tls.caOptional=true` | Check the certificates if present but do not force to be signed by a specified Certificate Authority (CA). |
| `<prefix>.frontend.auth.forward.tls.cert=/path/server.pem` | Set the Certificate for the TLS connection with the authentication server. |
| `<prefix>.frontend.auth.forward.tls.insecureSkipVerify=true`| If set to true invalid SSL certificates are accepted. |
| `<prefix>.frontend.auth.forward.tls.key=/path/server.key` | Set the Certificate for the TLS connection with the authentication server. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets instead of Set

| `<prefix>.frontend.auth.digest.usersfile=/path/.htdigest` | Sets digest authentication with an external file; if users and usersFile are provided, both are merged, with external file contents having precedence. |
| `<prefix>.frontend.auth.forward.address=https://example.com`| The URL of the authentication server. |
| `<prefix>.frontend.auth.forward.tls.ca=/path/ca.pem` | Set the Certificate Authority (CA) for the TLS connection with the authentication server. |
| `<prefix>.frontend.auth.forward.tls.caOptional=true` | Check the certificates if present but do not force to be signed by a specified Certificate Authority (CA). |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks instead of Check

| `traefik.frontend.auth.digest.users=EXPR` | Sets digest authentication to this frontend in CSV format: `User:Realm:Hash,User:Realm:Hash`. |
| `traefik.frontend.auth.digest.usersfile=/path/.htdigest` | Sets digest authentication with an external file; if users and usersFile are provided, both are merged, with external file contents having precedence. |
| `traefik.frontend.auth.forward.address=https://example.com`| The URL of the authentication server. |
| `traefik.frontend.auth.forward.tls.ca=/path/ca.pem` | Set the Certificate Authority (CA) for the TLS connection with the authentication server. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets instead of Set

| `traefik.frontend.auth.forward.tls.caOptional=true` | Check the certificates if present but do not force to be signed by a specified Certificate Authority (CA). |
| `traefik.frontend.auth.forward.tls.cert=/path/server.pem` | Set the Certificate for the TLS connection with the authentication server. |
| `traefik.frontend.auth.forward.tls.insecureSkipVerify=true`| If set to true invalid SSL certificates are accepted. |
| `traefik.frontend.auth.forward.tls.key=/path/server.key` | Set the Certificate for the TLS connection with the authentication server. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets instead of Set

| `traefik.frontend.auth.digest.users=EXPR` | Sets digest authentication to this frontend in CSV format: `User:Realm:Hash,User:Realm:Hash`. |
| `traefik.frontend.auth.digest.usersfile=/path/.htdigest` | Sets digest authentication with an external file; if users and usersFile are provided, both are merged, with external file contents having precedence. |
| `traefik.frontend.auth.forward.address=https://example.com`| The URL of the authentication server. |
| `traefik.frontend.auth.forward.tls.ca=/path/ca.pem` | Set the Certificate Authority (CA) for the TLS connection with the authentication server. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets instead of Set

| `traefik.frontend.auth.digest.usersfile=/path/.htdigest` | Sets digest authentication with an external file; if users and usersFile are provided, both are merged, with external file contents having precedence. |
| `traefik.frontend.auth.forward.address=https://example.com`| The URL of the authentication server. |
| `traefik.frontend.auth.forward.tls.ca=/path/ca.pem` | Set the Certificate Authority (CA) for the TLS connection with the authentication server. |
| `traefik.frontend.auth.forward.tls.caOptional=true` | Check the certificates if present but do not force to be signed by a specified Certificate Authority (CA). |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks instead of Check

| `traefik.frontend.auth.forward.address=https://example.com`| The URL of the authentication server. |
| `traefik.frontend.auth.forward.tls.ca=/path/ca.pem` | Set the Certificate Authority (CA) for the TLS connection with the authentication server. |
| `traefik.frontend.auth.forward.tls.caOptional=true` | Check the certificates if present but do not force to be signed by a specified Certificate Authority (CA). |
| `traefik.frontend.auth.forward.tls.cert=/path/server.pem` | Set the Certificate for the TLS connection with the authentication server. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets instead of Set

| `traefik.frontend.auth.forward.tls.caOptional=true` | Check the certificates if present but do not force to be signed by a specified Certificate Authority (CA). |
| `traefik.frontend.auth.forward.tls.cert=/path/server.pem` | Set the Certificate for the TLS connection with the authentication server. |
| `traefik.frontend.auth.forward.tls.insecureSkipVerify=true`| If set to true invalid SSL certificates are accepted. |
| `traefik.frontend.auth.forward.tls.key=/path/server.key` | Set the Certificate for the TLS connection with the authentication server. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets instead of Set

"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
Auth: &types.Auth{
//HeaderField: "X-WebAuth-User",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why keep this comment?

Basic: &types.Basic{
Users: []string{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
//UsersFile: ".htpasswd",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why keep this comment?

{{end}}

{{if $auth.Digest }}
[frontends.{{ $frontendName }}.auth.digest]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are no " for {{ $frontendName }}?

{{end}}

{{if $auth.Basic }}
[frontends.{{ $frontendName }}.auth.basic]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are no " for {{ $frontendName }}?

trustForwardHeader = {{ $auth.Forward.TrustForwardHeader }}

{{if $auth.Forward.TLS }}
[frontends.{{ $frontendName }}.auth.forward.tls]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are no " for {{ $frontendName }}?


{{if $auth.Digest }}
[frontends.frontend-{{ $frontendName }}.auth.digest]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are no " for frontend-{{ $frontendName }}?

headerField = "{{ $auth.HeaderField }}"

{{if $auth.Forward }}
[frontends.frontend-{{ $frontendName }}.auth.forward]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are no " for frontend-{{ $frontendName }}?

trustForwardHeader = {{ $auth.Forward.TrustForwardHeader }}

{{if $auth.Forward.TLS }}
[frontends.frontend-{{ $frontendName }}.auth.forward.tls]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are no " for frontend-{{ $frontendName }}?

{{end}}

{{if $auth.Basic }}
[frontends.frontend-{{ $frontendName }}.auth.basic]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are no " for frontend-{{ $frontendName }}?

{{end}}

{{if $auth.Digest }}
[frontends.frontend-{{ $frontendName }}.auth.digest]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are no " for frontend-{{ $frontendName }}?

@mmatur
Copy link
Member

mmatur commented Jul 5, 2018

@jbdoumenjou
Copy link
Member Author

@mmatur, I hadn't worked on the k8s provider, it is another PR (#3460 ). It seems that we keep this part of the template. So, I don't know if I have to clean the k8s template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants