Skip to content
Snippets Groups Projects
Commit 1badf5c3 authored by uhensler's avatar uhensler
Browse files

OO-4009: Configuration of API URL

parent 4ee74481
No related branches found
No related tags found
No related merge requests found
...@@ -43,14 +43,17 @@ import io.jsonwebtoken.security.Keys; ...@@ -43,14 +43,17 @@ import io.jsonwebtoken.security.Keys;
public class OnlyOfficeModule extends AbstractSpringModule implements ConfigOnOff { public class OnlyOfficeModule extends AbstractSpringModule implements ConfigOnOff {
private static final OLog log = Tracing.createLoggerFor(OnlyOfficeModule.class); private static final OLog log = Tracing.createLoggerFor(OnlyOfficeModule.class);
private static final String ONLYOFFICE_ENABLED = "onlyoffice.enabled"; private static final String ONLYOFFICE_ENABLED = "onlyoffice.enabled";
private static final String ONLYOFFICE_API_URL = "onlyoffice.apiUrl"; private static final String ONLYOFFICE_BASE_URL = "onlyoffice.baseUrl";
private static final String ONLYOFFICE_JWT_SECRET = "onlyoffice.jwt.secret"; private static final String ONLYOFFICE_JWT_SECRET = "onlyoffice.jwt.secret";
@Value("${onlyoffice.enabled:false}") @Value("${onlyoffice.enabled:false}")
private boolean enabled; private boolean enabled;
@Value("${onlyoffice.apiUrl}") @Value("${onlyoffice.baseUrl}")
private String baseUrl;
@Value("${onlyoffice.api.path}")
private String apiPath;
private String apiUrl; private String apiUrl;
private String jwtSecret; private String jwtSecret;
private Key jwtSignKey; private Key jwtSignKey;
...@@ -76,9 +79,10 @@ public class OnlyOfficeModule extends AbstractSpringModule implements ConfigOnOf ...@@ -76,9 +79,10 @@ public class OnlyOfficeModule extends AbstractSpringModule implements ConfigOnOf
enabled = "true".equals(enabledObj); enabled = "true".equals(enabledObj);
} }
String apiUrlObj = getStringPropertyValue(ONLYOFFICE_API_URL, true); String baseUrlObj = getStringPropertyValue(ONLYOFFICE_BASE_URL, true);
if(StringHelper.containsNonWhitespace(apiUrlObj)) { if(StringHelper.containsNonWhitespace(baseUrlObj)) {
apiUrl = apiUrlObj; baseUrl = baseUrlObj;
resetApiUrl();
} }
String jwtSecretObj = getStringPropertyValue(ONLYOFFICE_JWT_SECRET, true); String jwtSecretObj = getStringPropertyValue(ONLYOFFICE_JWT_SECRET, true);
...@@ -97,21 +101,31 @@ public class OnlyOfficeModule extends AbstractSpringModule implements ConfigOnOf ...@@ -97,21 +101,31 @@ public class OnlyOfficeModule extends AbstractSpringModule implements ConfigOnOf
setStringProperty(ONLYOFFICE_ENABLED, Boolean.toString(enabled), true); setStringProperty(ONLYOFFICE_ENABLED, Boolean.toString(enabled), true);
} }
public String getBaseUrl() {
return baseUrl;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
setStringProperty(ONLYOFFICE_BASE_URL, baseUrl, true);
resetApiUrl();
}
public String getApiUrl() { public String getApiUrl() {
return apiUrl; return apiUrl;
} }
public void setApiUrl(String apiUrl) { private void resetApiUrl() {
this.apiUrl = apiUrl; this.apiUrl = baseUrl + apiPath;
setStringProperty(ONLYOFFICE_API_URL, apiUrl, true);
} }
public String getJwtSecret() { public String getJwtSecret() {
return jwtSecret; return jwtSecret;
} }
public void setJwtSecret(String jwtSecret) { public void setJwtSecret(String jwtSecret) {
this.jwtSecret = jwtSecret; this.jwtSecret = jwtSecret;
this.jwtSignKey = null;
setStringProperty(ONLYOFFICE_JWT_SECRET, jwtSecret, true); setStringProperty(ONLYOFFICE_JWT_SECRET, jwtSecret, true);
} }
......
...@@ -45,7 +45,7 @@ public class OnlyOfficeAdminController extends FormBasicController { ...@@ -45,7 +45,7 @@ public class OnlyOfficeAdminController extends FormBasicController {
private static final String[] ENABLED_KEYS = new String[]{"on"}; private static final String[] ENABLED_KEYS = new String[]{"on"};
private MultipleSelectionElement enabledEl; private MultipleSelectionElement enabledEl;
private TextElement apiUrlEl; private TextElement baseUrlEl;
private TextElement jwtSecretEl; private TextElement jwtSecretEl;
@Autowired @Autowired
...@@ -66,10 +66,9 @@ public class OnlyOfficeAdminController extends FormBasicController { ...@@ -66,10 +66,9 @@ public class OnlyOfficeAdminController extends FormBasicController {
enabledEl = uifactory.addCheckboxesHorizontal("admin.enabled", formLayout, ENABLED_KEYS, translateAll(getTranslator(), ENABLED_KEYS)); enabledEl = uifactory.addCheckboxesHorizontal("admin.enabled", formLayout, ENABLED_KEYS, translateAll(getTranslator(), ENABLED_KEYS));
enabledEl.select(ENABLED_KEYS[0], onlyOfficeModule.isEnabled()); enabledEl.select(ENABLED_KEYS[0], onlyOfficeModule.isEnabled());
String url = onlyOfficeModule.getApiUrl(); String url = onlyOfficeModule.getBaseUrl();
apiUrlEl = uifactory.addTextElement("admin.api.url", 128, url, formLayout); baseUrlEl = uifactory.addTextElement("admin.base.url", 128, url, formLayout);
apiUrlEl.setExampleKey("admin.api.url.example", null); baseUrlEl.setMandatory(true);
apiUrlEl.setMandatory(true);
String secret = onlyOfficeModule.getJwtSecret(); String secret = onlyOfficeModule.getJwtSecret();
jwtSecretEl = uifactory.addTextElement("admin.jwt.secret", 128, secret, formLayout); jwtSecretEl = uifactory.addTextElement("admin.jwt.secret", 128, secret, formLayout);
...@@ -85,7 +84,7 @@ public class OnlyOfficeAdminController extends FormBasicController { ...@@ -85,7 +84,7 @@ public class OnlyOfficeAdminController extends FormBasicController {
boolean allOk = true; boolean allOk = true;
if (enabledEl.isAtLeastSelected(1)) { if (enabledEl.isAtLeastSelected(1)) {
allOk &= validateIsMandatory(apiUrlEl); allOk &= validateIsMandatory(baseUrlEl);
boolean jwtSecretOk = validateIsMandatory(jwtSecretEl); boolean jwtSecretOk = validateIsMandatory(jwtSecretEl);
if (jwtSecretOk && !onlyOfficeSecurityService.isValidSecret(jwtSecretEl.getValue())) { if (jwtSecretOk && !onlyOfficeSecurityService.isValidSecret(jwtSecretEl.getValue())) {
...@@ -103,8 +102,9 @@ public class OnlyOfficeAdminController extends FormBasicController { ...@@ -103,8 +102,9 @@ public class OnlyOfficeAdminController extends FormBasicController {
boolean enabled = enabledEl.isAtLeastSelected(1); boolean enabled = enabledEl.isAtLeastSelected(1);
onlyOfficeModule.setEnabled(enabled); onlyOfficeModule.setEnabled(enabled);
String url = apiUrlEl.getValue(); String url = baseUrlEl.getValue();
onlyOfficeModule.setApiUrl(url); url = url.endsWith("/")? url: url + "/";
onlyOfficeModule.setBaseUrl(url);
String jwtSecret = jwtSecretEl.getValue(); String jwtSecret = jwtSecretEl.getValue();
onlyOfficeModule.setJwtSecret(jwtSecret); onlyOfficeModule.setJwtSecret(jwtSecret);
......
admin.api.url=API URL admin.base.url=URL
admin.api.url.example=https://onlyoffice.example.org/web-apps/apps/api/documents/api.js
admin.desc=OnlyOffice ist eine Software zur einzelnen oder gemeinsamen Bearbeitung von Dokumenten. Es unterst\u00FCtzt alle g\u00E4ngigen Dateiformate zur Textverarbeitung, Tabellenkalkulation und Pr\u00E4sentationen. Weitere Informationen sind auf der <a href\="http\://www.onlyoffice.com/" target\=_blank>Webseite</a> von OnlyOffice zu finden. admin.desc=OnlyOffice ist eine Software zur einzelnen oder gemeinsamen Bearbeitung von Dokumenten. Es unterst\u00FCtzt alle g\u00E4ngigen Dateiformate zur Textverarbeitung, Tabellenkalkulation und Pr\u00E4sentationen. Weitere Informationen sind auf der <a href\="http\://www.onlyoffice.com/" target\=_blank>Webseite</a> von OnlyOffice zu finden.
admin.enabled=Modul "OnlyOffice" admin.enabled=Modul "OnlyOffice"
admin.jwt.secret=Secret admin.jwt.secret=Secret
......
admin.api.url=API URL admin.base.url=URL
admin.api.url.example=https://onlyoffice.example.org/web-apps/apps/api/documents/api.js
admin.desc=OnylOffice is a software to edit documents online. It supports all major document, spreadsheet and presentation file formats. Key features are collaborative editing and excellent office file format support. Further information is available on the <a href\="https\://www.onlyoffice.com/" target\=_blank>website</a> of OnlyOffice admin.desc=OnylOffice is a software to edit documents online. It supports all major document, spreadsheet and presentation file formats. Key features are collaborative editing and excellent office file format support. Further information is available on the <a href\="https\://www.onlyoffice.com/" target\=_blank>website</a> of OnlyOffice
admin.enabled=Module "OnylOffice" admin.enabled=Module "OnylOffice"
admin.jwt.secret=Secret admin.jwt.secret=Secret
......
...@@ -1503,7 +1503,8 @@ collabora.baseUrl=https://collabora.example.org/ ...@@ -1503,7 +1503,8 @@ collabora.baseUrl=https://collabora.example.org/
# Options for OnlyOffice # Options for OnlyOffice
######################################## ########################################
onlyoffice.enabled=false onlyoffice.enabled=false
onlyoffice.apiUrl=https://onlyoffice.example.org/web-apps/apps/api/documents/api.js onlyoffice.baseUrl=https://onlyoffice.example.org/
onlyoffice.api.path=web-apps/apps/api/documents/api.js
######################################## ########################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment