Skip to content

Commit

Permalink
Merge pull request #83 from kbss-cvut/80-configuration
Browse files Browse the repository at this point in the history
Implement configuration class
  • Loading branch information
blcham authored Dec 2, 2024
2 parents 8a99072 + af6562e commit 63ae004
Show file tree
Hide file tree
Showing 12 changed files with 488 additions and 24 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,8 @@ The system can be split into two parts. __Main application__ provides management

### Further Record Manager Configuration

The following table lists the names of environment variables that can be
passed to Record Manager backend either directly in `docker-compose.yml`, in
an [env_file](https://docs.docker.com/compose/compose-file/compose-file-v3/#env_file), or via command line.

| Variable | Explanation |
|:---------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ```RECORDS_ALLOWEDREJECTREASON``` | Allow user to enter reason when rejecting records. Default value: `false.` |
The table lists environment variables that can be passed to the Record Manager backend through `docker-compose.yml`, an [env_file](https://docs.docker.com/compose/compose-file/compose-file-v3/#env_file),
or the command line. For more details, see the [Configuration documentation](./doc/configuration.md).

## Documentation

Expand Down
30 changes: 30 additions & 0 deletions doc/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
| Variable | Description |
| --- | --- |
| ```APPCONTEXT``` | Public URL of the frontend of record-manager application that is used for password reset emails. e.g. https://study.example.com/record-manager/ (must have "/" at the end) |
| ```EMAIL_BCC``` | Email addresses to be blind carbon-copied, separated by a comma (optional, can be empty). |
| ```EMAIL_CC``` | Email addresses to be carbon-copied, separated by a comma (optional, can be empty). |
| ```EMAIL_DISPLAYNAME``` | Email display name |
| ```EMAIL_FROM``` | if email.from is not entered, smtp.user is used instead |
| ```EMAIL_INVITATIONCONTENT``` | UserInvite email html content, variables: username, link, name, appContext |
| ```EMAIL_INVITATIONSUBJECT``` | serInvite email subject |
| ```EMAIL_PASSWORDCHANGECONTENT``` | PasswordReset email html content, variables: username, appContext |
| ```EMAIL_PASSWORDCHANGESUBJECT``` | Password change email |
| ```EMAIL_PASSWORDRESETCONTENT``` | PasswordReset email html content, variables: username, link, appContext |
| ```EMAIL_PASSWORDRESETSUBJECT``` | You can use variables in email contents by using {{variable}}, available variables are listed before email content property<br>Password Reset email subject |
| ```EMAIL_PROFILEUPDATECONTENT``` | PasswordReset email html content, variables: username, appContext |
| ```EMAIL_PROFILEUPDATESUBJECT``` | Profile update email |
| ```EMAIL_REPLYTO``` | Email cc addresses where all invitations will be sent. For more use delimiter "," (can remain empty) |
| ```FORMGENREPOSITORYURL``` | URL of repository where output and configuration of form-generator should be held |
| ```FORMGENSERVICEURL``` | REST endpoint of form generator service |
| ```PERSISTENCEDRIVER``` | Persistence driver to manage triple stores |
| ```RECORDS_ALLOWEDREJECTREASON``` | it indicates functionality allowing users to specify a reason for rejection is enabled. |
| ```REPOSITORYURL``` | URL of repository that holds main data of the application |
| ```SECURITY_CORD_ALLOWEDORIGINS``` | Configures allowed origins for CORS (e.g. http://localhost:3000). Use a comma to separate multiple values |
| ```SECURITY_OIDC_ROLECLAIM``` | Claim containing user roles in the OIDC access token (applies only when 'oidc' security provider is selected). Use<br>dot notation for nested objects |
| ```SECURITY_PROVIDER``` | Provider of application security. Possible values are 'internal' for internally stored users and 'oidc' for using an<br>OIDC-compatible authentication service. Its URL is configured via Spring Boot configuration parameters |
| ```SECURITY_SAMESITE``` | Option to pass sameSite attribute for set-cookie headers. Possible values are None,Lax,Strict. In case of None value also attribute "Secure;" is added. |
| ```SMTP_HOST``` | SMTP host |
| ```SMTP_PASSWORD``` | SMTP password |
| ```SMTP_PORT``` | SMTP port |
| ```SMTP_USER``` | SMTP user |

11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,18 @@
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>cz.lukaskabc.cvut.processor</groupId>
<artifactId>spring-boot-configuration-docgen-processor</artifactId>
<version>1.1</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Aconfigurationdoc.output_file=./doc/configuration.md</arg>
<arg>-Aconfigurationdoc.format=MD</arg>
<arg>-Aconfigurationdoc.prepend_required=true</arg>
<arg>-Aconfigurationdoc.configuration_package=cz.cvut.kbss.study</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.PropertySource;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;

@SpringBootApplication
@ConfigurationPropertiesScan
public class RecordManagerApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import jakarta.annotation.PreDestroy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

import java.util.HashMap;
Expand All @@ -15,7 +14,7 @@
import static cz.cvut.kbss.jopa.model.JOPAPersistenceProperties.CACHE_ENABLED;
import static cz.cvut.kbss.jopa.model.JOPAPersistenceProperties.DATA_SOURCE_CLASS;
import static cz.cvut.kbss.jopa.model.JOPAPersistenceProperties.ONTOLOGY_PHYSICAL_URI_KEY;
import static cz.cvut.kbss.study.util.ConfigParam.DRIVER;
import static cz.cvut.kbss.study.util.ConfigParam.PERSISTENCE_DRIVER;
import static cz.cvut.kbss.study.util.ConfigParam.FORM_GEN_REPOSITORY_URL;

@Configuration
Expand All @@ -38,7 +37,7 @@ public EntityManagerFactory getEntityManagerFactory() {
private void init() {
final Map<String, String> properties = new HashMap<>(PersistenceFactory.getDefaultParams());
properties.put(ONTOLOGY_PHYSICAL_URI_KEY, environment.getProperty(FORM_GEN_REPOSITORY_URL.toString()));
properties.put(DATA_SOURCE_CLASS, environment.getProperty(DRIVER.toString()));
properties.put(DATA_SOURCE_CLASS, environment.getProperty(PERSISTENCE_DRIVER.toString()));
properties.put(CACHE_ENABLED, Boolean.FALSE.toString());
this.emf = Persistence.createEntityManagerFactory("formGenPU", properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static cz.cvut.kbss.jopa.model.JOPAPersistenceProperties.SCAN_PACKAGE;
import static cz.cvut.kbss.ontodriver.config.OntoDriverProperties.DATA_SOURCE_PASSWORD;
import static cz.cvut.kbss.ontodriver.config.OntoDriverProperties.DATA_SOURCE_USERNAME;
import static cz.cvut.kbss.study.util.ConfigParam.DRIVER;
import static cz.cvut.kbss.study.util.ConfigParam.PERSISTENCE_DRIVER;
import static cz.cvut.kbss.study.util.ConfigParam.REPOSITORY_URL;

/**
Expand Down Expand Up @@ -54,7 +54,7 @@ public EntityManagerFactory getEntityManagerFactory() {
private void init() {
final Map<String, String> properties = new HashMap<>(DEFAULT_PARAMS);
properties.put(ONTOLOGY_PHYSICAL_URI_KEY, environment.getProperty(REPOSITORY_URL.toString()));
properties.put(DATA_SOURCE_CLASS, environment.getProperty(DRIVER.toString()));
properties.put(DATA_SOURCE_CLASS, environment.getProperty(PERSISTENCE_DRIVER.toString()));
if (environment.getProperty(USERNAME_PROPERTY) != null) {
properties.put(DATA_SOURCE_USERNAME, environment.getProperty(USERNAME_PROPERTY));
properties.put(DATA_SOURCE_PASSWORD, environment.getProperty(PASSWORD_PROPERTY));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cz/cvut/kbss/study/util/ConfigParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public enum ConfigParam {
SECURITY_SAME_SITE("security.sameSite"),

REPOSITORY_URL("repositoryUrl"),
DRIVER("driver"),
PERSISTENCE_DRIVER("persistenceDriver"),
FORM_GEN_REPOSITORY_URL("formGenRepositoryUrl"),
FORM_GEN_SERVICE_URL("formGenServiceUrl"),

Expand Down
Loading

0 comments on commit 63ae004

Please sign in to comment.