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

[AMORO-3038] Unify the API set for dashboard and open API #3244

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

mansonliwh
Copy link
Contributor

Why are the changes needed?

Close #3038.

Brief change log

Unify the API set for both dashboard and Open API in the same url [ /api/ams/v1 ].

Previously, frontend requests and external interface requests were distinguished by using the paths ams/v1 and api/ams/v1 respectively. Frontend requests required cookie validation for login status, while external interface requests needed to pass an apikey parameter for verification. In this design, the request paths from both sources are unified to api/ams/v1. For frontend requests, an additional header parameter X-Request-Source: frontend will be included. This allows the source of the request to be distinguished and routed to different validation logic accordingly.

How was this patch tested?

  • [ ☑️ ] Add screenshots for manual tests if appropriate
    image

  • [ ☑️ ] Run test locally before making a pull request

@github-actions github-actions bot added module:ams-server Ams server module module:ams-dashboard Ams dashboard module labels Oct 12, 2024
@mansonliwh mansonliwh force-pushed the feature-unifyapi branch 2 times, most recently from 9f2aaed to 90dbee5 Compare October 12, 2024 07:20
Copy link
Contributor

@czy006 czy006 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. Do we have any relevant documents. should we introduce Swagger and related SDK in other PR?

@mansonliwh
Copy link
Contributor Author

Thank you for your contribution. Do we have any relevant documents. should we introduce Swagger and related SDK in other PR?

After merging, I will continue to improve this part of the functionality in a new PR.

Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your work.
I left a small suggestion, PTAL.

@@ -355,7 +354,8 @@ private EndpointGroup apiGroup() {

public void preHandleRequest(Context ctx) {
String uriPath = ctx.path();
if (needApiKeyCheck(uriPath)) {
String requestSource = ctx.header("X-Request-Source");
if (needApiKeyCheck(uriPath) && !"frontend".equals(requestSource)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is Web a proper name for requests from the front end?

And we may better declare a static final variable for it, and the same to X-Request-Source

Copy link
Contributor Author

@mansonliwh mansonliwh Oct 14, 2024

Choose a reason for hiding this comment

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

Thank you for your reasonable suggestions. I will optimize the code accordingly.

Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

LGTM.

Thanks a lot for pushing forward this improvement!

@zhoujinsong zhoujinsong merged commit d1274a9 into apache:master Oct 14, 2024
5 checks passed
@mansonliwh mansonliwh deleted the feature-unifyapi branch October 15, 2024 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:ams-dashboard Ams dashboard module module:ams-server Ams server module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Unify the API set for dashboard and open API
3 participants