Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Oidc preferred username #3629

Merged
merged 42 commits into from
May 25, 2021

Conversation

vdiskg
Copy link
Contributor

@vdiskg vdiskg commented Apr 4, 2021

What's the purpose of this PR

add a human readable username for oidc user

Which issue(s) this PR fixes:

Fixes #3625

@codecov-io
Copy link

codecov-io commented Apr 4, 2021

Codecov Report

Merging #3629 (7850814) into master (3de1d72) will decrease coverage by 0.50%.
The diff coverage is 4.50%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3629      +/-   ##
============================================
- Coverage     50.97%   50.47%   -0.51%     
- Complexity     2329     2330       +1     
============================================
  Files           449      451       +2     
  Lines         14026    14178     +152     
  Branches       1426     1448      +22     
============================================
+ Hits           7150     7156       +6     
- Misses         6389     6536     +147     
+ Partials        487      486       -1     
Impacted Files Coverage Δ Complexity Δ
.../com/ctrip/framework/apollo/common/dto/AppDTO.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...com/ctrip/framework/apollo/common/dto/BaseDTO.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ork/apollo/common/utils/PreferredUsernameUtil.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...work/apollo/portal/entity/bo/ReleaseHistoryBO.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...trip/framework/apollo/portal/entity/po/UserPO.java 4.16% <0.00%> (-0.60%) 1.00 <0.00> (ø)
...ctrip/framework/apollo/portal/spi/UserService.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...lo/portal/spi/configuration/AuthConfiguration.java 5.55% <0.00%> (ø) 2.00 <0.00> (ø)
...i/oidc/OidcAuthenticationSuccessEventListener.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ollo/portal/spi/oidc/OidcLocalUserServiceImpl.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
.../spi/springsecurity/SpringSecurityUserService.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3de1d72...7850814. Read the comment docs.

@nobodyiam
Copy link
Member

For oidc implementation, is it possible to follow the similar implementation of LdapUserService and CtripUserService to query the backend service when searching the users? So that no user info should be stored in local db and the user name could be retrieved on the fly.

https://github.com/ctripcorp/apollo/blob/943bbb4d56bd9d3bbec291ea17136099a3a60b7c/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java#L122-L129

https://github.com/ctripcorp/apollo/blob/943bbb4d56bd9d3bbec291ea17136099a3a60b7c/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/CtripUserService.java#L100-L106

@vdiskg
Copy link
Contributor Author

vdiskg commented Apr 5, 2021

For oidc implementation, is it possible to follow the similar implementation of LdapUserService and CtripUserService to query the backend service when searching the users? So that no user info should be stored in local db and the user name could be retrieved on the fly.

https://github.com/ctripcorp/apollo/blob/943bbb4d56bd9d3bbec291ea17136099a3a60b7c/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java#L122-L129

https://github.com/ctripcorp/apollo/blob/943bbb4d56bd9d3bbec291ea17136099a3a60b7c/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/CtripUserService.java#L100-L106

it seems impossible because there is no standard way to search users in the oidc scheme. some oidc provider such as keycloak, provided it's custom admin sdk for search users, while others like okta is not even provide a way to search users.

Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great effort, it looks much better!
Please find the latest comments below.

@@ -284,6 +284,7 @@ CREATE TABLE `Users` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
`Username` varchar(64) NOT NULL DEFAULT 'default' COMMENT '用户名',
`Password` varchar(64) NOT NULL DEFAULT 'default' COMMENT '密码',
`PreferredUsername` varchar(512) NOT NULL DEFAULT 'default' COMMENT '用户名称',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we agree on this, then we may also update the variable names in the programs. I understand it will cause a big refactoring but I think it's worth to clarify the concept.

@github-actions
Copy link

github-actions bot commented May 15, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@vdiskg
Copy link
Contributor Author

vdiskg commented May 15, 2021

I have read the CLA Document and I hereby sign the CLA

@vdiskg
Copy link
Contributor Author

vdiskg commented May 15, 2021

recheck

@@ -0,0 +1,22 @@
package com.ctrip.framework.apollo.portal.enricher;

import com.ctrip.framework.apollo.common.dto.BaseDTO;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the unused imports

/**
* @author vdisk <vdisk@foxmail.com>
*/
public interface UserInfoEnrichedAdapter {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This abstraction looks good to me.

@nobodyiam
Copy link
Member

@vdisk-group please check your email account (***@foxmail.com), there should be an invitation mail.

@nobodyiam nobodyiam added this to the 1.9.0 milestone May 23, 2021
Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nobodyiam nobodyiam merged commit 150955f into apolloconfig:master May 25, 2021
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2021
@vdiskg vdiskg deleted the oidc-preferred-username branch June 27, 2021 08:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Username is not corrected with ocdi user's subject
4 participants