mirror of
https://github.com/kopia/kopia.git
synced 2026-01-03 20:17:53 -05:00
* user: added user profile (username&password for authentication) and CRUD methods * manifest: helpers for disambiguating manifest entries * authn: added repository-based user authenticator * cli: added commands to manipulate user accounts and passwords * cli: added --allow-repository-users option to 'server start' * Update cli/command_user_info.go Co-authored-by: Julio López <julio+gh@kasten.io> * Always return false when the user is not found.
37 lines
779 B
Go
37 lines
779 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/internal/user"
|
|
"github.com/kopia/kopia/repo"
|
|
)
|
|
|
|
var (
|
|
userInfoCommand = userCommands.Command("info", "Info about particular user")
|
|
userInfoName = userInfoCommand.Arg("username", "The username to look up.").Required().String()
|
|
)
|
|
|
|
func runUserInfo(ctx context.Context, rep repo.DirectRepository) error {
|
|
up, err := user.GetUserProfile(ctx, rep, *userInfoName)
|
|
if err != nil {
|
|
return errors.Wrap(err, "error getting user profile")
|
|
}
|
|
|
|
j, err := json.MarshalIndent(up, "", " ")
|
|
if err != nil {
|
|
return errors.Wrap(err, "error marshaling JSON")
|
|
}
|
|
|
|
printStdout("%s", j)
|
|
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
userInfoCommand.Action(directRepositoryReadAction(runUserInfo))
|
|
}
|