mirror of https://github.com/sbt/sbt.git
Allow authenticating via custom HTTP headers
This commit is contained in:
parent
8c2d660434
commit
e2876fb23e
|
|
@ -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,28 @@
|
|||
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
|
||||
) {
|
||||
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("", "", optional = false, None, headers)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ object ToCoursier {
|
|||
coursier.core.Authentication(authentication.user, authentication.password)
|
||||
.withOptional(authentication.optional)
|
||||
.withRealmOpt(authentication.realmOpt)
|
||||
.withHttpHeaders(authentication.headers)
|
||||
|
||||
def module(module: Module): coursier.core.Module =
|
||||
coursier.core.Module(
|
||||
|
|
|
|||
Loading…
Reference in New Issue