Skip to content

Conversation

@dtomcej
Copy link
Contributor

@dtomcej dtomcej commented Oct 26, 2017

This PR creates the ability to configure the security headers for frontends via docker labels.
This should provide comprehensive functionality such as per-frontend SSL redirection.

Based on some of the work done in #2146

Fixes #1903

@dtomcej dtomcej requested a review from a team as a code owner October 26, 2017 19:35
@ldez ldez added this to the 1.5 milestone Oct 26, 2017
@ldez ldez added the kind/enhancement a new or improved feature. label Oct 26, 2017
Copy link
Contributor

Choose a reason for hiding this comment

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

You can simplify your code like that:

"hasAllowedHostsHeaders":            p.hasLabel(types.LabelFrontendAllowedHosts),
func (p Provider) hasLabel(label string) func(container dockerData) bool {
	return func(container dockerData) bool {
		label, err := getLabel(container, label)
		return err == nil && len(label) > 0
	}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good Call!

Was just getting code roughed in. I knew that there is a lot of duplication, but I wanted to see it as a whole first, before condensing :)

@dtomcej
Copy link
Contributor Author

dtomcej commented Nov 7, 2017

In case it wasn't clear, I will be integrating k8s annotations in this PR as well, since the functions will be the same.

@ldez
Copy link
Contributor

ldez commented Nov 16, 2017

@dtomcej So that your PR is integrated in the 1.5, it is imperative that it is ready by Tuesday 21 November at the latest. 🚀

@dtomcej
Copy link
Contributor Author

dtomcej commented Nov 16, 2017

Thank you for the reminder! Will have it ready!

Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed this typo: customresoponseheaders

Copy link
Contributor

Choose a reason for hiding this comment

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

It's already fixed in master

@dtomcej dtomcej force-pushed the docker-secure-labels branch from 52fea6e to e1c388b Compare November 18, 2017 04:21
@ldez ldez removed the WIP label Nov 18, 2017
@dtomcej dtomcej force-pushed the docker-secure-labels branch 3 times, most recently from 643d9b3 to c6fa8bb Compare November 21, 2017 20:31
Copy link
Contributor

Choose a reason for hiding this comment

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

This entry is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added!

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

@dtomcej Many thanks for this PR! 👏

Just few suggestions about the documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Provides to be homogeneous with the others lines

Copy link
Contributor

Choose a reason for hiding this comment

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

Forces to be homogeneous with the others lines

Copy link
Contributor

Choose a reason for hiding this comment

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

Forces to be homogeneous with the others lines

Copy link
Contributor

Choose a reason for hiding this comment

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

Could your remove this empty line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup!

Copy link
Contributor

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

LGTM 👏 👏

Copy link
Member

@juliens juliens left a comment

Choose a reason for hiding this comment

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

LGTM

add template function list

function frameworks

add prelim function

added template functions

add functions to template

fix case on template vars

fix typo

re-add redirect

update templates

delete autogen

add security headers documentation

fix missing line

chore: add autogen.

chore: remove old generated file.

fix spelling :)

remove missing line
@dtomcej dtomcej force-pushed the docker-secure-labels branch from 0a54441 to 763a29c Compare November 22, 2017 17:53
@traefiker traefiker merged commit 7063da1 into traefik:master Nov 22, 2017
@robholland
Copy link

It doesn't look like this adds support for kubernetes?

@ldez
Copy link
Contributor

ldez commented Nov 23, 2017

@robholland this PR only concern Docker.

@robholland
Copy link

#2334 (comment) says kubernetes would be included and #2146 was closed in favour of this :(

@dtomcej
Copy link
Contributor Author

dtomcej commented Nov 23, 2017

@robholland You are correct. My intention was to have both in this PR, but it was decided to keep the two separate due to testing. Will have a new PR for k8s today. Again, apologies for the delay.

@dtomcej
Copy link
Contributor Author

dtomcej commented Nov 23, 2017

@robholland Discussed with the team, and the new PR will make it into 1.5, so will make the next release, so this delay will not affect the mainline release :)

@robholland
Copy link

Great, thanks! :)

| Label | Description |
|-----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `traefik.frontend.headers.allowedHosts=EXPR` | Provides a list of allowed hosts that requests will be processed. Format: `Host1,Host2` |
|`traefik.frontend.headers.customrequestheaders=EXPR ` | Provides the container with custom request headers that will be appended to each request forwarded to the container. Format: `HEADER:value,HEADER2:value2` |
Copy link

Choose a reason for hiding this comment

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

are these meant to be lowercase or camel case?

traefik.frontend.headers.customrequestheaders should be traefik.frontend.headers.customRequestHeaders

Copy link
Contributor

@ldez ldez Nov 30, 2017

Choose a reason for hiding this comment

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

@vito-c Please open an issue instead of commented an already merged PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

@vito-c or open a PR. thanks

LabelWeight = LabelPrefix + "weight"
LabelFrontendAuthBasic = LabelPrefix + "frontend.auth.basic"
LabelFrontendEntryPoints = LabelPrefix + "frontend.entryPoints"
LabelFrontendRequestHeader = LabelPrefix + "frontend.headers.customrequestheaders"
Copy link

Choose a reason for hiding this comment

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

if camelcase then these should be updated as well

Copy link
Contributor

@ldez ldez Nov 30, 2017

Choose a reason for hiding this comment

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

@vito-c Please open an issue instead of commented an already merged PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

@vito-c or open a PR. thanks

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants