Skip to content

Commit

Permalink
Add mandatory SLULA license acceptance flag (close #405)
Browse files Browse the repository at this point in the history
Since introducing a new license we need to explicitly check if the user
has accepted the terms. Therefore a new flag is added.
By default it is set to false but can be overrided by either:
- setting `license.accept = true` in the config file
- setting `env ACCEPT_LIMITED_USE_LICENSE=true`
- appending `-Dlicense.accept=true`
  • Loading branch information
peel committed Jan 8, 2024
1 parent e85d055 commit 7a45a7c
Show file tree
Hide file tree
Showing 37 changed files with 112 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 'collector' contains configuration options for the main Scala collector.
collector {
license { accept = true }
# The collector runs as a web service specified on the following interface and port.
interface = "0.0.0.0"
port = "9292"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 'collector' contains configuration options for the main Scala collector.
collector {
license { accept = true }
# The collector runs as a web service specified on the following interface and port.
interface = "0.0.0.0"
port = "10292"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ssc-collector-config/config.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = 0.0.0.0
port = 12345

Expand Down
5 changes: 5 additions & 0 deletions core/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
license {
accept = false
accept = ${?ACCEPT_LIMITED_USE_LICENSE}
}

paths {}

p3p {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ case class Config[+SinkConfig](
networking: Config.Networking,
enableDefaultRedirect: Boolean,
redirectDomains: Set[String],
preTerminationPeriod: FiniteDuration
preTerminationPeriod: FiniteDuration,
license: Config.License
)

object Config {
Expand Down Expand Up @@ -154,7 +155,17 @@ object Config {
idleTimeout: FiniteDuration
)

case class License(
accept: Boolean
)

implicit def decoder[SinkConfig: Decoder]: Decoder[Config[SinkConfig]] = {
implicit val license: Decoder[License] = {
val truthy = Set("true", "yes", "on", "1")
Decoder
.forProduct1("accept")((s: String) => License(truthy(s.toLowerCase())))
.or(Decoder.forProduct1("accept")((b: Boolean) => License(b)))
}
implicit val p3p = deriveDecoder[P3P]
implicit val crossDomain = deriveDecoder[CrossDomain]
implicit val sameSite: Decoder[SameSite] = Decoder.instance { cur =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ object Run {
): F[ExitCode] = {
val eitherT = for {
config <- ConfigParser.fromPath[F, SinkConfig](path)
_ <- checkLicense(config.license.accept)
_ <- EitherT.right[ExitCode](fromConfig(appInfo, mkSinks, telemetryInfo, config))
} yield ExitCode.Success

Expand All @@ -67,6 +68,18 @@ object Run {
}
}

private def checkLicense[F[_]: Sync](acceptLicense: Boolean): EitherT[F, ExitCode, _] =
EitherT.liftF {
if (acceptLicense)
Sync[F].unit
else
Sync[F].raiseError(
new IllegalStateException(
"Please accept the terms of the Snowplow Limited Use License Agreement to proceed. See https://docs.snowplow.io/docs/pipeline-components-and-applications/stream-collector/configure/#license for more information on the license and how to configure this."
)
)
}

private def fromConfig[F[_]: Async: Tracking, SinkConfig](
appInfo: AppInfo,
mkSinks: MkSinks[F, SinkConfig],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class ConfigParserSpec extends Specification with CatsEffect {
.copy[SinkConfig](
paths = Map.empty[String, String],
streams = expectedStreams,
ssl = TestUtils.testConfig.ssl.copy(enable = true)
ssl = TestUtils.testConfig.ssl.copy(enable = true),
license = Config.License(false)
)

ConfigParser.fromPath[IO, SinkConfig](Some(path)).value.map(_ should beRight(expected))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ object TestUtils {
moduleVersion = None,
instanceId = None,
autoGeneratedId = None
)
),
license = License(accept = true)
)
}
5 changes: 5 additions & 0 deletions examples/config.kafka.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

# 'collector' contains configuration options for the main Scala collector.
collector {
# Full license text available in LICENSE.md
license {
accept = true
}

# The collector runs as a web service specified on the following interface and port.
interface = "0.0.0.0"
port = 8080
Expand Down
4 changes: 4 additions & 0 deletions examples/config.kafka.minimal.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
collector {
license {
accept = true
}

interface = "0.0.0.0"
port = 8080

Expand Down
5 changes: 5 additions & 0 deletions examples/config.kinesis.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

# 'collector' contains configuration options for the main Scala collector.
collector {
# Full license text available in LICENSE.md
license {
accept = true
}

# The collector runs as a web service specified on the following interface and port.
interface = "0.0.0.0"
port = 8080
Expand Down
4 changes: 4 additions & 0 deletions examples/config.kinesis.minimal.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
collector {
license {
accept = true
}

interface = "0.0.0.0"
port = 8080

Expand Down
5 changes: 5 additions & 0 deletions examples/config.nsq.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

# 'collector' contains configuration options for the main Scala collector.
collector {
# Full license text available in LICENSE.md
license {
accept = true
}

# The collector runs as a web service specified on the following interface and port.
interface = "0.0.0.0"
port = 8080
Expand Down
7 changes: 5 additions & 2 deletions examples/config.nsq.minimal.hocon
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
collector {
license {
accept = true
}
interface = "0.0.0.0"
port = 8080

streams {
good {
name = "good"
host = "nsqHost"
}
}

bad {
name = "bad"
host = "nsqHost"
Expand Down
5 changes: 5 additions & 0 deletions examples/config.pubsub.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

# 'collector' contains configuration options for the main Scala collector.
collector {
# Full license text available in LICENSE.md
license {
accept = true
}

# The collector runs as a web service specified on the following interface and port.
interface = "0.0.0.0"
port = 8080
Expand Down
4 changes: 4 additions & 0 deletions examples/config.pubsub.minimal.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
collector {
license {
accept = true
}

interface = "0.0.0.0"
port = 8080

Expand Down
5 changes: 5 additions & 0 deletions examples/config.sqs.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

# 'collector' contains configuration options for the main Scala collector.
collector {
# Full license text available in LICENSE.md
license {
accept = true
}

# The collector runs as a web service specified on the following interface and port.
interface = "0.0.0.0"
port = 8080
Expand Down
3 changes: 3 additions & 0 deletions examples/config.sqs.minimal.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
collector {
license {
accept = true
}
interface = "0.0.0.0"
port = 8080

Expand Down
5 changes: 5 additions & 0 deletions examples/config.stdout.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

# 'collector' contains configuration options for the main Scala collector.
collector {
# Full license text available in LICENSE.md
license {
accept = true
}

# The collector runs as a web service specified on the following interface and port.
interface = "0.0.0.0"
port = 8080
Expand Down
3 changes: 3 additions & 0 deletions examples/config.stdout.minimal.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
collector {
license {
accept = true
}
interface = "0.0.0.0"
port = 8080

Expand Down
1 change: 1 addition & 0 deletions kafka/src/it/resources/collector.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ object KafkaConfigSpec {
networking = Config.Networking(
maxConnections = 1024,
idleTimeout = 610.seconds
)
),
license = Config.License(accept = true)
)
}
1 change: 1 addition & 0 deletions kinesis/src/it/resources/collector-cookie-anonymous.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
1 change: 1 addition & 0 deletions kinesis/src/it/resources/collector-cookie-domain.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
1 change: 1 addition & 0 deletions kinesis/src/it/resources/collector-cookie-fallback.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
1 change: 1 addition & 0 deletions kinesis/src/it/resources/collector-cookie-no-domain.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
1 change: 1 addition & 0 deletions kinesis/src/it/resources/collector-custom-paths.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
1 change: 1 addition & 0 deletions kinesis/src/it/resources/collector.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ object KinesisConfigSpec {
moduleVersion = None,
instanceId = None,
autoGeneratedId = None
)
),
license = Config.License(accept = true)
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ object NsqConfigSpec {
networking = Config.Networking(
maxConnections = 1024,
idleTimeout = 610.seconds
)
),
license = Config.License(accept = true)
)
}
1 change: 1 addition & 0 deletions pubsub/src/it/resources/collector.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
collector {
license { accept = true }
interface = "0.0.0.0"
port = ${PORT}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ object ConfigSpec {
moduleVersion = None,
instanceId = None,
autoGeneratedId = None
)
),
license = Config.License(accept = true)
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ object SqsConfigSpec {
moduleVersion = None,
instanceId = None,
autoGeneratedId = None
)
),
license = Config.License(accept = true)
)

}

0 comments on commit 7a45a7c

Please sign in to comment.