Skip to content

Commit 7368a9a

Browse files
authored
Add service port configuration parameter (#59)
* Supports -1 flag for default protocol port * Update README
1 parent b9ae8e2 commit 7368a9a

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

README.md

+48-11
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ are therefore not mandatory to set
8686

8787
| environment variable | description |
8888
|----------------------|----------------------|
89-
| `PORT` | The application port |
89+
| `DM_PORT` | The application port |
9090
| `USER_DB_DRIVER` | The database driver |
9191

9292
```properties
93-
server.port=${PORT:8080}
93+
server.port=${DM_PORT:8080}
9494
spring.datasource.driver-class-name=${USER_DB_DRIVER:com.mysql.cj.jdbc.Driver}
9595
```
9696

@@ -100,7 +100,8 @@ As the application needs to send emails, you have to configure an smtp server as
100100
|----------------------|------------------------------------------------------|
101101
| `MAIL_HOST` | The smtp server host (e.g. smtp.gmail.com) |
102102
| `MAIL_PASSWORD` | The password to authenticate against the mail server |
103-
| `Mail_USERNAME` | The username to authenticate against the mail server |
103+
| `MAIL_USERNAME` | The username to authenticate against the mail server |
104+
| `MAIL_PORT` | The port to use for the SMTP connection |
104105

105106
```properties
106107
spring.mail.username=${MAIL_USERNAME}
@@ -114,18 +115,31 @@ the following properties:
114115

115116
| environment variable | description |
116117
|--------------------------------|-------------------------------------------------------------------|
117-
| `HOST` | The server address |
118+
| `DM_SERVICE_HOST` | The server address (if behind a proxy, the proxy domain name) |
119+
| `DM_HOST_PROTOCOL` | The server protocol (http or https) |
120+
| `DM_SERVICE_PORT` | The server port (-1 for default) |
118121
| `EMAIL_CONFIRMATION_PARAMETER` | The name of the parameter to which to pass the confirmation token |
119-
| `LOGIN_ENDPOINT` | The endpoint for the login |
122+
| `EMAIL_CONFIRMATION_ENDPOINT` | The endpoint for the email configuration entry |
123+
| `PASSWORD_RESET_ENDPOINT` | The endpoint for the password reset entry |
124+
| `PASSWORD_RESET_PARAMETER` | The name for the password reset query parameter in the URL |
120125

121126
Generated email confirmation links will look like `localhost:8080/login?confirm-email=<token>` with
122127
the
123128
default configuration.
124129

125130
```properties
126-
host.name=${HOST:localhost}
127-
login-endpoint=${LOGIN_ENDPOINT:login}
131+
# global service route configuration for email interaction requests
132+
service.host.name=${DM_SERVICE_HOST:localhost}
133+
service.host.protocol=${DM_HOST_PROTOCOL:https}
134+
service.host.port=${DM_SERVICE_PORT:-1}
135+
136+
# route for email confirmation consumption
137+
email-confirmation-endpoint=${EMAIL_CONFIRMATION_ENDPOINT:login}
128138
email-confirmation-parameter=${EMAIL_CONFIRMATION_PARAMETER:confirm-email}
139+
140+
# route for password reset
141+
password-reset-endpoint=${PASSWORD_RESET_ENDPOINT:new-password}
142+
password-reset-parameter=${PASSWORD_RESET_PARAMETER:user-id}
129143
```
130144

131145
#### Properties
@@ -134,18 +148,41 @@ The environment variables can either be set in the runtime configuration of your
134148
the [application properties file](https://github.com/qbicsoftware/data-manager-app/blob/main/webapp/src/main/resources/application.properties):
135149

136150
```properties
151+
server.port=${DM_PORT:8080}
152+
logging.level.org.atmosphere=warn
153+
spring.mustache.check-template-location=false
154+
# Launch the default browser when starting the application in development mode
155+
vaadin.launch-browser=true
156+
# To improve the performance during development.
157+
# For more information https://vaadin.com/docs/flow/spring/tutorial-spring-configuration.html#special-configuration-parameters
158+
vaadin.whitelisted-packages=com.vaadin,org.vaadin,dev.hilla,life.qbic
159+
# Database setup configuration
137160
spring.datasource.url=${USER_DB_URL:localhost}
161+
spring.datasource.driver-class-name=${USER_DB_DRIVER:com.mysql.cj.jdbc.Driver}
138162
spring.datasource.username=${USER_DB_USER_NAME:myusername}
139163
spring.datasource.password=${USER_DB_USER_PW:astrongpassphrase!}
140-
server.port=${PORT:8080}
141-
spring.datasource.driver-class-name=${USER_DB_DRIVER:com.mysql.cj.jdbc.Driver}
164+
spring.jpa.hibernate.ddl-auto=update
165+
166+
# email configuration
142167
spring.mail.username=${MAIL_USERNAME}
143168
spring.mail.password=${MAIL_PASSWORD}
144169
spring.mail.host=${MAIL_HOST:smtp.gmail.com}
170+
spring.mail.default-encoding=UTF-8
145171
spring.mail.port=${MAIL_PORT:587}
146-
host.name=${HOST:localhost}
147-
login-endpoint=${LOGIN_ENDPOINT:login}
172+
173+
# global service route configuration for email interaction requests
174+
service.host.name=${DM_SERVICE_HOST:localhost}
175+
service.host.protocol=${DM_HOST_PROTOCOL:https}
176+
service.host.port=${DM_SERVICE_PORT:-1}
177+
178+
# route for email confirmation consumption
179+
email-confirmation-endpoint=${EMAIL_CONFIRMATION_ENDPOINT:login}
148180
email-confirmation-parameter=${EMAIL_CONFIRMATION_PARAMETER:confirm-email}
181+
182+
# route for password reset
183+
password-reset-endpoint=${PASSWORD_RESET_ENDPOINT:new-password}
184+
password-reset-parameter=${PASSWORD_RESET_PARAMETER:user-id}
185+
149186
```
150187

151188
### Local testing

webapp/frontend/generated/vaadin.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ import './vaadin-featureflags.ts';
22

33
import './index';
44

5+
import '@vaadin/flow-frontend/VaadinDevmodeGizmo.js';
6+
57
import { applyTheme } from './theme';
68
applyTheme(document);

webapp/src/main/java/life/qbic/usermanagement/passwordreset/PasswordResetLinkSupplier.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class PasswordResetLinkSupplier {
2828
public PasswordResetLinkSupplier(
2929
@Value("${service.host.protocol}") String protocol,
3030
@Value("${service.host.name}") String host,
31-
@Value("${server.port}") int port,
31+
@Value("${service.host.port}") int port,
3232
@Value("${password-reset-endpoint}") String resetEndpoint,
3333
@Value("${password-reset-parameter}") String passwordResetParameter) {
3434
this.protocol = protocol;

webapp/src/main/java/life/qbic/usermanagement/registration/EmailConfirmationLinkSupplier.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class EmailConfirmationLinkSupplier {
2626
public EmailConfirmationLinkSupplier(
2727
@Value("${service.host.protocol}") String protocol,
2828
@Value("${service.host.name}") String host,
29-
@Value("${server.port}") int port,
29+
@Value("${service.host.port}") int port,
3030
@Value("${email-confirmation-endpoint}") String loginEndpoint,
3131
@Value("${email-confirmation-parameter}") String emailConfirmationParameter) {
3232
this.protocol = protocol;

webapp/src/main/resources/application.properties

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ spring.mail.port=${MAIL_PORT:587}
2323
# global service route configuration for email interaction requests
2424
service.host.name=${DM_SERVICE_HOST:localhost}
2525
service.host.protocol=${DM_HOST_PROTOCOL:https}
26+
service.host.port=${DM_SERVICE_PORT:-1}
2627

2728
# route for email confirmation consumption
2829
email-confirmation-endpoint=${EMAIL_CONFIRMATION_ENDPOINT:login}

0 commit comments

Comments
 (0)