Closed scyto closed 5 years ago
Good to hear! I’ll be releasing a first version of a v2 release shortly, need to consider whether I’ll use the same repo or not since it is quite large change.
Will let you know when I have a first package ready for testing.
Happy to test. Does it have a new dependencies i would need to add to my alpine image?
Currently this is my dockerfile so should be trivial to amend the git clone and add / amend the apk instructions as needed. It is literally a one line build line that lets me create all the variants!
https://github.com/scyto/docker-UnifiBrowser/blob/master/Dockerfile
PS are you on the ubiquiti discord server? Its a great place for you to advertise your work if you are not.
No other dependencies other than what is bundled using composer.
Keep you posted.
@scyto Here's a link to the 2.0.0-alpha version. It's quite stable and almost ready for release but documentation is lacking. Just go through the config directory and read the two files there, config-template.php
and users-template.php
.
<-- link removed now version 2.0.0 is released -->
The tool can now be secured with user name/passwords using hashed passwords in the config file. Not perfect but good enough for this tool IMHO. Also, most interaction between the browser and the controller API is handled through AJAX for a more flexible and smoother experience.
To get rid of the spaghetti code that had evolved over time we now use Twig templates to generate the HTML output for 99% of the cases. And of course, we now use Bootstrap 4.
Let me know when you've downloaded it so I can remove the link again.
Looking forward to your feedback😉
Removing the file and link because the 2.0.0 release has now been pushed to the repo. Only need to update the screenshots in the README.
Let me know what you think about this new version.
cool, will try and test this weekend
Good timing, right?😉
Maybe, i am supposed to be doing work and instead i am thinking about how to translate the config instructions into an easy container. I am thinking of making it so that in the config files I variablize the parameters in the first controller section and first users section and comment out the rest.... also thinking about mapping that file out to persistent storage.... :-)
I know that feeling😀 One way to approach this is by using environmental variables external to the tool and picking them up in the config file, something like this: https://www.php.net/manual/en/reserved.variables.environment.php
ok i have a local container, made my config.php for one site by using hardcoded value and commenting out the second element of the site array. everything starts ok then when i do localhost:8000 i get this:
PS C:\Users\lx_b\OneDrive\Documents\GitRepos\docker-UnifiBrowser> docker run -it --rm -p 8000:8000 scyto/unifibrowser:latest
starting UniFi-API-browser
PHP 7.3.10 Development Server started at Fri Oct 25 20:21:51 2019
Listening on http://0:8000
Document root is /UniFi-API-browser
Press Ctrl-C to quit.
[Fri Oct 25 20:22:01 2019] PHP Notice: Undefined variable: twig in /UniFi-API-browser/index.php on line 45
[Fri Oct 25 20:22:01 2019] PHP Fatal error: Uncaught Error: Call to a member function render() on null in /UniFi-API-browser/index.php:45
Stack trace:
#0 {main}
thrown in /UniFi-API-browser/index.php on line 45
[Fri Oct 25 20:22:01 2019] 172.17.0.1:47518 [500]: / - Uncaught Error: Call to a member function render() on null in /UniFi-API-browser/index.php:45
Stack trace:
#0 {main}
thrown in /UniFi-API-browser/index.php on line 45
i am starting the site using php -S 0:8000 -t ./UniFi-API-browser
my bad, had the config file in the wrong path - interestingly it never threw the error you have in the code to tell me to copy the template....
now i am here
starting UniFi-API-browser
PHP 7.3.10 Development Server started at Fri Oct 25 20:32:39 2019
Listening on http://0:8000
Document root is /UniFi-API-browser
Press Ctrl-C to quit.
[Fri Oct 25 20:32:44 2019] The file config/users.php does not exist, proceeding without user authentication.
[Fri Oct 25 20:32:44 2019] 172.17.0.1:47636 [200]: /UniFi-API-browser/
[Fri Oct 25 20:32:44 2019] 172.17.0.1:47634 [404]: /UniFi-API-browser/css/custom.css?2.0.1 - No such file or directory
[Fri Oct 25 20:32:44 2019] 172.17.0.1:47638 [404]: /UniFi-API-browser/js/custom.js?2.0.1 - No such file or directory
[Fri Oct 25 20:32:44 2019] 172.17.0.1:47640 [404]: /UniFi-API-browser/favicon.ico - No such file or directory
ahh that was an issue to do with browser cache - F5 fixed it (sorry for this stream of consciousness!)
ok, seems to be working, i will go look at env vars.
This is the config.php section. Work just fine :-) ignore any other message you saw before i deleted.
$controllers = [
[
'user' => getenv('USER'), // the user name for access to the Unifi Controller
'password' => getenv('PASSWORD'), // the password for access to the Unifi Controller
'url' => getenv('UNIFIURL'), // full url to the Unifi Controller, eg. 'https://22.22.11.11:8443'
'name' => getenv('DISPLAYNAME') // name for this controller which will be used in the dropdown menu
],
<rest of array removed for brevity>
];
Ok, v2 containers done https://hub.docker.com/r/scyto/unifibrowser/tags
Advantage for anyone using a UI like synology they will easily get prompted:
Nextup, modify the readme.md file and if i have time get real ambitious and see if can I also add a windows container to that list :-) and think about if i do same for an authenticated user
Oh feature thought - did you think about asking the user for the password and username as they select the sites - i.e. never storing it for more than the browser sessions lifetime?
Note if you change syntax / expectations of config.php it will break me :-)
please test it if you have docker anywhere on anything :-)
ok one last push, i added the users.php file, set a default username but not password (too much chance folks keep using the default) and I improved the readme.
ok, was playing with the different higlighters when i use the php highlighter (third button) it errors, even on tiny collection like the site lists and the in UI spinner just spins infintely, a full page reload lets one continue.
Cool, thanks for the feedback and testing. As it looks now major changes to the current config files aren’t to be expected. The only thing to consider for the users.php
file is to an array containing the index values for controllers the user is allowed access to, but if I add that, the default (in array not present or empty) will be to allow the user access to all controllers.
Regarding the Kint error; I haven’t seen that before, even on large collections. Can you post a anonymized screenshot of the About modal?
Quick Google returned this: https://wordpress.org/support/topic/fatal-error-call-to-undefined-function-token_get_all/ Are you using PHP 7.x? If this is the cause I need to update the prerequisites.
This my apk line ‘ apk add --no-cache php php-session php-curl composer git \’
Hmm, let me check after the weekend. Thx!
Further searching tells me you may need to also include php7-tokenizer/php-tokenizer. Can't confirm here; haven't found the time yet to spin up a new container for this.
Maybe you can @scyto ?
Yeah i saw same thing, it is supposed to be included, but will try and add manually when I get a chance - i am on the road and it will be a little challenging, will get docker setup on my mac tonight.
Get Outlook for iOShttps://aka.ms/o0ukef
From: malle-pietje notifications@github.com Sent: Monday, October 28, 2019 8:40:03 AM To: Art-of-WiFi/UniFi-API-browser UniFi-API-browser@noreply.github.com Cc: scyto lx_b@msn.com; Mention mention@noreply.github.com Subject: Re: [Art-of-WiFi/UniFi-API-browser] INFO: my docker unifiapi browser containers now support linux/amd64, linux/arm64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6 (#75)
Further searching tells me you may need to also include php7-tokenizer/php-tokenizer. Can't confirm here; haven't found the time yet to spin up a new container for this.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FArt-of-WiFi%2FUniFi-API-browser%2Fissues%2F75%3Femail_source%3Dnotifications%26email_token%3DACWXVXDP6JKB6LHWHFBBYV3QQ4BVHA5CNFSM4JEIYAFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECNKROI%23issuecomment-547006649&data=02%7C01%7C%7C0beb42ec869d4a41859108d75bbd1a04%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637078740048415180&sdata=XRsfzt6Gnadsktg7pqNx%2BtAolAXiIZKjPxCXGIzzwdo%3D&reserved=0, or unsubscribehttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACWXVXG3HFH7MCONNFOOGB3QQ4BVHANCNFSM4JEIYAFA&data=02%7C01%7C%7C0beb42ec869d4a41859108d75bbd1a04%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637078740048425188&sdata=6hxPr4hVhPtVslHVQx9S5XTBkB5GTmP4A89sopmftQ0%3D&reserved=0.
I launched my container with a /bin/sh command and tried apk add php-tokenizer - it downloaded 25MB so i don't think it was installed, will update and publish the container and try and test tonight.
Getting closer...;-)
just managed to VPN to home, yes that fixed it. containers are all updated.
Perfect, thanks for the feedback!
NP, can i make a wiki page to detail and link out to the containers?
That would be a great idea. I'll add a section to the README with a brief summary and a pointer to the wiki page.
done, closing issue.
README has been updated to include a reference to the Wiki page. Thanks!
Just to let you know, i made every conceivable linux variant i could (as an experiment). there are 7 architectures, I have only tested amd64 - but FYI
https://hub.docker.com/r/scyto/unifibrowser/tags