fix: encrypt mongodb password
This commit is contained in:
parent
72421d692b
commit
6e73f7f2e4
1 changed files with 16 additions and 1 deletions
|
|
@ -42,6 +42,20 @@ protected static function booted()
|
|||
});
|
||||
}
|
||||
|
||||
public function mongoInitdbRootPassword(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function ($value) {
|
||||
try {
|
||||
return decrypt($value);
|
||||
} catch (\Throwable $th) {
|
||||
$this->mongo_initdb_root_password = encrypt($value);
|
||||
$this->save();
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
public function portsMappings(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
|
|
@ -63,7 +77,8 @@ public function type(): string
|
|||
{
|
||||
return 'standalone-mongodb';
|
||||
}
|
||||
public function getDbUrl(bool $useInternal = false) {
|
||||
public function getDbUrl(bool $useInternal = false)
|
||||
{
|
||||
if ($this->is_public && !$useInternal) {
|
||||
return "mongodb://{$this->mongo_initdb_root_username}:{$this->mongo_initdb_root_password}@{$this->destination->server->getIp}:{$this->public_port}/?directConnection=true";
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue