92 lines
2.4 KiB
Go
92 lines
2.4 KiB
Go
package checker
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"strings"
|
|
|
|
sdk "git.happydns.org/checker-sdk-go/checker"
|
|
)
|
|
|
|
// RenderForm exposes the minimal set of fields a human needs to fire a
|
|
// standalone Kerberos probe via GET /check.
|
|
func (p *kerberosProvider) RenderForm() []sdk.CheckerOptionField {
|
|
return []sdk.CheckerOptionField{
|
|
{
|
|
Id: "realm",
|
|
Type: "string",
|
|
Label: "Kerberos realm",
|
|
Placeholder: "EXAMPLE.COM",
|
|
Required: true,
|
|
Description: "DNS domain advertising the realm (the realm name itself is derived in uppercase).",
|
|
},
|
|
{
|
|
Id: "principal",
|
|
Type: "string",
|
|
Label: "Principal (optional)",
|
|
Placeholder: "user@EXAMPLE.COM",
|
|
Description: "Supply to run an authenticated round-trip. Leave blank for anonymous probes only.",
|
|
},
|
|
{
|
|
Id: "password",
|
|
Type: "string",
|
|
Label: "Password (optional)",
|
|
Secret: true,
|
|
},
|
|
{
|
|
Id: "targetService",
|
|
Type: "string",
|
|
Label: "Service to request (TGS)",
|
|
Placeholder: "host/host.example.com",
|
|
},
|
|
{
|
|
Id: "timeout",
|
|
Type: "number",
|
|
Label: "Per-probe timeout (seconds)",
|
|
Default: 5,
|
|
},
|
|
{
|
|
Id: "requireStrongEnctypes",
|
|
Type: "bool",
|
|
Label: "Require strong enctypes",
|
|
Default: true,
|
|
},
|
|
{
|
|
Id: "maxClockSkew",
|
|
Type: "number",
|
|
Label: "Max tolerated clock skew (seconds)",
|
|
Default: 300,
|
|
},
|
|
}
|
|
}
|
|
|
|
// ParseForm turns the submitted form into a CheckerOptions. Collect handles
|
|
// the SRV / DNS discovery itself, so there is nothing to auto-fill here
|
|
// beyond the raw inputs.
|
|
func (p *kerberosProvider) ParseForm(r *http.Request) (sdk.CheckerOptions, error) {
|
|
realm := strings.TrimSpace(r.FormValue("realm"))
|
|
if realm == "" {
|
|
return nil, errors.New("realm is required")
|
|
}
|
|
|
|
opts := sdk.CheckerOptions{"realm": realm}
|
|
|
|
if v := strings.TrimSpace(r.FormValue("principal")); v != "" {
|
|
opts["principal"] = v
|
|
}
|
|
if v := r.FormValue("password"); v != "" {
|
|
opts["password"] = v
|
|
}
|
|
if v := strings.TrimSpace(r.FormValue("targetService")); v != "" {
|
|
opts["targetService"] = v
|
|
}
|
|
if v := strings.TrimSpace(r.FormValue("timeout")); v != "" {
|
|
opts["timeout"] = v
|
|
}
|
|
if v := strings.TrimSpace(r.FormValue("maxClockSkew")); v != "" {
|
|
opts["maxClockSkew"] = v
|
|
}
|
|
opts["requireStrongEnctypes"] = r.FormValue("requireStrongEnctypes") == "true"
|
|
|
|
return opts, nil
|
|
}
|