File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ public function init(): void
2626 $ settings ->host () . ': ' . $ settings ->port (),
2727 ],
2828 );
29+
30+ if ($ settings ->username () !== null && $ settings ->password () !== null ) {
31+ $ this ->clientBuilder ->setBasicAuthentication (
32+ $ settings ->username (),
33+ $ settings ->password (),
34+ );
35+ }
2936 }
3037
3138
Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ public function setConfigOptions(
5757 $ neonSettingsProvider = $ services ['services ' ]['neonSettingsProvider ' ]['factory ' ];
5858 $ neonSettingsProvider ->arguments [0 ] = $ config ['host ' ];
5959 $ neonSettingsProvider ->arguments [1 ] = $ config ['port ' ];
60+ $ neonSettingsProvider ->arguments [2 ] = $ config ['username ' ] ?? null ;
61+ $ neonSettingsProvider ->arguments [3 ] = $ config ['password ' ] ?? null ;
6062
6163 $ versionProvider = $ services ['services ' ]['versionProvider ' ]['factory ' ];
6264 $ versionProvider ->arguments [0 ] = $ config ['version ' ];
Original file line number Diff line number Diff line change 1111 public function __construct (
1212 private string $ host ,
1313 private int $ port ,
14+ private string |null $ username ,
15+ private string |null $ password ,
1416 private array $ headers ,
1517 )
1618 {
@@ -29,6 +31,18 @@ public function port(): int
2931 }
3032
3133
34+ public function username (): string |null
35+ {
36+ return $ this ->username ;
37+ }
38+
39+
40+ public function password (): string |null
41+ {
42+ return $ this ->password ;
43+ }
44+
45+
3246 /**
3347 * @return array<mixed>
3448 */
Original file line number Diff line number Diff line change 1111 public function __construct (
1212 private string $ host ,
1313 private int $ port ,
14+ private string |null $ username ,
15+ private string |null $ password ,
1416 private array $ headers = [],
1517 )
1618 {
@@ -22,6 +24,8 @@ public function provide(): \Spameri\Elastic\Settings
2224 return new \Spameri \Elastic \Settings (
2325 $ this ->host ,
2426 $ this ->port ,
27+ $ this ->username ,
28+ $ this ->password ,
2529 $ this ->headers ,
2630 );
2731 }
You can’t perform that action at this time.
0 commit comments