Admin Controller description
This commit is contained in:
parent
bf56d9e1a4
commit
e6e05c9b88
@ -16,6 +16,8 @@
|
||||
package org.thingsboard.server.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -44,6 +46,7 @@ import org.thingsboard.server.service.update.UpdateService;
|
||||
@RequestMapping("/api/admin")
|
||||
public class AdminController extends BaseController {
|
||||
|
||||
public static final String SYS_ADMIN_AUTHORITY_ONLY = " Available for users with System Administrator ('SYS_ADMIN') authority only.";
|
||||
@Autowired
|
||||
private MailService mailService;
|
||||
|
||||
@ -59,10 +62,14 @@ public class AdminController extends BaseController {
|
||||
@Autowired
|
||||
private UpdateService updateService;
|
||||
|
||||
@ApiOperation(value = "Get the Administration Settings object using key (getAdminSettings)",
|
||||
notes = "Get the Administration Settings object using specified string key. Referencing non-existing key will cause an error." + SYS_ADMIN_AUTHORITY_ONLY)
|
||||
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
||||
@RequestMapping(value = "/settings/{key}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public AdminSettings getAdminSettings(@PathVariable("key") String key) throws ThingsboardException {
|
||||
public AdminSettings getAdminSettings(
|
||||
@ApiParam(value = "A string value of the key (e.g. 'general' or 'mail').")
|
||||
@PathVariable("key") String key) throws ThingsboardException {
|
||||
try {
|
||||
accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ);
|
||||
AdminSettings adminSettings = checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, key));
|
||||
@ -75,10 +82,17 @@ public class AdminController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "Get the Administration Settings object using key (getAdminSettings)",
|
||||
notes = "Creates or Updates the Administration Settings. Platform generates random Administration Settings Id during settings creation. " +
|
||||
"The Administration Settings Id will be present in the response. Specify the Administration Settings Id when you would like to update the Administration Settings. " +
|
||||
"Referencing non-existing Administration Settings Id will cause an error." + SYS_ADMIN_AUTHORITY_ONLY)
|
||||
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
||||
@RequestMapping(value = "/settings", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public AdminSettings saveAdminSettings(@RequestBody AdminSettings adminSettings) throws ThingsboardException {
|
||||
public AdminSettings saveAdminSettings(
|
||||
@ApiParam(value = "A JSON value representing the Administration Settings.")
|
||||
@RequestBody AdminSettings adminSettings) throws ThingsboardException {
|
||||
try {
|
||||
accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.WRITE);
|
||||
adminSettings = checkNotNull(adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, adminSettings));
|
||||
@ -94,6 +108,8 @@ public class AdminController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Get the Security Settings object",
|
||||
notes = "Get the Security Settings object that contains password policy, etc." + SYS_ADMIN_AUTHORITY_ONLY)
|
||||
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
||||
@RequestMapping(value = "/securitySettings", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@ -106,10 +122,14 @@ public class AdminController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Update Security Settings (saveSecuritySettings)",
|
||||
notes = "Updates the Security Settings object that contains password policy, etc." + SYS_ADMIN_AUTHORITY_ONLY)
|
||||
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
||||
@RequestMapping(value = "/securitySettings", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public SecuritySettings saveSecuritySettings(@RequestBody SecuritySettings securitySettings) throws ThingsboardException {
|
||||
public SecuritySettings saveSecuritySettings(
|
||||
@ApiParam(value = "A JSON value representing the Security Settings.")
|
||||
@RequestBody SecuritySettings securitySettings) throws ThingsboardException {
|
||||
try {
|
||||
accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.WRITE);
|
||||
securitySettings = checkNotNull(systemSecurityService.saveSecuritySettings(TenantId.SYS_TENANT_ID, securitySettings));
|
||||
@ -119,14 +139,19 @@ public class AdminController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Send test email (sendTestMail)",
|
||||
notes = "Attempts to send test email to the System Administrator User using Mail Settings provided as a parameter. " +
|
||||
"You may change the 'To' email in the user profile of the System Administrator. " + SYS_ADMIN_AUTHORITY_ONLY)
|
||||
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
||||
@RequestMapping(value = "/settings/testMail", method = RequestMethod.POST)
|
||||
public void sendTestMail(@RequestBody AdminSettings adminSettings) throws ThingsboardException {
|
||||
public void sendTestMail(
|
||||
@ApiParam(value = "A JSON value representing the Mail Settings.")
|
||||
@RequestBody AdminSettings adminSettings) throws ThingsboardException {
|
||||
try {
|
||||
accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ);
|
||||
adminSettings = checkNotNull(adminSettings);
|
||||
if (adminSettings.getKey().equals("mail")) {
|
||||
if(!adminSettings.getJsonValue().has("password")) {
|
||||
if (!adminSettings.getJsonValue().has("password")) {
|
||||
AdminSettings mailSettings = checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "mail"));
|
||||
((ObjectNode) adminSettings.getJsonValue()).put("password", mailSettings.getJsonValue().get("password").asText());
|
||||
}
|
||||
@ -138,9 +163,14 @@ public class AdminController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Send test sms (sendTestMail)",
|
||||
notes = "Attempts to send test sms to the System Administrator User using SMS Settings and phone number provided as a parameters of the request. "
|
||||
+ SYS_ADMIN_AUTHORITY_ONLY)
|
||||
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
||||
@RequestMapping(value = "/settings/testSms", method = RequestMethod.POST)
|
||||
public void sendTestSms(@RequestBody TestSmsRequest testSmsRequest) throws ThingsboardException {
|
||||
public void sendTestSms(
|
||||
@ApiParam(value = "A JSON value representing the Test SMS request.")
|
||||
@RequestBody TestSmsRequest testSmsRequest) throws ThingsboardException {
|
||||
try {
|
||||
accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ);
|
||||
smsService.sendTestSms(testSmsRequest);
|
||||
@ -149,6 +179,9 @@ public class AdminController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Check for new Platform Releases (checkUpdates)",
|
||||
notes = "Check notifications about new platform releases. "
|
||||
+ SYS_ADMIN_AUTHORITY_ONLY)
|
||||
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
||||
@RequestMapping(value = "/updates", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
|
||||
@ -15,11 +15,15 @@
|
||||
*/
|
||||
package org.thingsboard.server.common.data;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.thingsboard.server.common.data.id.AdminSettingsId;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.thingsboard.server.common.data.id.DeviceId;
|
||||
import org.thingsboard.server.common.data.validation.NoXss;
|
||||
|
||||
@ApiModel
|
||||
public class AdminSettings extends BaseData<AdminSettingsId> {
|
||||
|
||||
private static final long serialVersionUID = -7670322981725511892L;
|
||||
@ -42,6 +46,19 @@ public class AdminSettings extends BaseData<AdminSettingsId> {
|
||||
this.jsonValue = adminSettings.getJsonValue();
|
||||
}
|
||||
|
||||
@ApiModelProperty(position = 1, value = "The Id of the Administration Settings, auto-generated, UUID")
|
||||
@Override
|
||||
public AdminSettingsId getId() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
@ApiModelProperty(position = 2, value = "Timestamp of the settings creation, in milliseconds", example = "1609459200000", readOnly = true)
|
||||
@Override
|
||||
public long getCreatedTime() {
|
||||
return super.getCreatedTime();
|
||||
}
|
||||
|
||||
@ApiModelProperty(position = 3, value = "The Administration Settings key, (e.g. 'general' or 'mail')")
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
@ -50,6 +67,7 @@ public class AdminSettings extends BaseData<AdminSettingsId> {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@ApiModelProperty(position = 4, value = "JSON representation of the Administration Settings value")
|
||||
public JsonNode getJsonValue() {
|
||||
return jsonValue;
|
||||
}
|
||||
|
||||
@ -15,12 +15,17 @@
|
||||
*/
|
||||
package org.thingsboard.server.common.data;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
public class UpdateMessage {
|
||||
|
||||
@ApiModelProperty(position = 1, value = "The message about new platform update available.")
|
||||
private final String message;
|
||||
@ApiModelProperty(position = 1, value = "'True' if new platform update is available.")
|
||||
private final boolean isUpdateAvailable;
|
||||
|
||||
}
|
||||
|
||||
@ -15,15 +15,20 @@
|
||||
*/
|
||||
package org.thingsboard.server.common.data.security.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
public class SecuritySettings implements Serializable {
|
||||
|
||||
@ApiModelProperty(position = 1, value = "The user password policy object." )
|
||||
private UserPasswordPolicy passwordPolicy;
|
||||
|
||||
@ApiModelProperty(position = 2, value = "Maximum number of failed login attempts allowed before user account is locked." )
|
||||
private Integer maxFailedLoginAttempts;
|
||||
@ApiModelProperty(position = 3, value = "Email to use for notifications about locked users." )
|
||||
private String userLockoutNotificationEmail;
|
||||
}
|
||||
|
||||
@ -15,20 +15,30 @@
|
||||
*/
|
||||
package org.thingsboard.server.common.data.security.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
public class UserPasswordPolicy implements Serializable {
|
||||
|
||||
@ApiModelProperty(position = 1, value = "Minimum number of symbols in the password." )
|
||||
private Integer minimumLength;
|
||||
@ApiModelProperty(position = 1, value = "Minimum number of uppercase letters in the password." )
|
||||
private Integer minimumUppercaseLetters;
|
||||
@ApiModelProperty(position = 1, value = "Minimum number of lowercase letters in the password." )
|
||||
private Integer minimumLowercaseLetters;
|
||||
@ApiModelProperty(position = 1, value = "Minimum number of digits in the password." )
|
||||
private Integer minimumDigits;
|
||||
@ApiModelProperty(position = 1, value = "Minimum number of special in the password." )
|
||||
private Integer minimumSpecialCharacters;
|
||||
|
||||
@ApiModelProperty(position = 1, value = "Password expiration period (days). Force expiration of the password." )
|
||||
private Integer passwordExpirationPeriodDays;
|
||||
@ApiModelProperty(position = 1, value = "Password reuse frequency (days). Disallow to use the same password for the defined number of days" )
|
||||
private Integer passwordReuseFrequencyDays;
|
||||
|
||||
}
|
||||
|
||||
@ -15,13 +15,19 @@
|
||||
*/
|
||||
package org.thingsboard.server.common.data.sms.config;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
public class AwsSnsSmsProviderConfiguration implements SmsProviderConfiguration {
|
||||
|
||||
@ApiModelProperty(position = 1, value = "The AWS SNS Access Key ID.")
|
||||
private String accessKeyId;
|
||||
@ApiModelProperty(position = 2, value = "The AWS SNS Access Key.")
|
||||
private String secretAccessKey;
|
||||
@ApiModelProperty(position = 3, value = "The AWS region.")
|
||||
private String region;
|
||||
|
||||
@Override
|
||||
|
||||
@ -15,13 +15,19 @@
|
||||
*/
|
||||
package org.thingsboard.server.common.data.sms.config;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
public class TestSmsRequest {
|
||||
|
||||
@ApiModelProperty(position = 1, value = "The SMS provider configuration")
|
||||
private SmsProviderConfiguration providerConfiguration;
|
||||
@ApiModelProperty(position = 2, value = "The phone number or other identifier to specify as a recipient of the SMS.")
|
||||
private String numberTo;
|
||||
@ApiModelProperty(position = 3, value = "The test message")
|
||||
private String message;
|
||||
|
||||
}
|
||||
|
||||
@ -15,13 +15,19 @@
|
||||
*/
|
||||
package org.thingsboard.server.common.data.sms.config;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
public class TwilioSmsProviderConfiguration implements SmsProviderConfiguration {
|
||||
|
||||
@ApiModelProperty(position = 1, value = "Twilio account Sid.")
|
||||
private String accountSid;
|
||||
@ApiModelProperty(position = 2, value = "Twilio account Token.")
|
||||
private String accountToken;
|
||||
@ApiModelProperty(position = 3, value = "The number/id of a sender.")
|
||||
private String numberFrom;
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user