forked from hashicorp/vault-plugin-database-oracle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreds.go
32 lines (27 loc) · 925 Bytes
/
creds.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package oracle
import (
"strings"
"github.com/hashicorp/vault/sdk/database/dbplugin"
"github.com/hashicorp/vault/sdk/database/helper/credsutil"
)
// oracleCredentialsProducer implements CredentialsProducer.
type oracleCredentialsProducer struct {
credsutil.SQLCredentialsProducer
}
func (ocp *oracleCredentialsProducer) GenerateUsername(config dbplugin.UsernameConfig) (string, error) {
if username, err := ocp.SQLCredentialsProducer.GenerateUsername(config); err != nil {
return "", err
} else {
username = strings.Replace(username, "-", "_", -1)
username = strings.Replace(username, ".", "_", -1)
return strings.ToLower(username), nil
}
}
func (ocp *oracleCredentialsProducer) GeneratePassword() (string, error) {
if password, err := ocp.SQLCredentialsProducer.GeneratePassword(); err != nil {
return "", err
} else {
password = strings.Replace(password, "-", "_", -1)
return password, nil
}
}