Causes and countermeasures for logging out of Excel when linking from Excel
When I step on a link from Word or Excel, for some reason I am taken to the login screen. We have also had this problem with learningBOX in the past, but it was resolved in version 2.8.9. We are now disclosing the cause and countermeasure for this problem in case other systems are also suffering from the same problem.
Click here to see the table of contents.
1. symptoms
2. causes
2. countermeasures
3. why was it discovered in the first place?
4. are all the web apps out there coping with it?
Symptoms
While logged in to a certain system, when I open a URL in the system from Word or Excel, I am redirected to the login screen.
Since the user is already logged in, we would like to have the URL in the system opened directly.
Cause
In Word or Excel, when you click on a link, Word or Excel sends a request to that link address; Word or Excel receives a response that redirects you to the login page because you are not logged in to the linked site. This redirect URL is passed to the web browser, which causes a transition to the login page.
Countermeasures
When a request for the post-login page is received from Word or Excel, do not perform redirect processing. By doing so, the specified URL is passed to the web browser as is, and the post-login page can be opened. In the figure above, it is enough to change the processing at point (2).
If you are using PHP, you can use the following code to handle this issue. exit may have side effects, so please terminate the process in accordance with your framework's style. If you return an empty document with a status code of 200, it is almost OK.
How was it discovered in the first place?
One of our customers distributes URLs for educational materials via Excel, and for some reason, when he steps on the link, he is taken to the login screen. Since there is no special exception handling only when opening from Excel, we investigated the cause of the problem by referring to the web server logs, etc., and found that the problem was caused by strange behavior of Office.
Are all the web apps in the world coping with this?
As of January 14, 2020, Gmail and Slack have been addressed, but there are many services that everyone knows about that have not been addressed. This is not so much a problem on the web application side as it is a problem with the behavior of Office, but it can be easily handled using the method described above, so please consider taking action.