Skip to content

Commit f006ad9

Browse files
committed
Relax configuration requirement for password
We now no longer require the password configuration property to be able to create a connection. The password requirements depend on authentication method (client-side) and trust settings (server-side). The requirement cannot be determined on the client side only, but rather the requirement is a function of how the server is configured (i.e. implicit trust, 2FA with Postgres 12). [resolves #178]
1 parent 60b1138 commit f006ad9

File tree

4 files changed

+12
-79
lines changed

4 files changed

+12
-79
lines changed

src/main/java/io/r2dbc/postgresql/PostgresqlConnectionConfiguration.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ private PostgresqlConnectionConfiguration(String applicationName, boolean autode
8787
this.forceBinary = forceBinary;
8888
this.host = Assert.requireNonNull(host, "host must not be null");
8989
this.options = options;
90-
this.password = sslConfig.getSslMode() != SSLMode.DISABLE
91-
? password
92-
: Assert.requireNonNull(password, "password must not be null");
90+
this.password = password;
9391
this.port = port;
9492
this.schema = schema;
9593
this.username = Assert.requireNonNull(username, "username must not be null");

src/main/java/io/r2dbc/postgresql/api/PostgresqlStatement.java

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -44,70 +44,6 @@ public interface PostgresqlStatement extends Statement {
4444
@Override
4545
PostgresqlStatement bind(int index, Object value);
4646

47-
/**
48-
* {@inheritDoc}
49-
*/
50-
@Override
51-
default PostgresqlStatement bind(int index, boolean value) {
52-
return bind(index, (Object) value);
53-
}
54-
55-
/**
56-
* {@inheritDoc}
57-
*/
58-
@Override
59-
default PostgresqlStatement bind(int index, byte value) {
60-
return bind(index, (Object) value);
61-
}
62-
63-
/**
64-
* {@inheritDoc}
65-
*/
66-
@Override
67-
default PostgresqlStatement bind(int index, char value) {
68-
return bind(index, (Object) value);
69-
}
70-
71-
/**
72-
* {@inheritDoc}
73-
*/
74-
@Override
75-
default PostgresqlStatement bind(int index, double value) {
76-
return bind(index, (Object) value);
77-
}
78-
79-
/**
80-
* {@inheritDoc}
81-
*/
82-
@Override
83-
default PostgresqlStatement bind(int index, float value) {
84-
return bind(index, (Object) value);
85-
}
86-
87-
/**
88-
* {@inheritDoc}
89-
*/
90-
@Override
91-
default PostgresqlStatement bind(int index, int value) {
92-
return bind(index, (Object) value);
93-
}
94-
95-
/**
96-
* {@inheritDoc}
97-
*/
98-
@Override
99-
default PostgresqlStatement bind(int index, long value) {
100-
return bind(index, (Object) value);
101-
}
102-
103-
/**
104-
* {@inheritDoc}
105-
*/
106-
@Override
107-
default PostgresqlStatement bind(int index, short value) {
108-
return bind(index, (Object) value);
109-
}
110-
11147
/**
11248
* {@inheritDoc}
11349
*

src/test/java/io/r2dbc/postgresql/PostgresqlConnectionConfigurationTest.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ void configuration() {
5858
.database("test-database")
5959
.host("test-host")
6060
.options(options)
61-
.password("test-password")
6261
.port(100)
6362
.schema("test-schema")
6463
.username("test-username")
@@ -71,7 +70,7 @@ void configuration() {
7170
.hasFieldOrPropertyWithValue("database", "test-database")
7271
.hasFieldOrPropertyWithValue("host", "test-host")
7372
.hasFieldOrPropertyWithValue("options", options)
74-
.hasFieldOrPropertyWithValue("password", "test-password")
73+
.hasFieldOrPropertyWithValue("password", null)
7574
.hasFieldOrPropertyWithValue("port", 100)
7675
.hasFieldOrPropertyWithValue("schema", "test-schema")
7776
.hasFieldOrPropertyWithValue("username", "test-username")
@@ -108,15 +107,6 @@ void constructorNoNoHost() {
108107
.withMessage("host must not be null");
109108
}
110109

111-
@Test
112-
void constructorNoPassword() {
113-
assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder()
114-
.host("test-host")
115-
.username("test-username")
116-
.build())
117-
.withMessage("password must not be null");
118-
}
119-
120110
@Test
121111
void constructorNoUsername() {
122112
assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder()

src/test/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProviderTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,16 @@ void supportsSsl() {
137137
}
138138

139139
@Test
140-
void providerShouldparseAndHandleConnectionParameters() {
140+
void shouldCreateConnectionFactoryWithoutPassword() {
141+
assertThat(this.provider.create(ConnectionFactoryOptions.builder()
142+
.option(DRIVER, POSTGRESQL_DRIVER)
143+
.option(HOST, "test-host")
144+
.option(USER, "test-user")
145+
.build())).isNotNull();
146+
}
147+
148+
@Test
149+
void providerShouldParseAndHandleConnectionParameters() {
141150
Map<String, String> expectedOptions = new HashMap<>();
142151
expectedOptions.put("lock_timeout", "5s");
143152
expectedOptions.put("statement_timeout", "6000");

0 commit comments

Comments
 (0)