mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 06:16:37 +08:00
9f8890d159
- Declared module Wavelet in backend/go.mod - Replaced github.com/Rain-kl/Wavelet/ with clean Wavelet/ import paths across backend codebase - Updated architecture guards, Makefile, swagger, and build tests - 100% passed all tests, lint checks, and binary compilation
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Package cap provides the proof-of-work (PoW) CAPTCHA verification domain plugin for Cordis.
|
|
package cap
|
|
|
|
import (
|
|
"Wavelet/core"
|
|
"Wavelet/core/extpoints"
|
|
)
|
|
|
|
// Plugin implements core.Plugin to provide CAPTCHA generation, validation, and route protection.
|
|
type Plugin struct{}
|
|
|
|
// New creates a new cap domain plugin.
|
|
func New() *Plugin {
|
|
return &Plugin{}
|
|
}
|
|
|
|
// Name returns the unique identifier for the cap domain plugin.
|
|
func (p *Plugin) Name() string {
|
|
return "cap"
|
|
}
|
|
|
|
// Manifest returns the plugin metadata.
|
|
func (p *Plugin) Manifest() core.Manifest {
|
|
return core.Manifest{
|
|
Name: "cap",
|
|
Version: "1.0.0",
|
|
Description: "Proof-of-work CAPTCHA challenge and verification domain plugin",
|
|
Author: "Wavelet Team",
|
|
}
|
|
}
|
|
|
|
// Apply registers the cap routes and settings into the Context.
|
|
func (p *Plugin) Apply(ctx *core.Context) error {
|
|
// Register HTTP Routes
|
|
capGroup := ctx.Router().Group("/api/v1/cap")
|
|
{
|
|
capGroup.GET("/challenge", Challenge)
|
|
capGroup.POST("/challenge", Challenge)
|
|
capGroup.POST("/redeem", Redeem)
|
|
}
|
|
|
|
// Register Settings Schemas
|
|
ctx.Settings().Register(extpoints.SettingSchema{
|
|
Key: "cap.login_enabled",
|
|
Default: false,
|
|
Description: "Whether to require CAPTCHA verification for user login",
|
|
Type: "boolean",
|
|
Category: "security",
|
|
})
|
|
ctx.Settings().Register(extpoints.SettingSchema{
|
|
Key: "cap.challenge_count",
|
|
Default: 1,
|
|
Description: "Number of PoW puzzle challenges to solve",
|
|
Type: "integer",
|
|
Category: "security",
|
|
})
|
|
|
|
return nil
|
|
}
|