Coder Social home page Coder Social logo

Comments (6)

dosubot avatar dosubot commented on June 11, 2024 4

The root cause of the JdbcSQLIntegrityConstraintViolationException you're encountering is indeed due to the createLocalUser method in OidcLocalUserServiceImpl not including the email attribute when creating a UserDetails object. This omission conflicts with your database schema where the 'Email' column is non-null.

To address this, you have a couple of options:

  1. Modify the createLocalUser Method: Adjust the method to ensure that the email attribute is included when creating a new user. Since the User class from Spring Security used here doesn't support an email field directly, you might need to extend it or use a different approach to include the email information. This could involve creating a custom UserDetails implementation that includes email or ensuring that the email is set in a subsequent step that can handle the database's non-null constraint for the email column.

  2. Database Schema Adjustment: Another approach could be to modify your database schema to allow the 'Email' column to be null temporarily, ensuring that the user creation process does not fail. Then, ensure that the email is updated immediately after the user is created. This approach, however, might not be ideal if the email attribute is critical for every user from the start.

Given the structure of your application and the constraints of your database, the first option might be more aligned with ensuring data integrity and consistency. It would require a closer look at how UserDetails is created and possibly customizing this process to include all necessary attributes from the start.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

from apollo.

dosubot avatar dosubot commented on June 11, 2024 2

The issue you're encountering with OidcLocalUserServiceImpl#createLocalUser throwing an exception due to a missing email address in the UserPO entity appears to be related to how the OIDC user information is handled, particularly regarding the email attribute. This situation suggests that the OIDC provider might not be supplying an email address, or the application is not correctly configured to request or handle this attribute.

To address this, you should:

  1. Confirm that your OIDC provider is configured to include the email address in the user information it supplies.
  2. Ensure your application's OIDC configuration requests the email scope from the OIDC provider.

The method createLocalUser in OidcLocalUserServiceImpl is designed to create a new user with the provided UserInfo, which should include the email. If the email is not being set, it could lead to the JdbcSQLIntegrityConstraintViolationException due to the email column being non-null in your database schema.

If after verifying the OIDC provider configuration and your application's request for the email scope the problem persists, it might indicate a need to debug the application further to understand why the email attribute is not being correctly processed or populated.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

from apollo.

dosubot avatar dosubot commented on June 11, 2024 2

To resolve the issue with createLocalUser in OidcLocalUserServiceImpl not including email and userDisplayName attributes, leading to a JdbcSQLIntegrityConstraintViolationException, you'll need to ensure these attributes are included when creating a UserDetails object. The default User class from Spring Security doesn't support these additional fields directly, so you might consider creating a custom UserDetails implementation that includes email and userDisplayName.

Here's a brief outline of what you could do:

  1. Implement a Custom UserDetails Class: Create a class that extends UserDetails and includes fields for email and userDisplayName. This class will be used to create UserDetails objects that contain all necessary information.

  2. Modify the createLocalUser Method: Adjust this method to use your custom UserDetails implementation instead of the default User class. Ensure that it populates the email and userDisplayName fields based on the information available in UserInfo.

Here is a conceptual example of how the adjusted createLocalUser method might look:

@Transactional(rollbackFor = Exception.class)
@Override
public void createLocalUser(UserInfo newUserInfo) {
  CustomUserDetails user = new CustomUserDetails(newUserInfo.getUserId(),
      this.placeholderDelegatingPasswordEncoder.encode(""), newUserInfo.getEmail(), newUserInfo.getName(), authorities);
  userDetailsManager.createUser(user);
  this.updateUserInfoInternal(newUserInfo);
}

In this example, CustomUserDetails is your new class that includes the additional attributes. This approach ensures that the user creation process aligns with your database schema requirements, avoiding exceptions due to missing non-null fields.

Remember, this solution requires you to also adjust any other parts of your application that interact with UserDetails to accommodate the new attributes.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

from apollo.

xyohn avatar xyohn commented on June 11, 2024

The issue you're encountering with OidcLocalUserServiceImpl#createLocalUser throwing an exception due to a missing email address in the UserPO entity appears to be related to how the OIDC user information is handled, particularly regarding the email attribute. This situation suggests that the OIDC provider might not be supplying an email address, or the application is not correctly configured to request or handle this attribute.

To address this, you should:

  1. Confirm that your OIDC provider is configured to include the email address in the user information it supplies.
  2. Ensure your application's OIDC configuration requests the email scope from the OIDC provider.

The method createLocalUser in OidcLocalUserServiceImpl is designed to create a new user with the provided UserInfo, which should include the email. If the email is not being set, it could lead to the JdbcSQLIntegrityConstraintViolationException due to the email column being non-null in your database schema.

If after verifying the OIDC provider configuration and your application's request for the email scope the problem persists, it might indicate a need to debug the application further to understand why the email attribute is not being correctly processed or populated.

Sources

About Dosu

It is not up to UserInfo,because JdbcUserDetailsManager.createUser need UserDetails,which is created in OidcLocalUserServiceImpl#createLocalUser.

    UserDetails user = new User(newUserInfo.getUserId(),
        this.placeholderDelegatingPasswordEncoder.encode(""), authorities);

The object user does not have the attribute email,which I think this is one of the reasons why cause the JdbcSQLIntegrityConstraintViolationException.

from apollo.

xyohn avatar xyohn commented on June 11, 2024

The root cause of the JdbcSQLIntegrityConstraintViolationException you're encountering is indeed due to the createLocalUser method in OidcLocalUserServiceImpl not including the email attribute when creating a UserDetails object. This omission conflicts with your database schema where the 'Email' column is non-null.

To address this, you have a couple of options:

  1. Modify the createLocalUser Method: Adjust the method to ensure that the email attribute is included when creating a new user. Since the User class from Spring Security used here doesn't support an email field directly, you might need to extend it or use a different approach to include the email information. This could involve creating a custom UserDetails implementation that includes email or ensuring that the email is set in a subsequent step that can handle the database's non-null constraint for the email column.
  2. Database Schema Adjustment: Another approach could be to modify your database schema to allow the 'Email' column to be null temporarily, ensuring that the user creation process does not fail. Then, ensure that the email is updated immediately after the user is created. This approach, however, might not be ideal if the email attribute is critical for every user from the start.

Given the structure of your application and the constraints of your database, the first option might be more aligned with ensuring data integrity and consistency. It would require a closer look at how UserDetails is created and possibly customizing this process to include all necessary attributes from the start.

Sources

About Dosu

Yeah,and the problem also exists in the userDisplayName attribute.

from apollo.

nobodyiam avatar nobodyiam commented on June 11, 2024

@vdiskg are you aware of this issue?

from apollo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.