All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.zeldigas.confclient.Auth.kt Maven / Gradle / Ivy

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 }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy