mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
add a dedicated struct to store encrypted credentials
also gcs credentials are now encrypted, both on disk and inside the provider. Data provider is automatically migrated and load data will accept old format too but you should upgrade to the new format to avoid future issues
This commit is contained in:
@@ -876,7 +876,10 @@ func TestLoginWithDatabaseCredentials(t *testing.T) {
|
||||
u := getTestUser()
|
||||
u.FsConfig.Provider = dataprovider.GCSFilesystemProvider
|
||||
u.FsConfig.GCSConfig.Bucket = "test"
|
||||
u.FsConfig.GCSConfig.Credentials = []byte(`{ "type": "service_account" }`)
|
||||
u.FsConfig.GCSConfig.Credentials = vfs.Secret{
|
||||
Status: vfs.SecretStatusPlain,
|
||||
Payload: `{ "type": "service_account" }`,
|
||||
}
|
||||
|
||||
providerConf := config.GetProviderConf()
|
||||
providerConf.PreferDatabaseCredentials = true
|
||||
@@ -897,9 +900,12 @@ func TestLoginWithDatabaseCredentials(t *testing.T) {
|
||||
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, vfs.SecretStatusAES256GCM, user.FsConfig.GCSConfig.Credentials.Status)
|
||||
assert.NotEmpty(t, user.FsConfig.GCSConfig.Credentials.Payload)
|
||||
assert.Empty(t, user.FsConfig.GCSConfig.Credentials.AdditionalData)
|
||||
assert.Empty(t, user.FsConfig.GCSConfig.Credentials.Key)
|
||||
|
||||
_, err = os.Stat(credentialsFile)
|
||||
assert.Error(t, err)
|
||||
assert.NoFileExists(t, credentialsFile)
|
||||
|
||||
client, err := getFTPClient(user, false)
|
||||
if assert.NoError(t, err) {
|
||||
@@ -922,7 +928,10 @@ func TestLoginInvalidFs(t *testing.T) {
|
||||
u := getTestUser()
|
||||
u.FsConfig.Provider = dataprovider.GCSFilesystemProvider
|
||||
u.FsConfig.GCSConfig.Bucket = "test"
|
||||
u.FsConfig.GCSConfig.Credentials = []byte("invalid JSON for credentials")
|
||||
u.FsConfig.GCSConfig.Credentials = vfs.Secret{
|
||||
Status: vfs.SecretStatusPlain,
|
||||
Payload: "invalid JSON for credentials",
|
||||
}
|
||||
user, _, err := httpd.AddUser(u, http.StatusOK)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user