fix(lib/challenge): allow challenges to register HTTP routes (#620)

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso 2025-06-05 20:26:23 -04:00 committed by GitHub
parent 5f3861ab37
commit 5a7499ea3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 16 additions and 5 deletions

View file

@ -41,7 +41,12 @@ func Methods() []string {
}
type Impl interface {
Fail(w http.ResponseWriter, r *http.Request) error
// Setup registers any additional routes with the Impl for assets or API routes.
Setup(mux *http.ServeMux)
// Issue a new challenge to the user, called by the Anubis.
Issue(r *http.Request, lg *slog.Logger, rule *policy.Bot, challenge string, ogTags map[string]string) (templ.Component, error)
// Validate a challenge, making sure that it passes muster.
Validate(r *http.Request, lg *slog.Logger, rule *policy.Bot, challenge string) error
}

View file

@ -24,8 +24,8 @@ type Impl struct {
Algorithm string
}
func (i *Impl) Fail(w http.ResponseWriter, r *http.Request) error {
return nil
func (i *Impl) Setup(mux *http.ServeMux) {
/* no implementation required */
}
func (i *Impl) Issue(r *http.Request, lg *slog.Logger, rule *policy.Bot, challenge string, ogTags map[string]string) (templ.Component, error) {