Comments (6)
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:
-
Modify the
createLocalUser
Method: Adjust the method to ensure that the email attribute is included when creating a new user. Since theUser
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 customUserDetails
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. -
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
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java
- scripts/sql/profiles/mysql-database-not-specified/apolloportaldb.sql
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.
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:
- Confirm that your OIDC provider is configured to include the email address in the user information it supplies.
- 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
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java
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.
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:
-
Implement a Custom
UserDetails
Class: Create a class that extendsUserDetails
and includes fields foremail
anduserDisplayName
. This class will be used to createUserDetails
objects that contain all necessary information. -
Modify the
createLocalUser
Method: Adjust this method to use your customUserDetails
implementation instead of the defaultUser
class. Ensure that it populates theemail
anduserDisplayName
fields based on the information available inUserInfo
.
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
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/UserInfo.java
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.
The issue you're encountering with
OidcLocalUserServiceImpl#createLocalUser
throwing an exception due to a missing email address in theUserPO
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:
- Confirm that your OIDC provider is configured to include the email address in the user information it supplies.
- Ensure your application's OIDC configuration requests the email scope from the OIDC provider.
The method
createLocalUser
inOidcLocalUserServiceImpl
is designed to create a new user with the providedUserInfo
, which should include the email. If the email is not being set, it could lead to theJdbcSQLIntegrityConstraintViolationException
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
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java
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.
The root cause of the
JdbcSQLIntegrityConstraintViolationException
you're encountering is indeed due to thecreateLocalUser
method inOidcLocalUserServiceImpl
not including the email attribute when creating aUserDetails
object. This omission conflicts with your database schema where the 'Email' column is non-null.To address this, you have a couple of options:
- Modify the
createLocalUser
Method: Adjust the method to ensure that the email attribute is included when creating a new user. Since theUser
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 customUserDetails
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.- 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
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcAuthenticationSuccessEventListener.java
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/oidc/OidcLocalUserServiceImpl.java
- scripts/sql/profiles/mysql-database-not-specified/apolloportaldb.sql
About Dosu
Yeah,and the problem also exists in the userDisplayName
attribute.
from apollo.
@vdiskg are you aware of this issue?
from apollo.
Related Issues (20)
- Portal 模块 RestTemplate 支持配置 ConnectionTimeToLive
- apollo2.1.0集成pgsql,求给一份pgsql的sql文件。mysql的不可以用 HOT 4
- 无法删除旧的配置 HOT 7
- 在项目namespace数量比较多的情况下(大约1000个),打开页面加载速度很慢,比较影响用户体验,这个是否有什么优化改进方案? HOT 9
- Apollo是否可以支持按照key维度来发布? HOT 4
- 1.8.0,接入一个app.id 使用多个namespace的时候,多个namesapce均开启了accesskey.sercet,这时候接入的配置代码要怎么写呢 HOT 3
- 麻烦问下,有什么办法能同时读到多个环境同一个配置的值吗? HOT 5
- 使用客户端添加string类型的配置项时会报错 HOT 3
- 配置从 2.1.0导出,导入到 2.2.0,数据中时间解析失败 HOT 1
- 在 apollo-portal统一增加访问路径的前缀/apollo 时,导入配置的请求url 有部分没有添加前缀 HOT 3
- apollo-portal 使用统一前缀/apollo以后,创建集群失败 HOT 2
- k8s部署apollo 接入ldap报错 HOT 3
- 请问有大佬已经在2.2.0版本上,数据源由mysql切换至pg了嘛? HOT 2
- 脚本启动与停止的问题 HOT 3
- 删除App后,相似的AppID权限异常,并无法恢复 HOT 4
- dockerfile基础镜像漏洞 HOT 4
- 使用docker安装apollo 镜像里面的demo.sh缺少读取环境变量的逻辑 HOT 2
- yml读取k-v的值错误 HOT 2
- Beautify Portal TraceLog UI interface
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo.