Skip to content

Commit 5babb8f

Browse files
committed
hide password in debug mode
1 parent b1145cf commit 5babb8f

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address'
10881088

10891089
#### Features
10901090

1091+
* `scw -D login` displays a fake password
10911092
* Syncing cache to disk after server creation when running `scw run` in a non-detached mode
10921093
* Bump to Golang 1.5
10931094
* Support --tmp-ssh-key `scw {run,create}` option ([#99](https://github.com/scaleway/scaleway-cli/issues/99))

pkg/api/api.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ type ScalewayAPI struct {
4747
// Token is the authentication token for the Scaleway organization
4848
Token string
4949

50+
// Password is the authentication password
51+
password string
52+
5053
// Cache is used to quickly resolve identifiers from names
5154
Cache *ScalewayCache
5255

@@ -595,6 +598,7 @@ func NewScalewayAPI(apiEndPoint, accountEndPoint, organization, token string) (*
595598
Organization: organization,
596599
Token: token,
597600
Cache: cache,
601+
password: "",
598602

599603
// internal
600604
anonuuid: *anonuuid.New(),
@@ -1459,6 +1463,9 @@ func (s *ScalewayAPI) HideAPICredentials(input string) string {
14591463
if s.Organization != "" {
14601464
output = strings.Replace(output, s.Organization, s.anonuuid.FakeUUID(s.Organization), -1)
14611465
}
1466+
if s.password != "" {
1467+
output = strings.Replace(output, s.password, "XX-XX-XX-XX", -1)
1468+
}
14621469
return output
14631470
}
14641471

@@ -1471,3 +1478,8 @@ func (s *ScalewayAPI) EnableAccountAPI() {
14711478
func (s *ScalewayAPI) DisableAccountAPI() {
14721479
s.APIUrl = s.ComputeAPI
14731480
}
1481+
1482+
// SetPassword register the password
1483+
func (s *ScalewayAPI) SetPassword(password string) {
1484+
s.password = password
1485+
}

pkg/commands/login.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func getToken(connect api.ScalewayConnect) (string, error) {
8585
return "", fmt.Errorf("Unable to create a fake ScalewayAPI: %s", err)
8686
}
8787
FakeConnection.EnableAccountAPI()
88+
FakeConnection.SetPassword(connect.Password)
8889

8990
resp, err := FakeConnection.PostResponse("tokens", connect)
9091
if err != nil {

0 commit comments

Comments
 (0)