|
|
|
@ -39,7 +39,7 @@ import org.thingsboard.server.service.user.cache.UserAuthDetailsCache; |
|
|
|
public class ApiKeyAuthenticationProvider implements org.springframework.security.authentication.AuthenticationProvider { |
|
|
|
|
|
|
|
private final ApiKeyService apiKeyService; |
|
|
|
private final UserAuthDetailsCache userEnabledCache; |
|
|
|
private final UserAuthDetailsCache userAuthDetailsCache; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException { |
|
|
|
@ -67,7 +67,7 @@ public class ApiKeyAuthenticationProvider implements org.springframework.securit |
|
|
|
if (apiKey.getExpirationTime() != 0 && apiKey.getExpirationTime() < System.currentTimeMillis()) { |
|
|
|
throw new CredentialsExpiredException("API key is expired"); |
|
|
|
} |
|
|
|
UserAuthDetails userAuthDetails = userEnabledCache.findUserEnabled(apiKey.getTenantId(), apiKey.getUserId()); |
|
|
|
UserAuthDetails userAuthDetails = userAuthDetailsCache.findUserEnabled(apiKey.getTenantId(), apiKey.getUserId()); |
|
|
|
if (userAuthDetails == null) { |
|
|
|
throw new UsernameNotFoundException("User with credentials not found"); |
|
|
|
} |
|
|
|
|