Skip to content

Commit

Permalink
Merge pull request #241 from Banno/8.0.0-into-9
Browse files Browse the repository at this point in the history
Merge 8.0.0 into 9
  • Loading branch information
rossabaker authored Aug 3, 2021
2 parents 72cc761 + 5419670 commit f7d7578
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 119 deletions.
14 changes: 1 addition & 13 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,6 @@ lazy val core = project.in(file("core"))
import com.typesafe.tools.mima.core.ProblemFilters.exclude
// See https://github.com/lightbend/mima/issues/423
Seq(
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.Base64.decodeBase64"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.Base64.encodeBase64"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.Base64.eqBase64"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.Base64.fromStringOpt"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.CipherText.decodeCipherText"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.CipherText.encodeCipherText"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.CipherText.eqCipherText"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.Context.unapply"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.DecryptRequest.unapply"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.EncryptResult.unapply"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.EncryptResult.unapply"),
exclude[IncompatibleSignatureProblem]("com.banno.vault.transit.PlainText.unapply")
)
},
)
Expand Down Expand Up @@ -156,7 +144,7 @@ lazy val commonSettings = Seq(
"org.http4s" %% "http4s-dsl" % http4sV % Test,
"org.typelevel" %% "munit-cats-effect-3" % munitCatsEffectV % Test,
"org.scalameta" %% "munit-scalacheck" % munitScalaCheckV % Test,
"org.typelevel" %% "scalacheck-effect" % scalacheckEffectV % Test,
"org.typelevel" %% "scalacheck-effect-munit" % scalacheckEffectV % Test,

) ++ {
if(scalaVersion.value.startsWith("3")) List.empty
Expand Down
22 changes: 17 additions & 5 deletions core/src/main/scala/com/banno/vault/Vault.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import io.circe.{Decoder, DecodingFailure, Encoder, Json}
import io.circe.syntax._
import org.http4s._
import org.http4s.circe._
import org.http4s.client.{Client, UnexpectedStatus}
import org.http4s.client._
import org.http4s.implicits._
import org.typelevel.ci.CIString


Expand All @@ -50,13 +51,17 @@ object Vault {
} yield token
}


/**
* https://www.vaultproject.io/api/auth/kubernetes/index.html#login
*/
def kubernetesLogin[F[_]](client: Client[F], vaultUri: Uri)(role: String, jwt: String)(implicit F: Concurrent[F]): F[VaultToken] = {
* https://www.vaultproject.io/api/auth/kubernetes/index.html#login
*
* @param mountPoint The mount point of the Kubernetes auth method.
* Should start with a slash.
*/
def loginKubernetes[F[_]](client: Client[F], vaultUri: Uri)(role: String, jwt: String, mountPoint: Uri.Path = path"/auth/kubernetes")(implicit F: Concurrent[F]): F[VaultToken] = {
val request = Request[F](
method = Method.POST,
uri = vaultUri / "v1" / "auth" / "kubernetes" / "login"
uri = vaultUri.withPath(path"/v1" |+| mountPoint |+| path"/login")
).withEntity(
Json.obj(
("role", Json.fromString(role)),
Expand All @@ -70,6 +75,13 @@ object Vault {
} yield token
}

/**
* https://www.vaultproject.io/api/auth/kubernetes/index.html#login
*/
@deprecated("Use loginKubernetes, which parameterizes the mount point", "7.1.2")
def kubernetesLogin[F[_]](client: Client[F], vaultUri: Uri)(role: String, jwt: String)(implicit F: Concurrent[F]): F[VaultToken] =
loginKubernetes(client, vaultUri)(role, jwt)

/**
* https://www.vaultproject.io/api/secret/kv/index.html#read-secret
*/
Expand Down
Loading

0 comments on commit f7d7578

Please sign in to comment.