This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I wanted to allow guests to access Koel without logging in, so I modified the nginx.conf file bundled as part of https://github.com/binhex/arch-koel to inject some JavaScript on GET / which will set some local storage variable (jwt-token). Koel will assume you're an authenticated user and will try and hit /api/data. If the JWT is good and signed correctly you'll be seamlessly authenticated to Koel. | |
For the following to work your nginx instance needs to be compiled with the --with-http_sub_module config parameter. You can check this by running "nginx -V". This solution will not work if nginx hasn't been compiled with this config parameter. | |
Next you need to create a new user in Koel which will be used as the guest account. | |
Now locate the nginx.conf file and add the following lines under "location ~ \.php$ {": | |
sub_filter '<script>' '<script>if (window.location.hostname == "KOEL-DOMAIN-HERE") localStorage.setItem("jwt-token", "\\"JWT-HERE\\"");'; | |
sub_filter_once on; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SCRIPT="#!/bin/bash | |
function check() { | |
if hash \$1 2>/dev/null; then | |
return 0 | |
else | |
return 1 | |
fi |