Give every view a TSIG key that selects it
Each view's match-clients starts with "key jarl-view-NAME" (after
"!key" for the views listed after it), so a query signed with a view's
key lands in that view from any address. The secrets are derived from a
random seed in Jarl's database. The delegation check signs its queries
to this server's own addresses with the key of the zone's view: before,
they got whichever view matched the server's address, usually internal.
jarl view key / GET /views/{id}/key show a key for dig -k (tsig:write,
audited). jarl-view- key names are reserved; the importer drops view
keys from a configuration Jarl wrote.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c696d02513
commit
384f6b3060
26 files changed
+463
-16
No files matched your search
@@ -393,6 +393,10 @@ func (im *importer) key(s *namedconf.Stmt) error {
|
||||
return fmt.Errorf("%s: key without a block", s.Pos)
|
||||
}
|
||||
name := model.NormalizeKeyName(s.Arg(0))
|
||||
if strings.HasPrefix(name, model.ViewKeyPrefix) {
|
||||
// A view key from a configuration Jarl wrote: Jarl makes its own.
|
||||
return nil
|
||||
}
|
||||
alg, secret := "", ""
|
||||
if a := namedconf.FindOne(b.Stmts, "algorithm"); a != nil {
|
||||
alg = strings.ToLower(a.Arg(0))
|
||||
@@ -433,7 +437,7 @@ func (im *importer) view(s *namedconf.Stmt) error {
|
||||
switch kw := st.Keyword(); kw {
|
||||
case "match-clients":
|
||||
if mb := st.FirstBlock(); mb != nil {
|
||||
v.MatchClients = nonNil(elementStrings(mb))
|
||||
v.MatchClients = withoutViewKeys(nonNil(elementStrings(mb)))
|
||||
}
|
||||
case "match-destinations":
|
||||
if mb := st.FirstBlock(); mb != nil {
|
||||
@@ -807,3 +811,23 @@ func allowsNone(o *namedconf.Stmt) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// withoutViewKeys drops the view keys Jarl puts in front of match-clients
|
||||
// (render/viewkeys.go) from a list read from a configuration Jarl wrote,
|
||||
// and the "any" it adds after them to a view that had no list.
|
||||
func withoutViewKeys(elems []string) []string {
|
||||
out := []string{}
|
||||
dropped := false
|
||||
for _, e := range elems {
|
||||
f := strings.Fields(strings.TrimPrefix(strings.TrimSpace(e), "!"))
|
||||
if len(f) == 2 && f[0] == "key" && strings.HasPrefix(strings.Trim(f[1], `"`), model.ViewKeyPrefix) {
|
||||
dropped = true
|
||||
continue
|
||||
}
|
||||
out = append(out, e)
|
||||
}
|
||||
if dropped && len(out) == 1 && out[0] == "any" {
|
||||
return []string{}
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in new issue
Block a user