Skip to content

Commit 8473eb4

Browse files
authored
Merge pull request #186 from guardian/extract-non-play-hmac-artifact
Extract non-Play-based `panda-hmac-core` artifact
2 parents 1b4b64d + 9af8d90 commit 8473eb4

File tree

18 files changed

+41
-13
lines changed

18 files changed

+41
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dist
1515
/RUNNING_PID
1616
/.settings
1717
/settings
18+
.DS_Store
1819

1920
*/conf/local.conf
2021
*/conf/devtoprod.conf

build.sbt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ val commonSettings = Seq(
2121
"-deprecation",
2222
"-release:11"
2323
),
24+
libraryDependencies ++= testDependencies,
2425
Test / testOptions +=
2526
Tests.Argument(TestFrameworks.ScalaTest, "-u", s"test-results/scala-${scalaVersion.value}", "-o")
2627
)
@@ -48,7 +49,7 @@ lazy val panDomainAuthCore = subproject("pan-domain-auth-core")
4849
)
4950

5051
def playBasedProject(playVersion: PlayVersion, projectPrefix: String, srcFolder: String) =
51-
subproject(s"$projectPrefix${playVersion.projectIdSuffix}").settings(
52+
subproject(s"$projectPrefix-${playVersion.suffix}").settings(
5253
sourceDirectory := (ThisBuild / baseDirectory).value / srcFolder / "src"
5354
)
5455

@@ -57,10 +58,15 @@ def playSupportFor(playVersion: PlayVersion) =
5758
libraryDependencies ++= playVersion.playLibs
5859
).dependsOn(panDomainAuthCore)
5960

61+
lazy val panDomainAuthHmac = Project(s"panda-hmac-core", file("hmac/core")).settings(commonSettings).settings(
62+
libraryDependencies += hmacHeaders
63+
)
64+
6065
def hmacPlayProject(playVersion: PlayVersion, playSupportProject: Project) =
61-
playBasedProject(playVersion, "panda-hmac", "pan-domain-auth-hmac").settings(
66+
Project(s"panda-hmac-${playVersion.suffix}", file(s"hmac/play/${playVersion.suffix}"))
67+
.settings(commonSettings).settings(
6268
libraryDependencies ++= hmacHeaders +: testDependencies
63-
).dependsOn(playSupportProject)
69+
).dependsOn(playSupportProject, panDomainAuthHmac)
6470

6571
lazy val panDomainAuthPlay_2_9 = playSupportFor(PlayVersion.V29)
6672
lazy val panDomainAuthHmac_2_9 = hmacPlayProject(PlayVersion.V29, panDomainAuthPlay_2_9)
@@ -82,12 +88,13 @@ lazy val root = Project("pan-domain-auth-root", file(".")).aggregate(
8288
panDomainAuthCore,
8389
panDomainAuthPlay_2_9,
8490
panDomainAuthPlay_3_0,
91+
panDomainAuthHmac,
8592
panDomainAuthHmac_2_9,
8693
panDomainAuthHmac_3_0,
8794
exampleApp
8895
).settings(
8996
publish / skip := true,
90-
releaseVersion := ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease().value,
97+
// releaseVersion := ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease().value,
9198
releaseCrossBuild := true, // true if you cross-build the project for multiple Scala versions
9299
releaseProcess := Seq[ReleaseStep](
93100
checkSnapshotDependencies,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.gu.pandahmac
2+
3+
import com.gu.hmac.HMACHeaders
4+
5+
import java.net.URI
6+
7+
class HMACClient(app: String, stage: String, secretKey: String) extends HMACHeaders {
8+
def secret: String = secretKey
9+
10+
def getHMACHeaders(uri: String): Seq[(String, String)] = {
11+
val headerValues = createHMACHeaderValues(new URI(uri))
12+
Seq(
13+
HMACHeaderNames.dateKey -> headerValues.date,
14+
HMACHeaderNames.hmacKey -> headerValues.token,
15+
HMACHeaderNames.serviceNameKey -> s"$app-$stage"
16+
)
17+
}
18+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.gu.pandahmac
2+
3+
4+
object HMACHeaderNames {
5+
val hmacKey = "X-Gu-Tools-HMAC-Token"
6+
val dateKey = "X-Gu-Tools-HMAC-Date"
7+
// Optional header to give the emulated user a nice name, if this isn't present we default to 'hmac-authed-service'
8+
val serviceNameKey = "X-Gu-Tools-Service-Name"
9+
}

pan-domain-auth-hmac/src/main/scala/com/gu/pandahmac/HmacSecrets.scala renamed to hmac/core/src/main/scala/com/gu/pandahmac/HMACSecrets.scala

File renamed without changes.

pan-domain-auth-hmac/src/test/scala/com/gu/pandahmac/HmacSecretsTest.scala renamed to hmac/core/src/test/scala/com/gu/pandahmac/HmacSecretsTest.scala

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)