-
Notifications
You must be signed in to change notification settings - Fork 299
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
Conversation
9f2aaed
to
90dbee5
Compare
There was a problem hiding this 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?
After merging, I will continue to improve this part of the functionality in a new PR. |
There was a problem hiding this 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)) { |
There was a problem hiding this comment.
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
There was a problem hiding this 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 reasonable suggestions. I will optimize the code accordingly.
90dbee5
to
18b1204
Compare
There was a problem hiding this 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!
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
[ ☑️ ] Run test locally before making a pull request