feat(api): add captcha fields and admin authentication endpoints
- Add CaptchaId and CaptchaCode fields to login/register/reset requests - Add /v1/auth/captcha/generate endpoint for user captcha generation - Add /v1/auth/admin/login endpoint for admin authentication - Add /v1/auth/admin/reset-password endpoint for admin password reset - Add /v1/auth/admin/captcha/generate endpoint for admin captcha generation - Update GlobalConfigResponse with new verify configuration fields - Add GenerateCaptchaResponse type for captcha generation
This commit is contained in:
parent
0f6fddc36d
commit
eb327b26b9
@ -11,13 +11,15 @@ info (
|
|||||||
type (
|
type (
|
||||||
// User login request
|
// User login request
|
||||||
UserLoginRequest {
|
UserLoginRequest {
|
||||||
Identifier string `json:"identifier"`
|
Identifier string `json:"identifier"`
|
||||||
Email string `json:"email" validate:"required"`
|
Email string `json:"email" validate:"required"`
|
||||||
Password string `json:"password" validate:"required"`
|
Password string `json:"password" validate:"required"`
|
||||||
IP string `header:"X-Original-Forwarded-For"`
|
IP string `header:"X-Original-Forwarded-For"`
|
||||||
UserAgent string `header:"User-Agent"`
|
UserAgent string `header:"User-Agent"`
|
||||||
LoginType string `header:"Login-Type"`
|
LoginType string `header:"Login-Type"`
|
||||||
CfToken string `json:"cf_token,optional"`
|
CfToken string `json:"cf_token,optional"`
|
||||||
|
CaptchaId string `json:"captcha_id,optional"`
|
||||||
|
CaptchaCode string `json:"captcha_code,optional"`
|
||||||
}
|
}
|
||||||
// Check user is exist request
|
// Check user is exist request
|
||||||
CheckUserRequest {
|
CheckUserRequest {
|
||||||
@ -29,26 +31,30 @@ type (
|
|||||||
}
|
}
|
||||||
// User login response
|
// User login response
|
||||||
UserRegisterRequest {
|
UserRegisterRequest {
|
||||||
Identifier string `json:"identifier"`
|
Identifier string `json:"identifier"`
|
||||||
Email string `json:"email" validate:"required"`
|
Email string `json:"email" validate:"required"`
|
||||||
Password string `json:"password" validate:"required"`
|
Password string `json:"password" validate:"required"`
|
||||||
Invite string `json:"invite,optional"`
|
Invite string `json:"invite,optional"`
|
||||||
Code string `json:"code,optional"`
|
Code string `json:"code,optional"`
|
||||||
IP string `header:"X-Original-Forwarded-For"`
|
IP string `header:"X-Original-Forwarded-For"`
|
||||||
UserAgent string `header:"User-Agent"`
|
UserAgent string `header:"User-Agent"`
|
||||||
LoginType string `header:"Login-Type"`
|
LoginType string `header:"Login-Type"`
|
||||||
CfToken string `json:"cf_token,optional"`
|
CfToken string `json:"cf_token,optional"`
|
||||||
|
CaptchaId string `json:"captcha_id,optional"`
|
||||||
|
CaptchaCode string `json:"captcha_code,optional"`
|
||||||
}
|
}
|
||||||
// User login response
|
// User reset password request
|
||||||
ResetPasswordRequest {
|
ResetPasswordRequest {
|
||||||
Identifier string `json:"identifier"`
|
Identifier string `json:"identifier"`
|
||||||
Email string `json:"email" validate:"required"`
|
Email string `json:"email" validate:"required"`
|
||||||
Password string `json:"password" validate:"required"`
|
Password string `json:"password" validate:"required"`
|
||||||
Code string `json:"code,optional"`
|
Code string `json:"code,optional"`
|
||||||
IP string `header:"X-Original-Forwarded-For"`
|
IP string `header:"X-Original-Forwarded-For"`
|
||||||
UserAgent string `header:"User-Agent"`
|
UserAgent string `header:"User-Agent"`
|
||||||
LoginType string `header:"Login-Type"`
|
LoginType string `header:"Login-Type"`
|
||||||
CfToken string `json:"cf_token,optional"`
|
CfToken string `json:"cf_token,optional"`
|
||||||
|
CaptchaId string `json:"captcha_id,optional"`
|
||||||
|
CaptchaCode string `json:"captcha_code,optional"`
|
||||||
}
|
}
|
||||||
LoginResponse {
|
LoginResponse {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
@ -75,6 +81,8 @@ type (
|
|||||||
UserAgent string `header:"User-Agent"`
|
UserAgent string `header:"User-Agent"`
|
||||||
LoginType string `header:"Login-Type"`
|
LoginType string `header:"Login-Type"`
|
||||||
CfToken string `json:"cf_token,optional"`
|
CfToken string `json:"cf_token,optional"`
|
||||||
|
CaptchaId string `json:"captcha_id,optional"`
|
||||||
|
CaptchaCode string `json:"captcha_code,optional"`
|
||||||
}
|
}
|
||||||
// Check user is exist request
|
// Check user is exist request
|
||||||
TelephoneCheckUserRequest {
|
TelephoneCheckUserRequest {
|
||||||
@ -97,6 +105,8 @@ type (
|
|||||||
UserAgent string `header:"User-Agent"`
|
UserAgent string `header:"User-Agent"`
|
||||||
LoginType string `header:"Login-Type,optional"`
|
LoginType string `header:"Login-Type,optional"`
|
||||||
CfToken string `json:"cf_token,optional"`
|
CfToken string `json:"cf_token,optional"`
|
||||||
|
CaptchaId string `json:"captcha_id,optional"`
|
||||||
|
CaptchaCode string `json:"captcha_code,optional"`
|
||||||
}
|
}
|
||||||
// User login response
|
// User login response
|
||||||
TelephoneResetPasswordRequest {
|
TelephoneResetPasswordRequest {
|
||||||
@ -109,6 +119,8 @@ type (
|
|||||||
UserAgent string `header:"User-Agent"`
|
UserAgent string `header:"User-Agent"`
|
||||||
LoginType string `header:"Login-Type,optional"`
|
LoginType string `header:"Login-Type,optional"`
|
||||||
CfToken string `json:"cf_token,optional"`
|
CfToken string `json:"cf_token,optional"`
|
||||||
|
CaptchaId string `json:"captcha_id,optional"`
|
||||||
|
CaptchaCode string `json:"captcha_code,optional"`
|
||||||
}
|
}
|
||||||
AppleLoginCallbackRequest {
|
AppleLoginCallbackRequest {
|
||||||
Code string `form:"code"`
|
Code string `form:"code"`
|
||||||
@ -126,6 +138,11 @@ type (
|
|||||||
CfToken string `json:"cf_token,optional"`
|
CfToken string `json:"cf_token,optional"`
|
||||||
ShortCode string `json:"short_code,optional"`
|
ShortCode string `json:"short_code,optional"`
|
||||||
}
|
}
|
||||||
|
GenerateCaptchaResponse {
|
||||||
|
Id string `json:"id"`
|
||||||
|
Image string `json:"image"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@server (
|
@server (
|
||||||
@ -166,11 +183,34 @@ service ppanel {
|
|||||||
@handler TelephoneResetPassword
|
@handler TelephoneResetPassword
|
||||||
post /reset/telephone (TelephoneResetPasswordRequest) returns (LoginResponse)
|
post /reset/telephone (TelephoneResetPasswordRequest) returns (LoginResponse)
|
||||||
|
|
||||||
|
@doc "Generate captcha"
|
||||||
|
@handler GenerateCaptcha
|
||||||
|
post /captcha/generate returns (GenerateCaptchaResponse)
|
||||||
|
|
||||||
@doc "Device Login"
|
@doc "Device Login"
|
||||||
@handler DeviceLogin
|
@handler DeviceLogin
|
||||||
post /login/device (DeviceLoginRequest) returns (LoginResponse)
|
post /login/device (DeviceLoginRequest) returns (LoginResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@server (
|
||||||
|
prefix: v1/auth/admin
|
||||||
|
group: auth/admin
|
||||||
|
middleware: DeviceMiddleware
|
||||||
|
)
|
||||||
|
service ppanel {
|
||||||
|
@doc "Admin login"
|
||||||
|
@handler AdminLogin
|
||||||
|
post /login (UserLoginRequest) returns (LoginResponse)
|
||||||
|
|
||||||
|
@doc "Admin reset password"
|
||||||
|
@handler AdminResetPassword
|
||||||
|
post /reset (ResetPasswordRequest) returns (LoginResponse)
|
||||||
|
|
||||||
|
@doc "Generate captcha"
|
||||||
|
@handler AdminGenerateCaptcha
|
||||||
|
post /captcha/generate returns (GenerateCaptchaResponse)
|
||||||
|
}
|
||||||
|
|
||||||
@server (
|
@server (
|
||||||
prefix: v1/auth/oauth
|
prefix: v1/auth/oauth
|
||||||
group: auth/oauth
|
group: auth/oauth
|
||||||
|
|||||||
@ -12,10 +12,12 @@ import "./types.api"
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
VeifyConfig {
|
VeifyConfig {
|
||||||
TurnstileSiteKey string `json:"turnstile_site_key"`
|
CaptchaType string `json:"captcha_type"`
|
||||||
EnableLoginVerify bool `json:"enable_login_verify"`
|
TurnstileSiteKey string `json:"turnstile_site_key"`
|
||||||
EnableRegisterVerify bool `json:"enable_register_verify"`
|
EnableUserLoginCaptcha bool `json:"enable_user_login_captcha"`
|
||||||
EnableResetPasswordVerify bool `json:"enable_reset_password_verify"`
|
EnableUserRegisterCaptcha bool `json:"enable_user_register_captcha"`
|
||||||
|
EnableAdminLoginCaptcha bool `json:"enable_admin_login_captcha"`
|
||||||
|
EnableUserResetPasswordCaptcha bool `json:"enable_user_reset_password_captcha"`
|
||||||
}
|
}
|
||||||
GetGlobalConfigResponse {
|
GetGlobalConfigResponse {
|
||||||
Site SiteConfig `json:"site"`
|
Site SiteConfig `json:"site"`
|
||||||
|
|||||||
@ -154,11 +154,13 @@ type (
|
|||||||
DeviceLimit int64 `json:"device_limit"`
|
DeviceLimit int64 `json:"device_limit"`
|
||||||
}
|
}
|
||||||
VerifyConfig {
|
VerifyConfig {
|
||||||
TurnstileSiteKey string `json:"turnstile_site_key"`
|
CaptchaType string `json:"captcha_type"` // local or turnstile
|
||||||
TurnstileSecret string `json:"turnstile_secret"`
|
TurnstileSiteKey string `json:"turnstile_site_key"`
|
||||||
EnableLoginVerify bool `json:"enable_login_verify"`
|
TurnstileSecret string `json:"turnstile_secret"`
|
||||||
EnableRegisterVerify bool `json:"enable_register_verify"`
|
EnableUserLoginCaptcha bool `json:"enable_user_login_captcha"` // User login captcha
|
||||||
EnableResetPasswordVerify bool `json:"enable_reset_password_verify"`
|
EnableUserRegisterCaptcha bool `json:"enable_user_register_captcha"` // User register captcha
|
||||||
|
EnableAdminLoginCaptcha bool `json:"enable_admin_login_captcha"` // Admin login captcha
|
||||||
|
EnableUserResetPasswordCaptcha bool `json:"enable_user_reset_password_captcha"` // User reset password captcha
|
||||||
}
|
}
|
||||||
NodeConfig {
|
NodeConfig {
|
||||||
NodeSecret string `json:"node_secret"`
|
NodeSecret string `json:"node_secret"`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user