Skip to content

Commit

Permalink
fix: Prevent jetty from trying to register ShibbolethLogin (#914)
Browse files Browse the repository at this point in the history
* fix: Prevent jetty from trying to register ShibbolethLogin

as part of the org.jitsi.jicofo.rest package. This was a harmless bug,
resulting in 5XX instead of 404 when serving /login when shibboleth is
disabled.
  • Loading branch information
bgrozev authored Apr 27, 2022
1 parent 7bb3798 commit d8cca3d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.jitsi.jicofo.auth;

import org.jitsi.jicofo.rest.*;
import org.jitsi.jicofo.auth.rest.*;
import org.jitsi.xmpp.extensions.jitsimeet.*;
import org.jivesoftware.smack.packet.*;
import org.jxmpp.jid.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.jicofo.rest;
package org.jitsi.jicofo.auth.rest;

import com.google.common.html.*;
import org.jetbrains.annotations.*;
import org.jitsi.jicofo.auth.*;
import org.jitsi.jicofo.rest.*;
import org.jxmpp.jid.*;
import org.jxmpp.jid.impl.*;
import org.jxmpp.stringprep.*;

import javax.servlet.http.*;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import javax.ws.rs.core.Response;

import static org.apache.commons.lang3.StringUtils.isBlank;

Expand All @@ -40,10 +40,9 @@ public class ShibbolethLogin
*
* @param request <tt>HttpServletRequest</tt> instance used to obtain
* Shibboleth attributes.
* @param name the name of Shibboleth attribute to get.
*
* @param name the name of Shibboleth attribute to get.
* @return Shibboleth attribute value retrieved from the request or
* <tt>null</tt> if there is no value for given <tt>name</tt>.
* <tt>null</tt> if there is no value for given <tt>name</tt>.
*/
private static String getShibAttr(HttpServletRequest request, String name)
{
Expand All @@ -58,7 +57,7 @@ private static String getShibAttr(HttpServletRequest request, String name)
@NotNull
private final ShibbolethAuthAuthority shibbolethAuthAuthority;

ShibbolethLogin(@NotNull ShibbolethAuthAuthority shibbolethAuthAuthority)
public ShibbolethLogin(@NotNull ShibbolethAuthAuthority shibbolethAuthAuthority)
{
this.shibbolethAuthAuthority = shibbolethAuthAuthority;
}
Expand Down Expand Up @@ -135,38 +134,38 @@ private String createResponse(
// Store session-id script
String script =
"<script>\n" +
"(function() {\n" +
" var sessionId = '" + sessionId + "';\n" +
" localStorage.setItem('sessionId', sessionId);\n" +
" console.info('sessionID :' + sessionId);\n" +
" var displayName = '" + displayName + "';\n" +
" console.info('displayName :' + displayName);\n" +
" var settings = localStorage.getItem('features/base/settings');\n" +
" console.info('settings :' + settings);\n" +
" if (settings){\n" +
" try {\n" +
" var settingsObj = JSON.parse(settings);\n" +
" if ( settingsObj && !settingsObj.displayName ) {\n" +
" settingsObj.displayName = displayName;\n" +
" localStorage.setItem('features/base/settings', JSON.stringify(settingsObj));\n" +
" }\n" +
" }\n" +
" catch(e){\n" +
" console.error('Unable to parse settings JSON');\n" +
" }\n" +
" }\n" ;
"(function() {\n" +
" var sessionId = '" + sessionId + "';\n" +
" localStorage.setItem('sessionId', sessionId);\n" +
" console.info('sessionID :' + sessionId);\n" +
" var displayName = '" + displayName + "';\n" +
" console.info('displayName :' + displayName);\n" +
" var settings = localStorage.getItem('features/base/settings');\n" +
" console.info('settings :' + settings);\n" +
" if (settings){\n" +
" try {\n" +
" var settingsObj = JSON.parse(settings);\n" +
" if ( settingsObj && !settingsObj.displayName ) {\n" +
" settingsObj.displayName = displayName;\n" +
" localStorage.setItem('features/base/settings', JSON.stringify(settingsObj));\n" +
" }\n" +
" }\n" +
" catch(e){\n" +
" console.error('Unable to parse settings JSON');\n" +
" }\n" +
" }\n";
if (close)
{
// Pass session id and close the popup
script += "var opener = window.opener;\n"+
"if (opener) {\n"+
script += "var opener = window.opener;\n" +
"if (opener) {\n" +
" var res = opener.postMessage(" +
" { sessionId: sessionId },\n" +
" window.opener.location.href);\n"+
" window.opener.location.href);\n" +
" console.info('res: ', res);\n" +
" window.close();\n"+
" window.close();\n" +
"} else {\n" +
" console.error('No opener !');\n"+
" console.error('No opener !');\n" +
"}\n";
}
else
Expand All @@ -182,7 +181,6 @@ private String createResponse(
return sb.toString();
}
}

class BadRequestExceptionWithMessage extends BadRequestException
{
public BadRequestExceptionWithMessage(String message)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jitsi/jicofo/rest/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.glassfish.jersey.server.*;
import org.jetbrains.annotations.*;
import org.jitsi.jicofo.auth.*;
import org.jitsi.jicofo.auth.rest.*;
import org.jitsi.jicofo.health.*;
import org.jitsi.utils.version.*;

Expand Down

0 comments on commit d8cca3d

Please sign in to comment.