mirror of https://github.com/sbt/sbt.git
Merge pull request #220 from alexarchambault/header-based-auth
Allow authenticating via custom HTTP headers
This commit is contained in:
commit
f336c89561
|
|
@ -1 +1,8 @@
|
|||
target/
|
||||
|
||||
# Metals / bloop
|
||||
.metals/
|
||||
.bloop/
|
||||
|
||||
# Intellij
|
||||
.idea/
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ import scala.concurrent.duration.Duration
|
|||
withStrict(Some(strict))
|
||||
def withTtl(ttl: Duration): CoursierConfiguration =
|
||||
withTtl(Some(ttl))
|
||||
def addRepositoryAuthentication(repositoryId: String, authentication: Authentication): CoursierConfiguration =
|
||||
withAuthenticationByRepositoryId(authenticationByRepositoryId :+ (repositoryId, authentication))
|
||||
}
|
||||
|
||||
object CoursierConfiguration {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,30 @@
|
|||
package lmcoursier.definitions
|
||||
|
||||
import dataclass.data
|
||||
import dataclass._
|
||||
|
||||
@data class Authentication(
|
||||
user: String,
|
||||
password: String,
|
||||
optional: Boolean = false,
|
||||
realmOpt: Option[String] = None
|
||||
realmOpt: Option[String] = None,
|
||||
@since
|
||||
headers: Seq[(String,String)] = Nil,
|
||||
httpsOnly: Boolean = true,
|
||||
passOnRedirect: Boolean = false
|
||||
) {
|
||||
override def toString(): String =
|
||||
withPassword("****")
|
||||
.withHeaders(
|
||||
headers.map {
|
||||
case (k, v) => (k, "****")
|
||||
}
|
||||
)
|
||||
.productIterator
|
||||
.mkString("Authentication(", ", ", ")")
|
||||
}
|
||||
|
||||
object Authentication {
|
||||
|
||||
def apply(headers: Seq[(String, String)]): Authentication =
|
||||
Authentication("", "").withHeaders(headers)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ object ToCoursier {
|
|||
coursier.core.Authentication(authentication.user, authentication.password)
|
||||
.withOptional(authentication.optional)
|
||||
.withRealmOpt(authentication.realmOpt)
|
||||
.withHttpHeaders(authentication.headers)
|
||||
.withHttpsOnly(authentication.httpsOnly)
|
||||
.withPassOnRedirect(authentication.passOnRedirect)
|
||||
|
||||
def module(module: Module): coursier.core.Module =
|
||||
coursier.core.Module(
|
||||
|
|
|
|||
Loading…
Reference in New Issue