Optimize register api. Add verify Turnstile captcha to login api.
This commit is contained in:
33
src/main/kotlin/top/fatweb/oxygen/api/http/TurnstileApi.kt
Normal file
33
src/main/kotlin/top/fatweb/oxygen/api/http/TurnstileApi.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
package top.fatweb.oxygen.api.http
|
||||
|
||||
import com.github.lianjiatech.retrofit.spring.boot.core.RetrofitClient
|
||||
import org.springframework.stereotype.Service
|
||||
import retrofit2.http.Field
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.POST
|
||||
import top.fatweb.oxygen.api.http.entity.turnstile.SiteverifyResponse
|
||||
import top.fatweb.oxygen.api.properties.ServerProperties
|
||||
|
||||
/**
|
||||
* Turnstile http request api
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Service
|
||||
@RetrofitClient(baseUrl = "https://challenges.cloudflare.com/turnstile/v0/")
|
||||
interface TurnstileApi {
|
||||
/**
|
||||
* Turnstile post verify captcha code
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
* @see SiteverifyResponse
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("siteverify")
|
||||
fun siteverify(
|
||||
@Field("response") captchaCode: String,
|
||||
@Field("secret") secret: String = ServerProperties.turnstileSecretKey
|
||||
): SiteverifyResponse
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package top.fatweb.oxygen.api.http.entity.turnstile
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import java.time.LocalDateTime
|
||||
|
||||
/**
|
||||
* Turnstile verify captcha code response
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
data class SiteverifyResponse(
|
||||
/**
|
||||
* Is success
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@JsonProperty("success")
|
||||
val success: Boolean,
|
||||
|
||||
/**
|
||||
* Challenge time
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@JsonProperty("challenge_ts")
|
||||
val challengeTs: LocalDateTime?,
|
||||
|
||||
/**
|
||||
* Hostname
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@JsonProperty("hostname")
|
||||
val hostname: String?,
|
||||
|
||||
/**
|
||||
* Error codes list
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@JsonProperty("error-codes")
|
||||
val errorCodes: List<String>?
|
||||
)
|
||||
Reference in New Issue
Block a user