com.github.zeldigas.confclient.Auth.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of text2confl-confluence-client Show documentation
Show all versions of text2confl-confluence-client Show documentation
Implementation of http client for confluence
The newest version!
package com.github.zeldigas.confclient
import io.ktor.client.plugins.auth.*
import io.ktor.client.plugins.auth.providers.*
interface ConfluenceAuth {
fun create(auth: Auth)
}
data class PasswordAuth(private val username: String, private val password: String) : ConfluenceAuth {
override fun create(auth: Auth) {
val creds = BasicAuthCredentials(username, password)
auth.basic {
credentials { creds }
sendWithoutRequest { true }
}
}
override fun toString(): String {
return "PasswordAuth(username='$username')"
}
}
data class TokenAuth(private val token: String) : ConfluenceAuth {
override fun create(auth: Auth) {
auth.bearer {
loadTokens { BearerTokens(token, "") }
sendWithoutRequest { true }
}
}
}