paascloud/paascloud-master · error · InternalAuthenticationServiceException
无法获取用户信息
Error message
无法获取用户信息
What it means
OpenIdAuthenticationProvider.authenticate throws InternalAuthenticationServiceException('无法获取用户信息') when usersConnectionRepository.findUserIdsConnectedTo returns no userId (or more than one) for the given providerId + openId pair. It means no (or ambiguous) local user is bound to that social account, so authentication cannot proceed.
Solutions
- Ensure the social connection exists: complete the signup/binding flow (AppSingUpUtils.doPostSignUp) so the connection is persisted for this providerId+openid.
- Check the user connection table for rows matching providerId and providerUserId; remove duplicates if userIds.size() != 1.
- Verify the providerId sent by the client matches the one stored when the connection was created.
- Confirm usersConnectionRepository is wired to the correct datasource/table.
- Log authenticationToken.getProviderId() and principal to debug which pair is missing.
Example fix
// before // client logs in with openid directly without binding // after // first bind: POST social signup with deviceId header so AppSingUpUtils persists the Connection, // then retry the openid login with the same providerId/openid
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check binding before login Set<String> ids = usersConnectionRepository.findUserIdsConnectedTo(providerId, Set.of(openId)); boolean bound = ids != null && ids.size() == 1;
Try / catch
try {
authenticationManager.authenticate(openIdToken);
} catch (InternalAuthenticationServiceException e) {
// guide user to signup/binding flow
return redirectToSocialSignUp();
} Prevention
- Complete the bind/signup flow before allowing openid login.
- Enforce unique constraint on (provider_id, provider_user_id).
- Keep deviceId-based cache and DB binding consistent.
When it happens
Trigger: Submitting an OpenIdAuthenticationToken whose providerId/openid combination has no row in the social user-connection table (e.g. UaaConnectionRepository / social_connection), or a data anomaly producing multiple connected userIds for the same providerUserId.
Common situations: User tries openid login before completing signup/binding; the social connection record was deleted or the appSecret/providerId changed; database rows duplicated by repeated connection inserts; deviceId-based caching of the connection was lost before doPostSignUp ran.
Related errors
- UsernameNotFoundException(userId)
- 无法获取用户信息
- Authentication method not supported:
- UsernameNotFoundException(username)
- Authentication method not supported:
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/2f3781efeb301d81.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-common/paascloud-security-app/src/main/java/com/paascloud/security/app/authentication/openid/OpenIdAuthenticationProvider.java:56
* Authenticate authentication.
*
* @param authentication the authentication
*
* @return the authentication
*
* @throws AuthenticationException the authentication exception
*/
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
OpenIdAuthenticationToken authenticationToken = (OpenIdAuthenticationToken) authentication;
Set<String> providerUserIds = new HashSet<>();
providerUserIds.add((String) authenticationToken.getPrincipal());
Set<String> userIds = usersConnectionRepository.findUserIdsConnectedTo(authenticationToken.getProviderId(), providerUserIds);
if (CollectionUtils.isEmpty(userIds) || userIds.size() != 1) {
throw new InternalAuthenticationServiceException("无法获取用户信息");
}
String userId = userIds.iterator().next();
UserDetails user = userDetailsService.loadUserByUserId(userId);
if (user == null) {
throw new InternalAuthenticationServiceException("无法获取用户信息");
}
OpenIdAuthenticationToken authenticationResult = new OpenIdAuthenticationToken(user, user.getAuthorities());
authenticationResult.setDetails(authenticationToken.getDetails());
return authenticationResult;
}
/**View on GitHub (pinned to 781281a950)