Skip to content

Commit d8cca3d

Browse files
authored
fix: Prevent jetty from trying to register ShibbolethLogin (#914)
* 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.
1 parent 7bb3798 commit d8cca3d

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed

src/main/java/org/jitsi/jicofo/auth/ShibbolethAuthAuthority.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
package org.jitsi.jicofo.auth;
1919

20-
import org.jitsi.jicofo.rest.*;
20+
import org.jitsi.jicofo.auth.rest.*;
2121
import org.jitsi.xmpp.extensions.jitsimeet.*;
2222
import org.jivesoftware.smack.packet.*;
2323
import org.jxmpp.jid.*;

src/main/java/org/jitsi/jicofo/rest/ShibbolethLogin.java renamed to src/main/java/org/jitsi/jicofo/auth/rest/ShibbolethLogin.java

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.jitsi.jicofo.rest;
16+
package org.jitsi.jicofo.auth.rest;
1717

1818
import com.google.common.html.*;
1919
import org.jetbrains.annotations.*;
2020
import org.jitsi.jicofo.auth.*;
21+
import org.jitsi.jicofo.rest.*;
2122
import org.jxmpp.jid.*;
2223
import org.jxmpp.jid.impl.*;
2324
import org.jxmpp.stringprep.*;
2425

2526
import javax.servlet.http.*;
2627
import javax.ws.rs.*;
2728
import javax.ws.rs.core.*;
28-
import javax.ws.rs.core.Response;
2929

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

@@ -40,10 +40,9 @@ public class ShibbolethLogin
4040
*
4141
* @param request <tt>HttpServletRequest</tt> instance used to obtain
4242
* Shibboleth attributes.
43-
* @param name the name of Shibboleth attribute to get.
44-
*
43+
* @param name the name of Shibboleth attribute to get.
4544
* @return Shibboleth attribute value retrieved from the request or
46-
* <tt>null</tt> if there is no value for given <tt>name</tt>.
45+
* <tt>null</tt> if there is no value for given <tt>name</tt>.
4746
*/
4847
private static String getShibAttr(HttpServletRequest request, String name)
4948
{
@@ -58,7 +57,7 @@ private static String getShibAttr(HttpServletRequest request, String name)
5857
@NotNull
5958
private final ShibbolethAuthAuthority shibbolethAuthAuthority;
6059

61-
ShibbolethLogin(@NotNull ShibbolethAuthAuthority shibbolethAuthAuthority)
60+
public ShibbolethLogin(@NotNull ShibbolethAuthAuthority shibbolethAuthAuthority)
6261
{
6362
this.shibbolethAuthAuthority = shibbolethAuthAuthority;
6463
}
@@ -135,38 +134,38 @@ private String createResponse(
135134
// Store session-id script
136135
String script =
137136
"<script>\n" +
138-
"(function() {\n" +
139-
" var sessionId = '" + sessionId + "';\n" +
140-
" localStorage.setItem('sessionId', sessionId);\n" +
141-
" console.info('sessionID :' + sessionId);\n" +
142-
" var displayName = '" + displayName + "';\n" +
143-
" console.info('displayName :' + displayName);\n" +
144-
" var settings = localStorage.getItem('features/base/settings');\n" +
145-
" console.info('settings :' + settings);\n" +
146-
" if (settings){\n" +
147-
" try {\n" +
148-
" var settingsObj = JSON.parse(settings);\n" +
149-
" if ( settingsObj && !settingsObj.displayName ) {\n" +
150-
" settingsObj.displayName = displayName;\n" +
151-
" localStorage.setItem('features/base/settings', JSON.stringify(settingsObj));\n" +
152-
" }\n" +
153-
" }\n" +
154-
" catch(e){\n" +
155-
" console.error('Unable to parse settings JSON');\n" +
156-
" }\n" +
157-
" }\n" ;
137+
"(function() {\n" +
138+
" var sessionId = '" + sessionId + "';\n" +
139+
" localStorage.setItem('sessionId', sessionId);\n" +
140+
" console.info('sessionID :' + sessionId);\n" +
141+
" var displayName = '" + displayName + "';\n" +
142+
" console.info('displayName :' + displayName);\n" +
143+
" var settings = localStorage.getItem('features/base/settings');\n" +
144+
" console.info('settings :' + settings);\n" +
145+
" if (settings){\n" +
146+
" try {\n" +
147+
" var settingsObj = JSON.parse(settings);\n" +
148+
" if ( settingsObj && !settingsObj.displayName ) {\n" +
149+
" settingsObj.displayName = displayName;\n" +
150+
" localStorage.setItem('features/base/settings', JSON.stringify(settingsObj));\n" +
151+
" }\n" +
152+
" }\n" +
153+
" catch(e){\n" +
154+
" console.error('Unable to parse settings JSON');\n" +
155+
" }\n" +
156+
" }\n";
158157
if (close)
159158
{
160159
// Pass session id and close the popup
161-
script += "var opener = window.opener;\n"+
162-
"if (opener) {\n"+
160+
script += "var opener = window.opener;\n" +
161+
"if (opener) {\n" +
163162
" var res = opener.postMessage(" +
164163
" { sessionId: sessionId },\n" +
165-
" window.opener.location.href);\n"+
164+
" window.opener.location.href);\n" +
166165
" console.info('res: ', res);\n" +
167-
" window.close();\n"+
166+
" window.close();\n" +
168167
"} else {\n" +
169-
" console.error('No opener !');\n"+
168+
" console.error('No opener !');\n" +
170169
"}\n";
171170
}
172171
else
@@ -182,7 +181,6 @@ private String createResponse(
182181
return sb.toString();
183182
}
184183
}
185-
186184
class BadRequestExceptionWithMessage extends BadRequestException
187185
{
188186
public BadRequestExceptionWithMessage(String message)

src/main/java/org/jitsi/jicofo/rest/Application.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.glassfish.jersey.server.*;
2020
import org.jetbrains.annotations.*;
2121
import org.jitsi.jicofo.auth.*;
22+
import org.jitsi.jicofo.auth.rest.*;
2223
import org.jitsi.jicofo.health.*;
2324
import org.jitsi.utils.version.*;
2425

0 commit comments

Comments
 (0)