In https://docs.gradle.org/2.7/release-notes.html#support-for-preemptive-http-authentication it demonstrates that you can tell Gradle to preemptively sent BasicAuth headers.
I should be able to configure the Authentication method
repositories {
maven {
url = uri("https://my.mavenrepo.com/artifactory/mvn-main")
authentication {
basic(BasicAuthentication) // enable preemptive authentication (won't compile)
}
credentials {
username = mavenUser
password = password
}
}
}
It isn't clear how to enable the BasicAuth preemptive auth mechanism.
I'm trying to enable auth in the pluginManagement in my settings.gradle.kts, and am seeing it misbehave (likely will be opening another issue in that regard)
Code sample is above
I'm using Gradle 4.10.1, on OSX with the included Gradle Kotlin DSL
Kotlin is static typed.
Means you have to use the class there:
basic(BasicAuthentication::class.java) {
}
(Maybe just BasicAuthentication::class works too).
Maybe I'm wrong with the solution above
Just checked the docu again.
Checkout the AuthenticationContainer.
Seems it should be:
authentication {
create(basic, BasicAuthentication::class.java)
}
The nightly build of the Gradle user manual now has samples demonstrating this with the Kotlin DSL.
See https://docs.gradle.org/nightly/userguide/repository_types.html#sub:authentication_schemes
Here's your sample translated:
repositories {
maven {
url = uri("https://my.mavenrepo.com/artifactory/mvn-main")
authentication {
create<BasicAuthentication>("basic")
}
credentials {
username = mavenUser
password = password
}
}
}
Closing as answered
Most helpful comment
The nightly build of the Gradle user manual now has samples demonstrating this with the Kotlin DSL.
See https://docs.gradle.org/nightly/userguide/repository_types.html#sub:authentication_schemes
Here's your sample translated:
Closing as answered