Skip to content

Commit

Permalink
httpcaddyfile: Support client auth verifiers (#6022)
Browse files Browse the repository at this point in the history
* Added verifier case

Update author

* Update verifier to match struct tag

* gci run
  • Loading branch information
zachgalvin committed Jan 9, 2024
1 parent ed41c92 commit cb86319
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions caddyconfig/httpcaddyfile/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,24 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
for nesting := h.Nesting(); h.NextBlock(nesting); {
subdir := h.Val()
switch subdir {
case "verifier":
if !h.NextArg() {
return nil, h.ArgErr()
}

vType := h.Val()
modID := "tls.client_auth." + vType
unm, err := caddyfile.UnmarshalModule(h.Dispenser, modID)
if err != nil {
return nil, err
}

_, ok := unm.(caddytls.ClientCertificateVerifier)
if !ok {
return nil, h.Dispenser.Errf("module %s is not a caddytls.ClientCertificatVerifier", modID)
}

cp.ClientAuthentication.VerifiersRaw = append(cp.ClientAuthentication.VerifiersRaw, caddyconfig.JSONModuleObject(unm, "verifier", vType, h.warnings))
case "mode":
if !h.Args(&cp.ClientAuthentication.Mode) {
return nil, h.ArgErr()
Expand Down

0 comments on commit cb86319

Please sign in to comment.