|
|
|
@ -21,16 +21,13 @@ import org.springframework.security.core.Authentication; |
|
|
|
import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken; |
|
|
|
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.thingsboard.server.common.data.id.CustomerId; |
|
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
|
import org.thingsboard.server.dao.oauth2.OAuth2Client; |
|
|
|
import org.thingsboard.server.dao.oauth2.OAuth2Configuration; |
|
|
|
import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository; |
|
|
|
import org.thingsboard.server.service.security.model.SecurityUser; |
|
|
|
import org.thingsboard.server.service.security.model.token.JwtToken; |
|
|
|
import org.thingsboard.server.service.security.model.token.JwtTokenFactory; |
|
|
|
import org.thingsboard.server.service.security.system.SystemSecurityService; |
|
|
|
import org.thingsboard.server.utils.MiscUtils; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
@ -46,26 +43,23 @@ public class Oauth2AuthenticationSuccessHandler extends SimpleUrlAuthenticationS |
|
|
|
private final RefreshTokenRepository refreshTokenRepository; |
|
|
|
private final OAuth2ClientMapperProvider oauth2ClientMapperProvider; |
|
|
|
private final OAuth2Configuration oauth2Configuration; |
|
|
|
private final SystemSecurityService systemSecurityService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
public Oauth2AuthenticationSuccessHandler(final JwtTokenFactory tokenFactory, |
|
|
|
final RefreshTokenRepository refreshTokenRepository, |
|
|
|
final OAuth2ClientMapperProvider oauth2ClientMapperProvider, |
|
|
|
final OAuth2Configuration oauth2Configuration, SystemSecurityService systemSecurityService) { |
|
|
|
final OAuth2Configuration oauth2Configuration) { |
|
|
|
this.tokenFactory = tokenFactory; |
|
|
|
this.refreshTokenRepository = refreshTokenRepository; |
|
|
|
this.oauth2ClientMapperProvider = oauth2ClientMapperProvider; |
|
|
|
this.oauth2Configuration = oauth2Configuration; |
|
|
|
this.systemSecurityService = systemSecurityService; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onAuthenticationSuccess(HttpServletRequest request, |
|
|
|
HttpServletResponse response, |
|
|
|
Authentication authentication) throws IOException { |
|
|
|
|
|
|
|
String baseUrl = systemSecurityService.getBaseUrl(TenantId.SYS_TENANT_ID, new CustomerId(EntityId.NULL_UUID), request); |
|
|
|
String baseUrl = MiscUtils.constructBaseUrl(request); |
|
|
|
try { |
|
|
|
OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) authentication; |
|
|
|
|
|
|
|
|