blog.mirabellette.eu

A blog about digital independence and autonomy

Host Firefox booksmarks with syncserver

Written by Mirabellette / / 8 comments

Introduction

In order to be more and more independent about my digital ecosystem. I decided to manage my bookmarks by myself. I use the browser Mozilla Firefox and Mozilla allows you to manage your own synchronization server. Syncserver stores only bookmarks, it didn't manage your Firefox account or the authentication mechanism. This could be done in installing Firefox Accounts Server but it is not the purpose of this tutorial.

firefox_logo

It was pretty annoying to deploy it because there aren't a lot of information available and it requires to me to do some basic stuff by myself. It took me something like 10 or 15 hours to make this article. By the way, it works now and you can read this tutorial and I hope you will find it useful :)

The Github repository isn't very active, one release in 2017 and 2016, two release in 2015 and 2014. Just add the Github repository to your RSS agregator to get news about update. If we trust the past, it shouldn't be done very often.

Configure the Firefox Synchronization Server

  • This setup was made on Debian stretch
  • To build the application, you need to be able to access to internet or to the python repository in order to download all dependencies includes in requirements.txt
  • Dependencies

    adduser --system --shell /usr/sbin/nologin --no-create-home firefox
    apt-get install python-dev git-core python-virtualenv g++ sqlite
    cd /opt
    sudo -u firefox git clone https://github.com/mozilla-services/syncserver

    Basic configuration

    The server is configured using an .ini file to specify various runtime settings. The file “syncserver.ini” is this file for the application. There is some setting that you must specify before building the application. Feel free to adjust the [server:main] part to your configuration. You can find the final syncserver.ini file here (some adjustment still required).

    The parameter public_url. You should modify it in order to match the interface where syncserver will be accessed by. Even if you run it inside a container or a virtual machine, you have to setup the public url.

    public_url = https://example.com

    The parameter sqluri. I choose to use a Sqlite database to store bookmarks because it is easy to backup. Feel free to use the one you want and modify the syncserver.ini. If you don't specify a Sql database, your bookmarks will be store in RAM and be reset each time you restart the server.Replace sqluri = sqlite:////tmp/syncserver.db by :

    sqluri = sqlite:////opt/syncserver/syncserver_data.db
    *//// means absolute path

    The parameter secret. It is better to generate a secret key for signing authentication tokens. If you don't, the server will generate it each time it start. That could mean a weak key if the random generator seed isn't good enough. Uncomment the parameter and set the value with the result of the next command:

    head -c 20 /dev/urandom | sha1sum

    The parameter allowed_issuers. If you are using the account system offered by Mozilla Firefox, you may want to restrict access to just that domain like so:

    allowed_issuers = api.accounts.firefox.com

    The parameter force_wsgi_environ. I setup the server behind an Apache2 reverse proxy. I make some try with false but it didn't work. I even open an issue in the official Github repository. The only to make it works was to set the force_wsgi_environ to true.

    force_wsgi_environ = true

    Build

    Don't skip the configuration step or your syncserver will not work as expected. As you build the application, you should configure syncserver.ini BEFORE build the application. If you don't, the modifications did to syncserver.ini will not be read.

    cd /opt/syncserver
    sudo -u firefox make build
    sudo -u firefox make test

    After that, if you run sudo -u firefox make serve, you should be able to see some lines about syncserver listening. It could tell you if something go wrong.

    Update

    After building the application, you could now see two new folder : syncserver.egg-info and local. You should delete them to be able to build the server again, for example for an update.

    rm -r syncserver.egg-info
    rm -r local

    Apache2 virtualhost

    I create a classic reverse proxy Apache2 virtual host. It just redirects flux to the virtual machine interface. You can find the script here.

    Configure your browser

    The procedure varies a little between desktop and mobile Firefox, and may not work on older versions of the browser. I will only describe the process for desktop version of firefox. Feel free to find more informations here

    • Enter “about:config” in the URL bar picture.

      about_config

      You should display this warranty screen, confirm your choice to continue.

      warranty

    • Made a research for “identity.sync.tokenserver.uri” as name. Double click on the line and replace the string by your public URL.

      tokenserver_uri

      The syntax should be like this https://example.com/token/1.0/sync/1.5.The current version is 1.7 but the endpoint didn't change ... * the original one is the one display in the previous picture https://token.services.mozilla.com/1.0/sync/1.5

    • Restart Firefox for the change to take effect.

    Note that this must be set prior to loading the sign-up or sign-in page in order to take effect, and its effects are reset on sign-out.

    Hardening and clean up

    Lock the instance for your own usage

    As you can see, you now use your own server to store your bookmarks. To avoid someone else could do that, you have to set the parameter allow_new_users to false in syncserver.ini and build the application again.

    vim syncserver.ini
    rm -r syncserver.egg-info
    rm -r local
    sudo -u firefox make build

    Systemd script

    Astonishingly, there is no Systemd script provides by the official tutorial. You could find the one I created here. You have to put it in /etc/systemd/system/ and execute systemctl daemon-reload then systemctl enable syncserver.service. It will start syncserver at each boot.

    Cleanup

    If you install make and g++ just for building this application, feel free to remove them.

    apt purge make g++

    Of course, setup the firewall in the correct way.

    Sources

    Social media

    If you find this article interesting, feel free to subscribe to my RSS flux and to follow me on Mastodon. Don't hesitate to share it if you think he could interest someone else.

    8 comments

    #1  - Mark Tearle said :

    To change the shell of the firefox user, better to use chsh than edit the passwd file directly

    Reply
    #2  - Mirabellette said :

    Thank you for your comment. I didn't know this comment. I tried it a little with sudo -u but it doesn't look to works well.

    Finally, I found that I can make it directly when I create the user. I edited in the article.

    adduser --system --shell /usr/sbin/nologin --no-create-home firefox

    Reply
    #3  - Seboss666 said :

    I tried some years ago and finally abandoned because it would not want to run. Glad to see someone who made it through the crappy doc.

    If you can make the Firefox Accounts nodejs components to work pretty much the same, I would be glad to share, and even translate the blog post (may I translate this one after confirmed that it works also for me ?)

    Reply
    #4  - Mirabellette said :

    I clearly understand why. It wasn't very clear and It needs me some time to understand how it works. The systemd service was quite surprising to build.

    If you wanted to translate it and share it, it will be a great honor, with pleasure!

    Could you please just write at the beginning of the article that it was originally written by me with a link to the original article. A message sent to me with the link will also be very appreciated.

    It is the requirement I think will ask for those which wish to translate my articles.

    I will write some lines about the license in some days/months in order to clarify for the future asks.

    Thank you for the comment!

    Reply
    #5  - Seboss666 said :

    I see that you finally translated it yourself :)
    I always refer to the original article when proposing a translation, and when it's not clear, ask first for permission, in public or private (some web agencies or "commercial" sites have no clear licences on their website, hard to know what to do).

    I'll just share the post in a future "diverse links' series" episode ;)

    Reply
    #6  - Mirabellette said :

    Yes

    Cool, thank you :)

    Reply
    #7  - zeroheure said :

    Nice, but will it require changes because of the new sync server that comes in FF Nightly ?
    See this paper about it: https://blog.nightly.mozilla.org/2018/05/14/deep-dive-new-bookmark-sync-in-nightly/

    Reply
    #8  - Mirabellette said :

    Apparently, they plan to rebuild it so they it is highly probable the current sync tool will be obsolete.

    It looks like they still have works before releasing it. They still have bugs to fix and they wait for metrics before releasing it to the master branch.

    Kit said that it will be include at the earliest in Firefox 64. Firefox 64 is scheduled for 27 of November 2018.
    https://wiki.mozilla.org/Release_Management/Calendar

    Reply

    Rss feed of the article's comments

    Write a comment

    What is the third letter of the word culg?