/!\ Anyone interested in this Gist should look at the work of @danielchc ;)
-> https://gist.github.com/danielchc/c159626485a08c76856b2d30ae457e04
/!\ I used bind9 on my local server to add mb3admin.com entry for all devices ( like android app ) Otherwise in hosts fie :
<your_server> mb3admin.com
C:\Users\<YOUR_USER>\AppData\Roaming\Emby-Theater\system\electronapp
Add after app.on('window-all-closed', function () {
block L:18
To accept self certificate
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
event.preventDefault()
callback(true)
})
- Create /var/www/mb3admin.com folder
- In /var/www/mb3admin.com/ create file
index.php
with
<?php
if (false){
$file = 'data.log';
$content = file_get_contents($file);
$content .= date('Y-m-d H:i:s').' : '.$_SERVER['REMOTE_ADDR'].' URL : '.$_SERVER['REDIRECT_URL'].' Query : '.json_encode($_REQUEST)."\r\n";
file_put_contents($file, $content);
}
if ($_SERVER['REDIRECT_URL'] == '/admin/service/registration/validate'){
header('content-type:application/json');
$date = new DateTime();
$date->add(new DateInterval('P14D'));
echo '{"featId":"'.$_POST['feature'].'","registered":true,"expDate":"'.$date->format('Y-m-d').'","key":"'.$_POST['key'].'"}';
}elseif ($_SERVER['REDIRECT_URL'] == '/admin/service/registration/validateDevice'){
header('content-type:application/json');
echo '{"cacheExpirationDays":21,"resultCode":"GOOD","message":"Device Valid"}';
}
- Create file
.htaccess
Allow from all Options -Indexes <IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L] </IfModule>
# /etc/apache2/sites-enabled/mb3admin.conf
<VirtualHost *:80>
DocumentRoot "/var/www/mb3admin.com"
ServerName mb3admin.com
<Directory "/var/www/mb3admin.com/">
Options MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
TransferLog /var/log/apache2/mb3admin_access.log
ErrorLog /var/log/apache2/mb3admin_error.log
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/var/www/mb3admin.com"
ServerName mb3admin.com
SSLEngine on
SSLCertificateFile /etc/apache2/mb3admin.crt # Self signed certificate
SSLCertificateKeyFile /etc/apache2/mb3admin.key
<Directory "/var/www/mb3admin.com/">
Options MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
TransferLog /var/log/apache2/mb3admin_access.log
ErrorLog /var/log/apache2/mb3admin_error.log
</VirtualHost>
@demogorgonz
If I understood correctly, you have:
Patched the server
Emby.Web.dll
to force the server to authenticate against a different FQDN, to avoid having to set up a redirect within/etc/hosts
(which is what I effectively do within my docker compose network).I did not get how you managed to make the server return the patched
connectionmanager.js
? In my testing just patching the server was not enough, as the web client also tries to authenticate againstmb3admin.com
(which is why I patched theconnectionmanager.js
with a hard-coded valid authentication response).Regarding the standalone clients, at first I assumed as well that they will have their own authentication logic (instead of having to pull js files off of the server). But then I saw one of the server js files referring to "native" versions of the js files for iOS and Android clients. This made me believe that the "native" clients are nothing more than a browser without an address bar, but I did not investigate much further.
How do you know that the standalone apps do not download the authentication logic from the server? Did you try to MITM the connection between them to see what is being exchanged?