|
|
|
@ -19,11 +19,15 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
import org.springframework.web.bind.annotation.ResponseStatus; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.thingsboard.server.common.data.exception.ThingsboardException; |
|
|
|
import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo; |
|
|
|
import org.thingsboard.server.common.data.oauth2.OAuth2ClientsParams; |
|
|
|
import org.thingsboard.server.common.data.oauth2.SchemeType; |
|
|
|
import org.thingsboard.server.dao.oauth2.OAuth2Configuration; |
|
|
|
import org.thingsboard.server.queue.util.TbCoreComponent; |
|
|
|
import org.thingsboard.server.service.security.permission.Operation; |
|
|
|
@ -31,6 +35,7 @@ import org.thingsboard.server.service.security.permission.Resource; |
|
|
|
import org.thingsboard.server.utils.MiscUtils; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.util.Enumeration; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@RestController |
|
|
|
@ -46,6 +51,14 @@ public class OAuth2Controller extends BaseController { |
|
|
|
@ResponseBody |
|
|
|
public List<OAuth2ClientInfo> getOAuth2Clients(HttpServletRequest request) throws ThingsboardException { |
|
|
|
try { |
|
|
|
if (log.isDebugEnabled()) { |
|
|
|
log.debug("Executing getOAuth2Clients: [{}][{}][{}]", request.getScheme(), request.getServerName(), request.getServerPort()); |
|
|
|
Enumeration<String> headerNames = request.getHeaderNames(); |
|
|
|
while (headerNames.hasMoreElements()) { |
|
|
|
String header = headerNames.nextElement(); |
|
|
|
log.debug("Header: {} {}", header, request.getHeader(header)); |
|
|
|
} |
|
|
|
} |
|
|
|
return oAuth2Service.getOAuth2Clients(MiscUtils.getScheme(request), MiscUtils.getDomainNameAndPort(request)); |
|
|
|
} catch (Exception e) { |
|
|
|
throw handleException(e); |
|
|
|
|