Selkies Checkpoint 7 - Auth
All checks were successful
Build & Push Docker Image / build-and-publish (push) Successful in 45s
All checks were successful
Build & Push Docker Image / build-and-publish (push) Successful in 45s
This commit is contained in:
@@ -14,7 +14,8 @@ ENV \
|
||||
SELKIES_AUDIO_ENABLED="false" \
|
||||
SELKIES_GAMEPAD_ENABLED="false" \
|
||||
SELKIES_UI_SIDEBAR_SHOW_GAMEPADS="false" \
|
||||
SELKIES_UI_SIDEBAR_SHOW_AUDIO_SETTINGS="false"
|
||||
SELKIES_UI_SIDEBAR_SHOW_AUDIO_SETTINGS="false" \
|
||||
CUSTOM_USER="runelite"
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
default-jre \
|
||||
@@ -33,7 +34,7 @@ RUN usermod -a -G audio abc
|
||||
# Add RuneLite icon for Selkies interface and favicon
|
||||
COPY icons/ /usr/share/selkies/www/
|
||||
|
||||
# Inject iOS webapp meta tags into Selkies HTML (if index.html exists)
|
||||
# Inject iOS webapp meta tags and auth fix into Selkies HTML (if index.html exists)
|
||||
RUN if [ -f /usr/share/selkies/www/index.html ]; then \
|
||||
sed -i '/<\/head>/i\<!-- RuneLite iOS WebApp Support -->' /usr/share/selkies/www/index.html && \
|
||||
sed -i '/<\/head>/i\<meta name="apple-mobile-web-app-capable" content="yes">' /usr/share/selkies/www/index.html && \
|
||||
@@ -42,7 +43,8 @@ RUN if [ -f /usr/share/selkies/www/index.html ]; then \
|
||||
sed -i '/<\/head>/i\<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">' /usr/share/selkies/www/index.html && \
|
||||
sed -i '/<\/head>/i\<link rel="apple-touch-icon" sizes="152x152" href="apple-touch-icon-152x152.png">' /usr/share/selkies/www/index.html && \
|
||||
sed -i '/<\/head>/i\<link rel="manifest" href="manifest.json">' /usr/share/selkies/www/index.html && \
|
||||
sed -i '/<\/head>/i\<meta name="theme-color" content="#ff6600">' /usr/share/selkies/www/index.html; \
|
||||
sed -i '/<\/head>/i\<meta name="theme-color" content="#ff6600">' /usr/share/selkies/www/index.html && \
|
||||
echo "<!-- Auth fix temporarily disabled -->" ; \
|
||||
fi
|
||||
|
||||
|
||||
|
||||
89
icons/auth-fix.js
Normal file
89
icons/auth-fix.js
Normal file
@@ -0,0 +1,89 @@
|
||||
// Simple fix for HTTP Basic Auth WebSocket connection issues
|
||||
// Only prevents initial failed connections, allows normal operation after auth
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// Quick check if we're already authenticated
|
||||
let authChecked = false;
|
||||
let isAuthenticated = false;
|
||||
|
||||
// Store original WebSocket
|
||||
const OriginalWebSocket = window.WebSocket;
|
||||
|
||||
// Simple auth check
|
||||
function quickAuthCheck() {
|
||||
if (authChecked) return Promise.resolve(isAuthenticated);
|
||||
|
||||
return fetch(window.location.href, {
|
||||
method: 'HEAD',
|
||||
credentials: 'same-origin'
|
||||
}).then(response => {
|
||||
authChecked = true;
|
||||
isAuthenticated = response.ok && response.status !== 401;
|
||||
return isAuthenticated;
|
||||
}).catch(() => {
|
||||
authChecked = true;
|
||||
isAuthenticated = false;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Override WebSocket constructor
|
||||
window.WebSocket = function(url, protocols) {
|
||||
// If we haven't checked auth yet, do a quick check
|
||||
if (!authChecked) {
|
||||
quickAuthCheck().then(authenticated => {
|
||||
if (!authenticated) {
|
||||
// If not authenticated, wait a bit and try again
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// If we're authenticated or auth check passed, create WebSocket normally
|
||||
if (isAuthenticated || authChecked) {
|
||||
return new OriginalWebSocket(url, protocols);
|
||||
}
|
||||
|
||||
// Otherwise, create a dummy WebSocket that will be replaced
|
||||
const ws = this;
|
||||
ws.readyState = OriginalWebSocket.CONNECTING;
|
||||
ws.bufferedAmount = 0;
|
||||
ws.extensions = '';
|
||||
ws.protocol = '';
|
||||
ws.url = url;
|
||||
ws.onopen = null;
|
||||
ws.onclose = null;
|
||||
ws.onerror = null;
|
||||
ws.onmessage = null;
|
||||
ws.close = function() {};
|
||||
ws.send = function() {};
|
||||
|
||||
// Check auth and replace with real WebSocket when ready
|
||||
quickAuthCheck().then(authenticated => {
|
||||
if (authenticated) {
|
||||
const realWs = new OriginalWebSocket(url, protocols);
|
||||
|
||||
// Copy event handlers
|
||||
realWs.onopen = ws.onopen;
|
||||
realWs.onclose = ws.onclose;
|
||||
realWs.onerror = ws.onerror;
|
||||
realWs.onmessage = ws.onmessage;
|
||||
|
||||
// Replace methods and properties
|
||||
Object.setPrototypeOf(ws, realWs);
|
||||
Object.assign(ws, realWs);
|
||||
}
|
||||
});
|
||||
|
||||
return ws;
|
||||
};
|
||||
|
||||
// Copy static properties
|
||||
Object.setPrototypeOf(window.WebSocket, OriginalWebSocket);
|
||||
Object.assign(window.WebSocket, OriginalWebSocket);
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user