Skip to content

Commit

Permalink
caddyhttp: parse UID field from client certificates
Browse files Browse the repository at this point in the history
This requires a patch to the Go standard library.
  • Loading branch information
vikanezrimaya committed Oct 16, 2024
1 parent c6f2979 commit e7987ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/caddyhttp/replacer.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ func getReqTLSReplacement(req *http.Request, key string) (any, bool) {
}

field := strings.ToLower(key[len(reqTLSReplPrefix):])

if strings.HasPrefix(field, "client.") {
cert := getTLSPeerCert(req.TLS)
if cert == nil {
Expand All @@ -409,6 +408,10 @@ func getReqTLSReplacement(req *http.Request, key string) (any, bool) {
case strings.HasPrefix(field, "uris"):
fieldName = "uris"
fieldValue = cert.URIs
// Maybe there's a better place for this
case strings.HasPrefix(field, "uids"):
fieldName = "uids"
fieldValue = cert.Subject.Uid
default:
return nil, false
}
Expand Down

0 comments on commit e7987ce

Please sign in to comment.