Documentation
¶
Overview ¶
Package password is the password behavior: the password of a user, under the user. It sets the password on the Debian family. The controller hashes the password, so the job data and NATS have only its hash.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Behavior = behavior.Register(behavior.Define( "password", "The password of a user", behavior.Title("User password"), behavior.Node, behavior.API, behavior.Area(area.Security), behavior.CLI, behavior.Of(user.Behavior), behavior.Requires(user.Behavior), behavior.Platform(behavior.PlatformDebian, newDebian), behavior.Write("update", Update). ReadsNothing("no read shows a password or its hash: the host keeps them, and osapi never reads them back"). AdminOnly(). Sudo("chpasswd"). Always(). Before(hashPassword). Describe("Set the password of a user"). Explain("Sets the password with chpasswd -e, from its hash on standard input. "+ "The controller hashes the password, so the job and NATS have only the "+ "hash. Each call makes a new hash, so it always reports changed: true. A "+ "user that the host does not have is not found. It runs on the Debian "+ "family only, and elsewhere reports skipped."). Example("Set a password", UpdateInput{ Name: "osapitest", Password: "osapi-test-password", PasswordHash: testHash, }, Result{Name: "osapitest", Changed: true}, withHost(newUser, behavior.After(user.CreateInput{Name: "osapitest"}), behavior.Ran("chpasswd", "-e"), )..., ). Fails("No password", UpdateInput{Name: "alice"}, "give the password", withHost()...). Fails("A user that the host does not have", UpdateInput{Name: "nobody", PasswordHash: testHash}, "not found", withHost()...). Fails("A hash that is not a crypt hash", UpdateInput{Name: "alice", PasswordHash: "plain"}, "crypt hash", withHost()...). Fails("A name that is an option", UpdateInput{Name: "-r"}, "account_name"). Fails("A name longer than 32 characters", UpdateInput{Name: strings.Repeat("a", 33)}, "max"). Fails("A password with a line break", UpdateInput{Name: "alice", Password: "a\nb"}, "no_linebreak"), ))
Behavior is the password of a user, under the user: /api/node/{hostname}/user/{name}/password. Its permission is the user's user:write, which only the admin role gets, because an account gets to root.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider interface {
// Set sets the password of the user from its sha512-crypt hash.
Set(ctx context.Context, name string, hash string) error
}
Provider sets the password of a user. debian.go sets it on the Debian family; on each other platform the method reports skipped.
type Result ¶
type Result struct {
Name string `json:"name" doc:"The user"`
Changed bool `json:"changed" doc:"Whether the host changed"`
}
Result is what update reports for the user.
type UpdateInput ¶
type UpdateInput struct {
Name string `json:"name" validate:"required,max=32,account_name" doc:"The user, such as alice"`
Password secret.Value `` /* 131-byte string literal not displayed */
PasswordHash string `` /* 154-byte string literal not displayed */
}
UpdateInput sets the password of a user. The caller sends password; the controller's step hashes it into password_hash.