Showing
8 changed files
with
14 additions
and
42 deletions
... | ... | @@ -431,9 +431,6 @@ public abstract class BaseController { |
431 | 431 | case WIDGET_TYPE: |
432 | 432 | checkWidgetTypeId(new WidgetTypeId(entityId.getId()), operation); |
433 | 433 | return; |
434 | - case OAUTH2_CLIENT_REGISTRATION_INFO: | |
435 | - case OAUTH2_CLIENT_REGISTRATION_TEMPLATE: | |
436 | - return; | |
437 | 434 | default: |
438 | 435 | throw new IllegalArgumentException("Unsupported entity type: " + entityId.getEntityType()); |
439 | 436 | } | ... | ... |
... | ... | @@ -25,6 +25,8 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; |
25 | 25 | import org.thingsboard.server.common.data.id.OAuth2ClientRegistrationTemplateId; |
26 | 26 | import org.thingsboard.server.common.data.oauth2.OAuth2ClientRegistrationTemplate; |
27 | 27 | import org.thingsboard.server.queue.util.TbCoreComponent; |
28 | +import org.thingsboard.server.service.security.permission.Operation; | |
29 | +import org.thingsboard.server.service.security.permission.Resource; | |
28 | 30 | |
29 | 31 | import java.util.List; |
30 | 32 | |
... | ... | @@ -40,6 +42,7 @@ public class OAuth2ConfigTemplateController extends BaseController { |
40 | 42 | @ResponseStatus(value = HttpStatus.OK) |
41 | 43 | public OAuth2ClientRegistrationTemplate saveClientRegistrationTemplate(@RequestBody OAuth2ClientRegistrationTemplate clientRegistrationTemplate) throws ThingsboardException { |
42 | 44 | try { |
45 | + accessControlService.checkPermission(getCurrentUser(), Resource.OAUTH2_CONFIGURATION_TEMPLATE, Operation.WRITE); | |
43 | 46 | return oAuth2ConfigTemplateService.saveClientRegistrationTemplate(clientRegistrationTemplate); |
44 | 47 | } catch (Exception e) { |
45 | 48 | throw handleException(e); |
... | ... | @@ -52,21 +55,10 @@ public class OAuth2ConfigTemplateController extends BaseController { |
52 | 55 | public void deleteClientRegistrationTemplate(@PathVariable(CLIENT_REGISTRATION_TEMPLATE_ID) String strClientRegistrationTemplateId) throws ThingsboardException { |
53 | 56 | checkParameter(CLIENT_REGISTRATION_TEMPLATE_ID, strClientRegistrationTemplateId); |
54 | 57 | try { |
58 | + accessControlService.checkPermission(getCurrentUser(), Resource.OAUTH2_CONFIGURATION_TEMPLATE, Operation.DELETE); | |
55 | 59 | OAuth2ClientRegistrationTemplateId clientRegistrationTemplateId = new OAuth2ClientRegistrationTemplateId(toUUID(strClientRegistrationTemplateId)); |
56 | 60 | oAuth2ConfigTemplateService.deleteClientRegistrationTemplateById(clientRegistrationTemplateId); |
57 | - | |
58 | - logEntityAction(clientRegistrationTemplateId, | |
59 | - null, | |
60 | - null, | |
61 | - ActionType.DELETED, null, strClientRegistrationTemplateId); | |
62 | - | |
63 | 61 | } catch (Exception e) { |
64 | - | |
65 | - logEntityAction(emptyId(EntityType.OAUTH2_CLIENT_REGISTRATION_TEMPLATE), | |
66 | - null, | |
67 | - null, | |
68 | - ActionType.DELETED, e, strClientRegistrationTemplateId); | |
69 | - | |
70 | 62 | throw handleException(e); |
71 | 63 | } |
72 | 64 | } |
... | ... | @@ -76,6 +68,7 @@ public class OAuth2ConfigTemplateController extends BaseController { |
76 | 68 | @ResponseBody |
77 | 69 | public List<OAuth2ClientRegistrationTemplate> getClientRegistrationTemplates() throws ThingsboardException { |
78 | 70 | try { |
71 | + accessControlService.checkPermission(getCurrentUser(), Resource.OAUTH2_CONFIGURATION_TEMPLATE, Operation.READ); | |
79 | 72 | return oAuth2ConfigTemplateService.findAllClientRegistrationTemplates(); |
80 | 73 | } catch (Exception e) { |
81 | 74 | throw handleException(e); | ... | ... |
... | ... | @@ -24,6 +24,8 @@ import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo; |
24 | 24 | import org.thingsboard.server.common.data.oauth2.OAuth2ClientsParams; |
25 | 25 | import org.thingsboard.server.common.data.oauth2.SchemeType; |
26 | 26 | import org.thingsboard.server.queue.util.TbCoreComponent; |
27 | +import org.thingsboard.server.service.security.permission.Operation; | |
28 | +import org.thingsboard.server.service.security.permission.Resource; | |
27 | 29 | import org.thingsboard.server.utils.MiscUtils; |
28 | 30 | |
29 | 31 | import javax.servlet.http.HttpServletRequest; |
... | ... | @@ -49,6 +51,7 @@ public class OAuth2Controller extends BaseController { |
49 | 51 | @ResponseBody |
50 | 52 | public OAuth2ClientsParams getCurrentOAuth2Params() throws ThingsboardException { |
51 | 53 | try { |
54 | + accessControlService.checkPermission(getCurrentUser(), Resource.OAUTH2_CONFIGURATION_INFO, Operation.READ); | |
52 | 55 | return oAuth2Service.findOAuth2Params(); |
53 | 56 | } catch (Exception e) { |
54 | 57 | throw handleException(e); |
... | ... | @@ -60,6 +63,7 @@ public class OAuth2Controller extends BaseController { |
60 | 63 | @ResponseStatus(value = HttpStatus.OK) |
61 | 64 | public OAuth2ClientsParams saveOAuth2Params(@RequestBody OAuth2ClientsParams oauth2Params) throws ThingsboardException { |
62 | 65 | try { |
66 | + accessControlService.checkPermission(getCurrentUser(), Resource.OAUTH2_CONFIGURATION_INFO, Operation.WRITE); | |
63 | 67 | oAuth2Service.saveOAuth2Params(oauth2Params); |
64 | 68 | return oAuth2Service.findOAuth2Params(); |
65 | 69 | } catch (Exception e) { | ... | ... |
... | ... | @@ -32,8 +32,8 @@ public enum Resource { |
32 | 32 | USER(EntityType.USER), |
33 | 33 | WIDGETS_BUNDLE(EntityType.WIDGETS_BUNDLE), |
34 | 34 | WIDGET_TYPE(EntityType.WIDGET_TYPE), |
35 | - OAUTH2_CONFIGURATION_INFO(EntityType.OAUTH2_CLIENT_REGISTRATION_INFO), | |
36 | - OAUTH2_CONFIGURATION_TEMPLATE(EntityType.OAUTH2_CLIENT_REGISTRATION_TEMPLATE), | |
35 | + OAUTH2_CONFIGURATION_INFO(), | |
36 | + OAUTH2_CONFIGURATION_TEMPLATE(), | |
37 | 37 | TENANT_PROFILE(EntityType.TENANT_PROFILE), |
38 | 38 | DEVICE_PROFILE(EntityType.DEVICE_PROFILE); |
39 | 39 | ... | ... |
... | ... | @@ -62,10 +62,6 @@ public class EntityIdFactory { |
62 | 62 | return new WidgetsBundleId(uuid); |
63 | 63 | case WIDGET_TYPE: |
64 | 64 | return new WidgetTypeId(uuid); |
65 | - case OAUTH2_CLIENT_REGISTRATION_INFO: | |
66 | - return new OAuth2ClientRegistrationInfoId(uuid); | |
67 | - case OAUTH2_CLIENT_REGISTRATION_TEMPLATE: | |
68 | - return new OAuth2ClientRegistrationTemplateId(uuid); | |
69 | 65 | case DEVICE_PROFILE: |
70 | 66 | return new DeviceProfileId(uuid); |
71 | 67 | case TENANT_PROFILE: | ... | ... |
... | ... | @@ -17,11 +17,10 @@ package org.thingsboard.server.common.data.id; |
17 | 17 | |
18 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; |
19 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; |
20 | -import org.thingsboard.server.common.data.EntityType; | |
21 | 20 | |
22 | 21 | import java.util.UUID; |
23 | 22 | |
24 | -public class OAuth2ClientRegistrationId extends UUIDBased implements EntityId { | |
23 | +public class OAuth2ClientRegistrationId extends UUIDBased { | |
25 | 24 | |
26 | 25 | @JsonCreator |
27 | 26 | public OAuth2ClientRegistrationId(@JsonProperty("id") UUID id) { |
... | ... | @@ -31,9 +30,4 @@ public class OAuth2ClientRegistrationId extends UUIDBased implements EntityId { |
31 | 30 | public static OAuth2ClientRegistrationId fromString(String clientRegistrationId) { |
32 | 31 | return new OAuth2ClientRegistrationId(UUID.fromString(clientRegistrationId)); |
33 | 32 | } |
34 | - | |
35 | - @Override | |
36 | - public EntityType getEntityType() { | |
37 | - return EntityType.OAUTH2_CLIENT_REGISTRATION; | |
38 | - } | |
39 | 33 | } | ... | ... |
... | ... | @@ -17,11 +17,10 @@ package org.thingsboard.server.common.data.id; |
17 | 17 | |
18 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; |
19 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; |
20 | -import org.thingsboard.server.common.data.EntityType; | |
21 | 20 | |
22 | 21 | import java.util.UUID; |
23 | 22 | |
24 | -public class OAuth2ClientRegistrationInfoId extends UUIDBased implements EntityId { | |
23 | +public class OAuth2ClientRegistrationInfoId extends UUIDBased { | |
25 | 24 | |
26 | 25 | @JsonCreator |
27 | 26 | public OAuth2ClientRegistrationInfoId(@JsonProperty("id") UUID id) { |
... | ... | @@ -31,9 +30,4 @@ public class OAuth2ClientRegistrationInfoId extends UUIDBased implements EntityI |
31 | 30 | public static OAuth2ClientRegistrationInfoId fromString(String clientRegistrationInfoId) { |
32 | 31 | return new OAuth2ClientRegistrationInfoId(UUID.fromString(clientRegistrationInfoId)); |
33 | 32 | } |
34 | - | |
35 | - @Override | |
36 | - public EntityType getEntityType() { | |
37 | - return EntityType.OAUTH2_CLIENT_REGISTRATION_INFO; | |
38 | - } | |
39 | 33 | } | ... | ... |
... | ... | @@ -17,11 +17,10 @@ package org.thingsboard.server.common.data.id; |
17 | 17 | |
18 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; |
19 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; |
20 | -import org.thingsboard.server.common.data.EntityType; | |
21 | 20 | |
22 | 21 | import java.util.UUID; |
23 | 22 | |
24 | -public class OAuth2ClientRegistrationTemplateId extends UUIDBased implements EntityId { | |
23 | +public class OAuth2ClientRegistrationTemplateId extends UUIDBased { | |
25 | 24 | |
26 | 25 | @JsonCreator |
27 | 26 | public OAuth2ClientRegistrationTemplateId(@JsonProperty("id") UUID id) { |
... | ... | @@ -31,9 +30,4 @@ public class OAuth2ClientRegistrationTemplateId extends UUIDBased implements Ent |
31 | 30 | public static OAuth2ClientRegistrationTemplateId fromString(String clientRegistrationTemplateId) { |
32 | 31 | return new OAuth2ClientRegistrationTemplateId(UUID.fromString(clientRegistrationTemplateId)); |
33 | 32 | } |
34 | - | |
35 | - @Override | |
36 | - public EntityType getEntityType() { | |
37 | - return EntityType.OAUTH2_CLIENT_REGISTRATION_TEMPLATE; | |
38 | - } | |
39 | 33 | } | ... | ... |