Skip to content

Commit

Permalink
Use COZY_ADMIN_PASSPHRASE for every commands (#4232)
Browse files Browse the repository at this point in the history
  • Loading branch information
nono authored Nov 27, 2023
2 parents 21c96a3 + 0213d18 commit 0087d98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ passphrase if needed.
if !bytes.Equal(pass1, pass2) {
return fmt.Errorf("Passphrase missmatch")
}
if len(pass1) == 0 {
return fmt.Errorf("Empty password is forbidden")
}

passphrase = pass1
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func newClient(domain string, scopes ...string) *client.Client {
}

func newAdminClient() *client.AdminClient {
pass := []byte(os.Getenv("COZY_ADMIN_PASSWORD"))
pass := []byte(os.Getenv("COZY_ADMIN_PASSPHRASE"))
if len(pass) == 0 {
pass = []byte(os.Getenv("COZY_ADMIN_PASSWORD"))
}
if !build.IsDevRelease() {
if len(pass) == 0 {
var err error
Expand Down
2 changes: 1 addition & 1 deletion debian/uninstall-onboarding.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
export COZY_ADMIN_PASSWORD="$(cat /etc/cozy/.cozy-admin-passphrase)"
export COZY_ADMIN_PASSPHRASE="$(cat /etc/cozy/.cozy-admin-passphrase)"

function app_installed {
DOMAIN="${1}"
Expand Down
4 changes: 2 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ generate this file, you can use the `cozy-stack config passwd [filepath]`
command. This command will ask you for a passphrase and will create the
`cozy-admin-passphrase` at the specified path.

You can use the `COZY_ADMIN_PASSWORD` env variable if you do not want to type
the passphrase each time you call `cozy-stack`.
You can use the `COZY_ADMIN_PASSPHRASE` (or `COZY_ADMIN_PASSWORD`) env variable
if you do not want to type the passphrase each time you call `cozy-stack`.

### Example

Expand Down

0 comments on commit 0087d98

Please sign in to comment.