sojorn/go-backend/internal/handlers/altcha_handler.go
Patrick Britton a3fcfe67ab feat: replace Turnstile with ALTCHA for all authentication
- Add ALTCHA service with challenge generation and verification
- Update auth and admin handlers to use ALTCHA tokens
- Replace Turnstile widget with ALTCHA widget in Flutter app
- Update admin frontend to use ALTCHA token
- Add ALTCHA challenge endpoints for both auth and admin
- Maintain development bypass for testing
- Remove Turnstile dependencies from authentication flow
2026-02-16 22:18:29 -06:00

33 lines
833 B
Go

package handlers
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/patbritton/sojorn-backend/internal/services"
)
func (h *AdminHandler) GetAltchaChallenge(c *gin.Context) {
altchaService := services.NewAltchaService(h.jwtSecret) // Use JWT secret as ALTCHA secret for now
challenge, err := altchaService.GenerateChallenge()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to generate challenge"})
return
}
c.JSON(http.StatusOK, challenge)
}
func (h *AuthHandler) GetAltchaChallenge(c *gin.Context) {
altchaService := services.NewAltchaService(h.config.JWTSecret)
challenge, err := altchaService.GenerateChallenge()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to generate challenge"})
return
}
c.JSON(http.StatusOK, challenge)
}