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

chore(server): clear context after req done #2470

Merged
merged 28 commits into from
Mar 19, 2024

Conversation

SunnyBoy-WYH
Copy link
Contributor

@SunnyBoy-WYH SunnyBoy-WYH commented Mar 3, 2024

Note

complete the history todo

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. api Changes of API labels Mar 3, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Mar 6, 2024
Copy link

codecov bot commented Mar 8, 2024

Codecov Report

Attention: Patch coverage is 58.62069% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 66.25%. Comparing base (c09982b) to head (5817ccd).
Report is 1 commits behind head on master.

Files Patch % Lines
...che/hugegraph/api/filter/AuthenticationFilter.java 47.36% 5 Missing and 5 partials ⚠️
...g/apache/hugegraph/api/filter/AccessLogFilter.java 66.66% 0 Missing and 1 partial ⚠️
...org/apache/hugegraph/auth/ConfigAuthenticator.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2470      +/-   ##
============================================
- Coverage     66.34%   66.25%   -0.09%     
+ Complexity      829      827       -2     
============================================
  Files           511      511              
  Lines         42624    42631       +7     
  Branches       5947     5948       +1     
============================================
- Hits          28278    28246      -32     
- Misses        11541    11563      +22     
- Partials       2805     2822      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

imbajin
imbajin previously approved these changes Mar 9, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 9, 2024

RestClient arthasApiClientWithAuth = new RestClient(ARTHAS_API_BASE_URL);
r = arthasApiClientWithAuth.post(ARTHAS_API_PATH, body);
assertResponseStatus(401, r);
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 add some negative test cases

"versions",
"openapi.json"
);
private static final AntPathMatcher MATCHER = new AntPathMatcher();
// Remove auth/login API from white list
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to make sure the login api is accessible, it's used to get a user token.
and also update the comment after checked.

Copy link
Member

@imbajin imbajin Mar 10, 2024

Choose a reason for hiding this comment

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

we need to make sure the login api is accessible, it's used to get a user token. and also update the comment after checked.

@javeme Some context for the modification:

  1. When we unset-context in AccessLogFilter, the CI will fail in login when(login) whiteList exist (refer CI link)
image
  1. follow the login API input param & the validate logic
image
  1. login is only used for hubble, and if we need set whitelist for login.jsp(to make user visit it without auth) , seems we should set it in hubble rather than set it in Graph/AuthServer -> AuthFilter, and after we remove the login API from the whitelist, the login is fine now

Copy link
Contributor

Choose a reason for hiding this comment

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

Because the login method itself will authenticate the user, there is no need to authenticate twice. Of course, it seems there is no problem when authenticating twice.

Copy link
Member

Choose a reason for hiding this comment

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

  1. the CI will fail in login when(login) whiteList exist (refer CI link)

@javeme Yes, but after we fix the TLS leak, the login/tests can't run well if we only check auth once in LoginAPI, and we'll dig it out the reason, cc @SunnyBoy-WYH mark it as a TODO issue

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 13, 2024
"versions",
"openapi.json"
);
private static final AntPathMatcher MATCHER = new AntPathMatcher();
// Remove auth/login API from white list
Copy link
Contributor

Choose a reason for hiding this comment

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

Because the login method itself will authenticate the user, there is no need to authenticate twice. Of course, it seems there is no problem when authenticating twice.

Copy link
Member

@imbajin imbajin left a comment

Choose a reason for hiding this comment

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

Mark some todo & merge this PR first (arthas test will enhance in #2429

@imbajin imbajin requested a review from VGalaxies March 19, 2024 07:56
@VGalaxies VGalaxies merged commit 277f76e into apache:master Mar 19, 2024
19 of 21 checks passed
@VGalaxies VGalaxies changed the title chore(server): clear context after req done chore(server): clear context after req done Mar 19, 2024
VGalaxies pushed a commit that referenced this pull request Mar 19, 2024
Co-authored-by: vaughn.zhang <vaughn.zhang@zoom.us>
Co-authored-by: imbajin <jin@apache.org>
@@ -107,7 +107,7 @@ default User authenticate(final Map<String, String> credentials)
}

HugeGraphAuthProxy.logUser(user, credentials.get(KEY_PATH));
// Set authentication context & unset in AccessLogFilter
// TODO: Ensure context lifecycle in GraphServer & AuthServer(#AccessLogFilter)
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need TODO mark anymore since it's done

@@ -76,7 +76,7 @@ public class AuthenticationFilter implements ContainerRequestFilter {
"versions",
"openapi.json"
);
// Remove auth/login API from white list
/** Remove auth/login API from whitelist */
Copy link
Contributor

Choose a reason for hiding this comment

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

one * is ok

@@ -122,7 +122,7 @@ public void filter(ContainerRequestContext requestContext,

// Unset the context in "HugeAuthenticator", need distinguish Graph/Auth server lifecycle
GraphManager manager = managerProvider.get();
// TODO transfer Authorizer if we need after.
// TODO: transfer Authorizer if we need after.
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need TODO mark anymore since it's done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Changes of API lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants