{"id":19371921,"url":"https://github.com/chatsecure/chatsecure-push-server","last_synced_at":"2025-04-23T16:31:42.247Z","repository":{"id":39846594,"uuid":"5991304","full_name":"ChatSecure/ChatSecure-Push-Server","owner":"ChatSecure","description":"An experimental design for a privacy-minded push server.","archived":false,"fork":false,"pushed_at":"2022-12-08T06:34:49.000Z","size":723,"stargazers_count":111,"open_issues_count":9,"forks_count":30,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-02T17:21:39.347Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://chatsecure.org/blog/fixing-the-xmpp-push-problem/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChatSecure.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING.AGPL.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-28T01:53:54.000Z","updated_at":"2025-01-24T05:49:01.000Z","dependencies_parsed_at":"2022-09-05T09:10:28.289Z","dependency_job_id":null,"html_url":"https://github.com/ChatSecure/ChatSecure-Push-Server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChatSecure%2FChatSecure-Push-Server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChatSecure%2FChatSecure-Push-Server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChatSecure%2FChatSecure-Push-Server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChatSecure%2FChatSecure-Push-Server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChatSecure","download_url":"https://codeload.github.com/ChatSecure/ChatSecure-Push-Server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250470882,"owners_count":21435855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T08:20:31.691Z","updated_at":"2025-04-23T16:31:41.877Z","avatar_url":"https://github.com/ChatSecure.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"ChatSecure Push Server\n======================\n\n[![Build Status](https://travis-ci.org/ChatSecure/ChatSecure-Push-Server.svg?branch=master)](https://travis-ci.org/ChatSecure/ChatSecure-Push-Server)\n\nAn experimental design for a privacy-minded push server.\n\nDeploy to Heroku\n----------------\n\n[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)\n\nAfter deployment is complete, use the [Heroku Scheduler](https://scheduler.heroku.com/dashboard) to schedule daily expired token cleanup via the `python push/manage.py delete_expired_tokens` command:\n\n![Heroku Scheduler Clean Expired Tokens Task](https://github.com/ChatSecure/ChatSecure-Push-Server/raw/master/art/heroku_scheduler_command.png)\n\nManual Installation\n-------------------\n\nYou will need to install RabbitMQ, Postgres, and pip using the method of your choosing:\n\nRabbitMQ is available via Homebrew.\n\n    $ brew install rabbitmq\n\nPostgres is available on Mac with [Postgres.app](http://postgresapp.com) but more readily upgradeable when installed via Homebrew with `brew install postgres`. On Linux, install the latest version of Postgres with the package manager of your choice.\n\nAfter installing Postgres, add its `bin/` directory to your system path in prepararation for `psycopg2`, the python PostgreSQL adapter.\n\n```bash\n# ~/.bash_profile\n# ...\n# Postgres (Your path will differ if you aren't using Postgress.app)\nPATH=${PATH}:/Applications/Postgres.app/Contents/Versions/9.4/bin/\n\n```\n\nIf you don't have the latest version of Python 2.7 and pip, get them.\n\n    $ brew install python (Mac. On Linux, use the package manager of your choice)\n    $ easy_install pip\n\n### Virtual Environment\n\nSetup your virtual environment. You'll probably need to do some more stuff too.\n\n    $ pip install virtualenv virtualenvwrapper\n    $ mkvirtualenv push\n    $ workon push\n    \nThen you will need to install the following dependencies: \n\n\t(push)$ cd /path/to/ChatSecure-Push-Server/\n\t(push)$ pip install -r requirements.txt\n\n### Database\n\nCreate a PostgrSQL database matching that you specified in your `./push/push/local_settings.py`.\n\n    # From psql console:\n    $ create database NAME;\n    \nSetup\n---------\n\n### APNS SSL Certificates\n\nEach iOS client application requires separate APNS SSL Certificates for development and production environments. The process below is for a single certificate.\n\n1. Obtained a signed SSL cert from the Apple Provisioning Portal. We'll refer to this cert as `DevCert.cer`.\n    \n    1. Go to [iOS Identifiers](https://developer.apple.com/account/ios/identifiers/bundle/bundleList.action) and create an entry for your application namespace. \n    1. Select the newly created identifier and then `Edit` from the bottom of the page. Select `Push Notifications` and then `Create Certificate`. This will provide instructions for generating and uploading a `.certSigningRequest` file created with Keychain Access on your Mac. \n    1. Upload the `.certSigningRequest` and download the signed SSL cert as `DevCert.cer`\n\n2. Convert your Apple-issued `DevCert.cer` to `DevCert.pem`.\n\n    ```\n    $ openssl x509 -in DevCert.cer -inform der -out DevCert.pem\n    ```\n\n3. Export your Keychain Access-generated private key (from 1.ii) as `DevKey.p12`.\n\n    Open Keychain Access, and select `Keys` from the left pane. Select your certificate's Private Key entry and then `Export` to generate the `DevKey.p12` file.\n    \n4. Convert `DevKey.p12` private key to `DevKey.pem`\n\n    ```\n    $ openssl pkcs12 -nocerts -in DevKey.p12 -out DevKey.pem -nodes\n    ```\n\n5. Combine the no-password private key `DevKey.pem` with the Apple-issued and signed cert `DevCert.pem` into the cert file `Certificate.pem`:\n\n    ```\n    $ cat DevCert.pem DevKey.pem \u003e Certificate.pem\n    ```\n\n6. Configure this Django app to use your prepared certificate\n\n    If using Heroku:\n\n    ```\n    heroku config:add APNS_CERTIFICATE=\"$(cat Certificate.pem)\"\n    ```\n\n    Else if using your own server, make sure your certificate is accessible at `./private_keys/apns_cert.pem`.\n    \n### GCM API Key\n\n1. Create a Google Cloud Messaging application using [this wizard](https://developers.google.com/mobile/add). \n2. You'll be prompted for an 'App name' and 'Android package name' (or 'iOS Bundle ID' if you're using GCM for iOS).\n3. You'll finally be prompted to choose your Google Services. For our purposes you'll only need 'Cloud Messaging'.\n4. The wizard will present a `Server API Key` which you copy to `local_settings.py` as `GCM_API_KEY`\n    \n### local_settings.py\n\nCopy `local_settings_template.py` to `local_settings.py`. Fill in the following values:\n\nIn `PUSH_NOTIFICATION_SETTINGS` (for django-push-notifications app):\n\n * `APNS_CERTIFICATE` (str): Path to your `Certificate.pem` file. On Heroku this file is generated from the `APNS_CERTIFICATE` environmental variable by the `bin/post_compile` hook.\n * `APNS_HOST` (str) : Address to the APNS Host. Should be one of `settings.APNS_HOST_DEV` or `settings.APNS_HOST_PROD`, depending on which APNS certificate you are using\n * `APNS_FEEDBACK_HOST` (str) : Address to the APNS Feedback Host. Should be one of `settings.APNS_FEEDBACK_HOST_DEV` or `settings.APNS_FEEDBACK_HOST_PROD`, depending on which APNS certificate you are using\n * `APNS_ERROR_TIMEOUT` (float) : A period in seconds to await an APNS error response. Set non-zero to check and log APNS send errors. `0.5` is a typical value.\n * `GCM_API_KEY` (str) : Your Google Cloud Messaging `Server Api Key`\n * `APNS_TOPIC` (str): This is used to group iOS push notifications. Use your app's bundle identifier.\n\n#### Heroku Instructions\n\n    heroku config:set KEY=VALUE\n\nOn Heroku the default `settings.py` will generate the above settings if you specify the following environmental variables:\n\n * `GCM_API_KEY` : Your Google Cloud Messaging `Server Api Key`\n * `APNS_CERTIFICATE` : Your APNS certificate contents. This can be added via `heroku config:add APNS_CERTIFICATE=\"$(cat Certificate.pem)\"`\n * `APNS_USE_SANDBOX` : Either `'true'` or `'false'`. Will supply the appropriate values for `APNS_HOST` and `APNS_FEEDBACK_HOST`\n* `APNS_TOPIC`: This is used to group iOS push notifications. Use your app's bundle identifier.\n\nNote: When updating the APNS certificate env var you'll need to push a new empty commit to Heroku otherwise the old certificate will be cached across dyno restarts.\n\n### Database\n\nFirst create a PostgrSQL database matching that you specified in your `./push/push/local_settings.py`.\n\n    # From psql console:\n    $ create database NAME;\n    \nNext you need to sync your database before you can do anything.\n\n    (push)$ python manage.py migrate\n\nNext add a superuser account for yourself. The below command will start a wizard to guide you.\n\n    (push)$ python manage.py createsuperuser\n\n    \n### Running (Development)  \n\nLaunch the Django Push Server:\n\n\t$ workon push # activate your virtual environment\n    (push)$ python manage.py runserver # Start Django Server\n    \nIn a new terminal window:\n    \n    $ rabbitmq-server\n\nIn another new terminal window:\n    \n    $ workon push # activate your virtual environment\n    (push)$ python manage.py celery worker --loglevel=info # Start Celery workers\n    \n### Running (Heroku)\n\n#### Setup\n\nFirst install the [Heroku toolbelt](https://toolbelt.heroku.com/) on your development machine.\n\n    $ brew install heroku-toolbelt\n\nTo set up a new Heroku instance, invoke the following from the project root:\n\n    $ heroku create appname\n\nTo connect to an existing Heroku instance, invoke the following from the project root:\n\n    $ git remote add heroku git@heroku.com:appname.git\n    \nTo modify the value of secret values (currently `GCM_API_KEY`, `APNS_CERTIFICATE`, `DJANGO_SECRET_KEY`, `DATABASE_URL`):\n\n    $ heroku config:set NAME=VALUE  # This also restarts your app\n\nNote that we store the APNS certificate contents in `APNS_CERTIFICATE` and use the `post_compile` hook to copy its value into a certificate file.\n    \nTo add commands that should be run before the `Procfile` is invoked, see `./bin/post_compile`. Currently we invoke `manage.py migrate`.\n\n#### Develop\n\nUse Heroku Local to locally run the application in the heroku environment.\n\n    $ heroku local\n\n#### Deploy\n\nAfter creating your Heroku application, add a `Heroku Postgres` addon. To add the free trial database:\n\n    $  heroku addons:create heroku-postgresql:hobby-dev\n\nSee other [Heroku Postgres plans](https://devcenter.heroku.com/articles/heroku-postgres-plans).\n\nPush to the Heroku remote's master branch to deploy.\n\n    $ git push heroku master\n    \nIf you need to deploy a non-master local branch:\n\n    $ git push heroku localBranch:master\n    \n#### Maintain\n\nTo run a command on the Heroku instance:\n\n    $ heroku run python push/manage.py some_command\n\n\n##### Pruning Push Tokens\n\nPush tokens on our Heroku instance older than `settings.CHATSECURE_PUSH['DEFAULT_TOKEN_EXPIRY_TIME_S']` are deleted based on the `tokens/delete_expired_tokens.py` management command.\nYou can manually invoke this on Heroku (remove `--dry-run` to actually delete expired tokens)`:\n\n    $ heroku run python push/manage.py delete_expired_tokens --dry-run\n\nAPI Documentation\n-------------\n\nCheck out `docs/v3/README.md` for now. The API is constantly in flux right now.\n\nTests\n-------------\nRun tests from the termainal:\n\n    $ python push/manage.py test push\n\nOr directly within PyCharm:\n\n    Edit Configurations -\u003e + Add new -\u003e Django tests\n\n\nLicense\n---------\n\n\tChatSecure Push Server\n\tCopyright (C) 2015 Chris Ballinger \u003cchris@chatsecure.org\u003e\n\t\n\tThis program is free software: you can redistribute it and/or modify\n\tit under the terms of the GNU Affero General Public License as\n\tpublished by the Free Software Foundation, either version 3 of the\n\tLicense, or (at your option) any later version.\n\t\n\tThis program is distributed in the hope that it will be useful,\n\tbut WITHOUT ANY WARRANTY; without even the implied warranty of\n\tMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n\tGNU Affero General Public License for more details.\n\t\n\tYou should have received a copy of the GNU Affero General Public License\n\talong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatsecure%2Fchatsecure-push-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchatsecure%2Fchatsecure-push-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatsecure%2Fchatsecure-push-server/lists"}