[ZEPPELIN-6366] Separate WebSocket max message size into a dedicated REST API #5099
Perhaps we could remove this.
Requested changes.
@tbonelee
Thanks, I've removed.
I don't know if we should also adapt zeppelin-web? What do you think?
@Reamer Looks reasonable for zeppelin-web too. Are there specific concerns you’re considering, such as maintenance or behavior differences?
@seung-00
(If we also apply this to zeppelin-web.)
There is a failing test in zeppelin-integration(test-selenium-with-spark-module-for-spark-3-5 CI job).
After a quick note: in zeppelin-web's NoteImportCtrl, wsMaxMessageSize is called even when the user is not logged in.
The server then returns a 302 redirect to /api/login (shiro.loginUrl). When the login API responds with 405, the HTTP interceptor emits session_logout (https://github.com/apache/zeppelin/blob/f1f671394dc742ec35ede32be039850cdf8a1145/zeppelin-web/src/app/app.js#L170). The login controller listens for session_logout and programmatically clicks the login button (.nav-login-btn).
As a result, the login modal pops up immediately when the window opens, which is different from before, and the integration test fails.
It looks like we should change this to issue the API request only when the user is authenticated, or defer it until the moment it is actually needed.
@Reamer Looks reasonable for zeppelin-web too. Are there specific concerns you’re considering, such as maintenance or behavior differences?
Yes both. All frontends should use the same interfaces. This makes it easier to remove things later on.
@Reamer
In this case I applied it to both, as you mentioned, to make it easier to remove unreferenced things later on.
But I don’t think we need to do that for every task. Covering both sides would be a bit tricky, since the front-end codebases are quite different.
@tbonelee
I fixed the issue you mentioned.
If the CI failed due to the login modal, I think the CI job might need to be adjusted instead, because the wsMaxMessageSize API doesn’t require authentication.
However, I found that wsMaxMessageSize was being called and cached initially (same as before), but the field only needed in specific cases (e.g., exporting/importing note). So I modified it to be called only when required, now the CI error no longer occurs.
BTW, if the user isn’t logged in initially, showing the login modal seems more natural. 🤔
I added a sleep because the test was failing intermittently.
import { NgModule } from '@angular/core';
import { TicketService } from '@zeppelin/services';
Everything seems right but the unused imports should be removed.
LGTM. I also agree with showing a login modal when authentication is required. Maybe we could address that in another issue.
You have changed the path of the API class here. Probably so that the call is /api/wsMaxMessageSize. However, I also think /api/configurations/wsMaxMessageSize is very good and would prefer this API endpoint.
But I don’t think we need to do that for every task. Covering both sides would be a bit tricky, since the front-end codebases are quite different.
Sooner or later, we should send the old front end into well-deserved retirement. In my opinion, sooner rather than later.
@Reamer
I also think the path you mentioned looks good. However, since the authentication referenced in shiro.ini appears to be set up based on the /configuration path, I excluded /configurations from the path. The wsMaxMessageSize API is intended to be a non-authenticated API.
Please feel free to let me know if you have any other suggestions. 🤔
@Reamer
Would you mind taking a look at this?
The issue this PR addresses, configuration data being accessible via WebSocket without a permission check because of the wsMaxMessageSize field, seems to be a clear problem that needs to be fixed.
Hi @seung-00 ,
Thank you for bringing this issue to my attention again.
As I see it, we have the following options.
1) We include the path /api/configurations/wsMaxMessageSize in shiro.ini and give unauthenticated users the right to call this endpoint.
This would be a breaking change.
2) We add a new path, but it would also have to contain something related to configuration in the path, e.g., /api/configuration/wsMaxMessageSize (without s). The entire API endpoint would then also have to be mapped to a new class.
The shiro.ini would also have to be adjusted here, and that would also be a breaking change.
What bothers me about 1) is that potentially new frontend configuration options would also have to be added to the shiro.ini.
What bothers me about 2) is that it's quite confusing, but you probably only need to adjust the shiro.ini once.
What do you think about creating a general endpoint for frontend configurations? With this pull request, it's wsMaxMessageSize, tomorrow it might be something else. Then you could build the whole thing in the ConfigurationsRestApi and use frontend-config or something else as the endpoint path. You would only have to adjust shiro.ini once and extend the map that the endpoint returns.
Either way, this change would be a breaking change, since the shiro.ini, for example, is very variable.
See: https://github.com/apache/zeppelin/blob/master/conf/shiro.ini.template#L129-L130
@Reamer @tbonelee
As Reamer suggested, I changed the endpoint to a general configuration API for the frontend. As a result, this PR includes a breaking change in shiro.ini.template.
Thanks for great suggestions and sorry for the one-year delay.
We should set $scope.maxLimit value to tell users the max file size.
<img width="557" height="446" alt="Image" src="https://github.com/user-attachments/assets/b44e9401-c5c7-43c1-a8dc-43a3c557938e" />
Requested changes.
@tbonelee
Thanks for the comment. I’ve updated this part.
Approved these changes.
@Reamer
Could you review it again?
The backend part looks good.
Thanks for your work. I merged this PR into the master branch only, since it introduces a breaking change to the authorization behavior.
tbonelee
seung-00
What is this PR for?
Currently, configuration data is fetched through both REST API and WebSocket channels. However, the WebSocket path does not perform permission checks, and the only required data from it is the WebSocket max message size.
I extracted the websocket max message size field into a dedicated REST API, to improve security and simplify configuration handling.
What type of PR is it?
Improvement
Todos
[ ] #5060
What is the Jira issue?
Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/6366
How should this be tested?
Screenshots (if appropriate)
Questions:
Does the license files need to update? N
Is there breaking changes for older versions? Y