|
|
|
@ -59,6 +59,7 @@ import static org.thingsboard.server.controller.ControllerConstants.PAGE_SIZE_DE |
|
|
|
import static org.thingsboard.server.controller.ControllerConstants.SORT_ORDER_DESCRIPTION; |
|
|
|
import static org.thingsboard.server.controller.ControllerConstants.SORT_PROPERTY_DESCRIPTION; |
|
|
|
import static org.thingsboard.server.controller.ControllerConstants.SYSTEM_AUTHORITY_PARAGRAPH; |
|
|
|
import static org.thingsboard.server.controller.ControllerConstants.SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH; |
|
|
|
|
|
|
|
@RestController |
|
|
|
@TbCoreComponent |
|
|
|
@ -104,8 +105,8 @@ public class OAuth2Controller extends BaseController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "Save OAuth2 Client (saveOAuth2Client)", notes = SYSTEM_AUTHORITY_PARAGRAPH) |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN')") |
|
|
|
@ApiOperation(value = "Save OAuth2 Client (saveOAuth2Client)", notes = SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH) |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") |
|
|
|
@PostMapping(value = "/oauth2/client") |
|
|
|
public OAuth2Client saveOAuth2Client(@RequestBody @Valid OAuth2Client oAuth2Client) throws Exception { |
|
|
|
TenantId tenantId = getTenantId(); |
|
|
|
@ -114,8 +115,8 @@ public class OAuth2Controller extends BaseController { |
|
|
|
return tbOauth2ClientService.save(oAuth2Client, getCurrentUser()); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "Get OAuth2 Client infos (findTenantOAuth2ClientInfos)", notes = SYSTEM_AUTHORITY_PARAGRAPH) |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN')") |
|
|
|
@ApiOperation(value = "Get OAuth2 Client infos (findTenantOAuth2ClientInfos)", notes = SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH) |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") |
|
|
|
@GetMapping(value = "/oauth2/client/infos") |
|
|
|
public PageData<OAuth2ClientInfo> findTenantOAuth2ClientInfos(@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true) |
|
|
|
@RequestParam int pageSize, |
|
|
|
@ -134,7 +135,7 @@ public class OAuth2Controller extends BaseController { |
|
|
|
|
|
|
|
@ApiOperation(value = "Get OAuth2 Client infos By Ids (findTenantOAuth2ClientInfosByIds)", |
|
|
|
notes = "Fetch OAuth2 Client info objects based on the provided ids. ") |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN')") |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") |
|
|
|
@GetMapping(value = "/oauth2/client/infos", params = {"clientIds"}) |
|
|
|
public List<OAuth2ClientInfo> findTenantOAuth2ClientInfosByIds( |
|
|
|
@Parameter(description = "A list of oauth2 ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true) |
|
|
|
@ -143,8 +144,8 @@ public class OAuth2Controller extends BaseController { |
|
|
|
return oAuth2ClientService.findOAuth2ClientInfosByIds(getTenantId(), oAuth2ClientIds); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "Get OAuth2 Client by id (getOAuth2ClientById)", notes = SYSTEM_AUTHORITY_PARAGRAPH) |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN')") |
|
|
|
@ApiOperation(value = "Get OAuth2 Client by id (getOAuth2ClientById)", notes = SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH) |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") |
|
|
|
@GetMapping(value = "/oauth2/client/{id}") |
|
|
|
public OAuth2Client getOAuth2ClientById(@PathVariable UUID id) throws ThingsboardException { |
|
|
|
OAuth2ClientId oAuth2ClientId = new OAuth2ClientId(id); |
|
|
|
@ -152,8 +153,8 @@ public class OAuth2Controller extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "Delete oauth2 client (deleteOauth2Client)", |
|
|
|
notes = "Deletes the oauth2 client. Referencing non-existing oauth2 client Id will cause an error." + SYSTEM_AUTHORITY_PARAGRAPH) |
|
|
|
@PreAuthorize("hasAuthority('SYS_ADMIN')") |
|
|
|
notes = "Deletes the oauth2 client. Referencing non-existing oauth2 client Id will cause an error." + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH) |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") |
|
|
|
@DeleteMapping(value = "/oauth2/client/{id}") |
|
|
|
public void deleteOauth2Client(@PathVariable UUID id) throws Exception { |
|
|
|
OAuth2ClientId oAuth2ClientId = new OAuth2ClientId(id); |
|
|
|
@ -165,7 +166,7 @@ public class OAuth2Controller extends BaseController { |
|
|
|
"double quotes. After successful authentication with OAuth2 provider, it makes a redirect to this path so that the platform can do " + |
|
|
|
"further log in processing. This URL may be configured as 'security.oauth2.loginProcessingUrl' property in yml configuration file, or " + |
|
|
|
"as 'SECURITY_OAUTH2_LOGIN_PROCESSING_URL' env variable. By default it is '/login/oauth2/code/'" + SYSTEM_AUTHORITY_PARAGRAPH) |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN')") |
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") |
|
|
|
@GetMapping(value = "/oauth2/loginProcessingUrl") |
|
|
|
public String getLoginProcessingUrl() throws ThingsboardException { |
|
|
|
accessControlService.checkPermission(getCurrentUser(), Resource.OAUTH2_CLIENT, Operation.READ); |
|
|
|
|