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

refact(auth): cache login role in auth client to avoid sending rpc repeatedly #1507

Merged
merged 17 commits into from
Jun 25, 2021

Conversation

imbajin
Copy link
Member

@imbajin imbajin commented Jun 17, 2021

before cache:
image

after cache in auth client:
image

Comment on lines 142 to 147
Id usrname = IdGenerator.of(username);
UserRoleCache userRole = this.usersRoleCache.getOrFetch(usrname, r -> {
RolePermission rolePermission = this.graph().authManager()
.loginUser(username, password);
return new UserRoleCache(rolePermission, password);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

prefer to move to hugegraph auth proxy

@codecov
Copy link

codecov bot commented Jun 21, 2021

Codecov Report

Merging #1507 (9dd2e2a) into master (b43ab45) will increase coverage by 0.04%.
The diff coverage is 91.20%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1507      +/-   ##
============================================
+ Coverage     59.63%   59.67%   +0.04%     
- Complexity     6147     6151       +4     
============================================
  Files           410      410              
  Lines         33222    33255      +33     
  Branches       4588     4591       +3     
============================================
+ Hits          19812    19846      +34     
+ Misses        11343    11335       -8     
- Partials       2067     2074       +7     
Impacted Files Coverage Δ
...java/com/baidu/hugegraph/config/ServerOptions.java 100.00% <ø> (ø)
...n/java/com/baidu/hugegraph/config/CoreOptions.java 99.45% <ø> (-0.01%) ⬇️
...om/baidu/hugegraph/auth/StandardAuthenticator.java 41.89% <37.50%> (+0.46%) ⬆️
.../com/baidu/hugegraph/auth/StandardAuthManager.java 96.50% <92.68%> (-1.94%) ⬇️
...va/com/baidu/hugegraph/auth/HugeAuthenticator.java 40.21% <100.00%> (+6.15%) ⬆️
...a/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java 57.97% <100.00%> (+0.61%) ⬆️
.../java/com/baidu/hugegraph/auth/HugePermission.java 80.00% <100.00%> (+1.05%) ⬆️
...n/java/com/baidu/hugegraph/config/AuthOptions.java 96.15% <100.00%> (+3.29%) ⬆️
...va/com/baidu/hugegraph/task/ServerInfoManager.java 71.34% <0.00%> (-2.81%) ⬇️
...ain/java/com/baidu/hugegraph/task/TaskManager.java 70.50% <0.00%> (-1.44%) ⬇️
... and 4 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 b43ab45...9dd2e2a. Read the comment docs.

corgiboygsj and others added 4 commits June 22, 2021 21:00
Also enhance:
- add time strategy to avoid old logs overwriting by current logs
- auto create log folder if it does not exist
- add some comment for auth config

* use strict mode for config property & separate rest configs
* reduce log format length
* Update rest-server.properties
* update all configs (TODO: push to other modules)
…peatedly

TODO: also need be compatible with token way (consider put 'usrname + passwd' together into caches's key)
@imbajin imbajin marked this pull request as ready for review June 24, 2021 11:15
@imbajin imbajin marked this pull request as draft June 24, 2021 11:15
@imbajin imbajin marked this pull request as ready for review June 24, 2021 15:15
…peatedly

fix: don't create Id every time

perf: remove useless toLowerCase

add config for expire time in auth client
@javeme javeme merged commit f22d03f into master Jun 25, 2021
@javeme javeme deleted the cache-auth-client branch June 25, 2021 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants