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

Scala Stream Collector: allow use of the originating scheme during cookie bounce #3512

Conversation

rbolkey
Copy link
Contributor

@rbolkey rbolkey commented Nov 20, 2017

Commit adds a new configuration parameter (forwardedProtocolHeader) in the
cookie bounce feature. This parameter specifies the name of an http header
that contains the originating protocol if deployed behind a load balancer.

This is useful if SSL termination happens at the load balancer in order to
maintain the security model of you web page.

Fixes #3505

@snowplowcla
Copy link

@rbolkey has signed the Software Grant and Corporate Contributor License Agreement. Thanks so much

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

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

Looks good overall 👍

RawHeader("P3P", "policyref=\"%s\", CP=\"%s\"".format(config.p3p.policyRef, config.p3p.CP)),
accessControlAllowOriginHeader(request),
`Access-Control-Allow-Credentials`(true)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we leave this as it was?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

woops ... didn't realize I had changed that

queryParams: Map[String, String],
uri: Uri,
cookieBounceName: String,
queryParams: Map[String,String],
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing space [String, String]

enabled: Boolean,
name: String,
fallbackNetworkUserId: String,
forwardedProtocolHeader: Option[String]
Copy link
Contributor

Choose a reason for hiding this comment

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

the indent seems off

)
}.getOrElse(redirectUri)

Some(`Location`(redirectUriWithForwardedScheme))
} else {
None
}
Copy link
Contributor

Choose a reason for hiding this comment

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

let's refactor this as:

if (bounce) {
  val forwardedScheme = for {
    headerName <- bounceConfig.forwardedProtocolHeader
    headerValue  <- request.headers.find(_.lowercaseName == headerName.toLowerCase)
    scheme         <-
      if (Set("http", "https").contains(headerValue)) {
        Some(headerValue)
      else {
        logger.warn(s"Header $headerName contains invalid protocol value $headerValue.")
        None
     }
  } yield scheme

  val redirectUri = request.uri
    .withQuery(Uri.Query(queryParams + (bounceConfig.name -> "true")))
    .withScheme(forwardedScheme.getOrElse(request.uri.scheme))
  Some(`Location`(redirectUri))  
} else {
  None
}

@rbolkey
Copy link
Contributor Author

rbolkey commented Nov 21, 2017

Thanks @BenFradet. I've applied the recommended changes. Let me know if I missed anything.

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

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

Looks great, could you rebase against master? 👍

# Optionally, specify the name of the header containing the originating protocol for use in the bounce redirect
# location. Use this if behind a load balancer that performs SSL termination. The value of this header must
# be http or https. Example, if behind an AWS Classic ELB.
forwardedProtocolHeader: "X-Forwarded-Proto"
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 use = as above?

@BenFradet BenFradet added this to the R9x [STR] Priority fixes milestone Nov 22, 2017
@BenFradet BenFradet self-assigned this Nov 22, 2017
Richard Bolkey added 3 commits November 22, 2017 16:06
Commit adds a new configuration parameter (`forwardedProtocolHeader`) in the
cookie bounce feature. This parameter specifies the name of an http header
that contains the originating protocol if deployed behind a load balancer.

This is useful if SSL termination happens at the load balancer in order to
maintain the security model of you web page.
@rbolkey rbolkey force-pushed the onespot-forwarded-proto-in-cookie-bounce branch from 3f04abf to f6ae60d Compare November 22, 2017 22:06
@rbolkey
Copy link
Contributor Author

rbolkey commented Nov 22, 2017

@BenFradet fixed the example config, and rebased.

@BenFradet BenFradet changed the title Allow use of the originating protocol in the cookie bounce feature. Scala Stream Collector: allow use of the originating scheme during cookie bounce Dec 15, 2017
BenFradet pushed a commit that referenced this pull request Dec 15, 2017
…okie bounce (closes #3512)

Commit adds a new configuration parameter (`forwardedProtocolHeader`) in the
cookie bounce feature. This parameter specifies the name of an http header
that contains the originating protocol if deployed behind a load balancer.

This is useful if SSL termination happens at the load balancer in order to
maintain the security model of you web page.
BenFradet pushed a commit that referenced this pull request Dec 15, 2017
…okie bounce (closes #3512)

Commit adds a new configuration parameter (`forwardedProtocolHeader`) in the
cookie bounce feature. This parameter specifies the name of an http header
that contains the originating protocol if deployed behind a load balancer.

This is useful if SSL termination happens at the load balancer in order to
maintain the security model of you web page.
BenFradet pushed a commit that referenced this pull request Dec 15, 2017
…okie bounce (closes #3512)

Commit adds a new configuration parameter (`forwardedProtocolHeader`) in the
cookie bounce feature. This parameter specifies the name of an http header
that contains the originating protocol if deployed behind a load balancer.

This is useful if SSL termination happens at the load balancer in order to
maintain the security model of you web page.
@BenFradet BenFradet closed this in 8a26b36 Jan 5, 2018
lukeindykiewicz pushed a commit to snowplow/stream-collector that referenced this pull request Jun 4, 2020
…plow/snowplow#3512)

Commit adds a new configuration parameter (`forwardedProtocolHeader`) in the
cookie bounce feature. This parameter specifies the name of an http header
that contains the originating protocol if deployed behind a load balancer.

This is useful if SSL termination happens at the load balancer in order to
maintain the security model of you web page.
lukeindykiewicz pushed a commit to snowplow/stream-collector that referenced this pull request Jun 5, 2020
…plow/snowplow#3512)

Commit adds a new configuration parameter (`forwardedProtocolHeader`) in the
cookie bounce feature. This parameter specifies the name of an http header
that contains the originating protocol if deployed behind a load balancer.

This is useful if SSL termination happens at the load balancer in order to
maintain the security model of you web page.
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.

None yet

3 participants