Let an own secret's manifest declare a desk prompt (issue 789)
A family like mesh-mail's mail-credential-* names only the module and the secret's key at the desk, so the operator cannot tell which account is asked. An own secret (or a family) may now declare a one-line prompt in its manifest, with {member} filled by a family member's suffix; the module check refuses one that is not one line, over 120 characters, or holds another placeholder. desk_secret.go reads it from the controller's own catalogue and sends it to the desk as what, never from the call or the module's runtime; omitted when none is declared, so an old desk or module behaves as today.
This commit is contained in:
@@ -595,6 +595,26 @@ func (i *Inventory) DeclaresOwnSecret(ctx context.Context, module, name string)
|
||||
return GivableAtDesk(m, name)
|
||||
}
|
||||
|
||||
// OwnSecretPrompt is the one line the desk asks for this secret as — the module's declared `prompt`, read from
|
||||
// the controller's own catalogue, never from the call or the module's runtime (novox/hq issue 789). For a family
|
||||
// member it is the family's prompt with `{member}` replaced by the member's suffix. Empty when the module or the
|
||||
// secret is unknown, or declares no prompt — the desk then asks by name alone, as it does today.
|
||||
func (i *Inventory) OwnSecretPrompt(ctx context.Context, module, name string) (string, error) {
|
||||
m, err := i.declared(ctx, module)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
own, family, ok := m.OwnSecrets.Lookup(name)
|
||||
if !ok || own.Prompt == "" {
|
||||
return "", nil
|
||||
}
|
||||
if family == "" {
|
||||
return own.Prompt, nil
|
||||
}
|
||||
member := strings.TrimPrefix(name, catalogue.FamilyPrefix(family))
|
||||
return strings.ReplaceAll(own.Prompt, "{member}", member), nil
|
||||
}
|
||||
|
||||
// RunsAsItsOwnAccount says a module runs as an account of its own (novox/hq ADR 0259 §8): a trusted party — the
|
||||
// router, a channel that proves its sender or shows a link's code — whose own secret is what the operator's
|
||||
// answers are believed by. Its value is given at the controller's terminal alone.
|
||||
|
||||
Reference in New Issue
Block a user