<commit_before>SNS push service
================

This service provides a simple API for registering devices to SNS.

Installation
------------

1. Sign up to AWS
2. Configure SNS (create topics and platform applications).
3. Configure [IAM](https://aws.amazon.com/documentation/iam/) for SNS access. [Example policy](iam-example-policy.json). Add your topics and platform applications to `Resource` array.
4. Set up SNS credentials and other settings as environment variables ([config variables in Heroku](https://devcenter.heroku.com/articles/config-vars)).
5. In local environment, create and activate new python virtual environment (`pyvenv push-service-env; source push-service-env/bin/activate`) and install dependencies (`pip install -r requirements.txt`). For Heroku, push to heroku remote (`git push heroku master`).

Configuration
-------------

- `ADMIN_AUTH_TOKEN` - authentication token for admin access (publishing, deleting topics etc.). Optional, but if missing, admin access is disabled.
- `AUTH_TOKEN` - authentication token. Optional, but if missing, random one will be generated on each start.
- `DEBUG` - if set to "true", Flask debug and debug logging will be enabled. Optional.
- `AWS_ACCESS_KEY` - access key from Amazon. Avoid using your full-access credentials here - configure restricted account with IAM. Mandatory.
- `AWS_SECRET_KEY` - secret access key. Mandatory.
- `AWS_REGION` - AWS region name for configured SNS (i.e., `eu-west-1`). Mandatory.
- `AUTOSUBSCRIBE_TOPICS` - optional. Comma-separated list of topics each device will be subscribed when registering an endpoint.

Configuring platform applications: create platform applications in SNS first. In this service, you need to invent aliases for each platform application.

For example, if you have platform application with identifier `arn:aws:sns:eu-west-1:133752156591:app/WNS/your-app-name-here`, you can add environment variable

    APP_NAME_PLATFORM_APPLICATION="arn:aws:sns:eu-west-1:133752156591:app/WNS/your-app-name-here"

This way, your Windows Phone (WNS) application will use `"platform": "app_name"` in registration requests.<commit_msg>Add short "what is and what is not included" listing<commit_after>SNS push service
================

This service provides a simple API for registering devices to SNS.

What this is and what this is not?
----------------------------------

- There *is* a simple API for basic operations
- There *is* a simple token authentication with two tokens (admin/user)
- This *is not* full management service for SNS
- There *is no* functionality for managing platform applications or permissions. Do these through SNS console.
- There *is no* support for email/SMS/SQS/HTTP/... subscriptions. This service is designed for mobile apps, and not to be a generic all-purpose push service.
- There *is no* configurable authorization logic, or multiple authentication schemes. There is only admin token for all operations and restricted consumer token.
- There *is no* state on the server side, i.e., all client information, subscriptions and so on are stored in SNS, not on this service. This means client devices (mobile apps) must keep their device IDs and subscription IDs stored somewhere.

Push requests for functionality listed with "no" will probably be rejected - even though those features would be useful for some people, not everything is worth added complexity.

Installation
------------

1. Sign up to AWS
2. Configure SNS (create topics and platform applications).
3. Configure [IAM](https://aws.amazon.com/documentation/iam/) for SNS access. [Example policy](iam-example-policy.json). Add your topics and platform applications to `Resource` array.
4. Set up SNS credentials and other settings as environment variables ([config variables in Heroku](https://devcenter.heroku.com/articles/config-vars)).
5. In local environment, create and activate new python virtual environment (`pyvenv push-service-env; source push-service-env/bin/activate`) and install dependencies (`pip install -r requirements.txt`). For Heroku, push to heroku remote (`git push heroku master`).

Configuration
-------------

- `ADMIN_AUTH_TOKEN` - authentication token for admin access (publishing, deleting topics etc.). Optional, but if missing, admin access is disabled.
- `AUTH_TOKEN` - authentication token. Optional, but if missing, random one will be generated on each start.
- `DEBUG` - if set to "true", Flask debug and debug logging will be enabled. Optional.
- `AWS_ACCESS_KEY` - access key from Amazon. Avoid using your full-access credentials here - configure restricted account with IAM. Mandatory.
- `AWS_SECRET_KEY` - secret access key. Mandatory.
- `AWS_REGION` - AWS region name for configured SNS (i.e., `eu-west-1`). Mandatory.
- `AUTOSUBSCRIBE_TOPICS` - optional. Comma-separated list of topics each device will be subscribed when registering an endpoint.

Configuring platform applications: create platform applications in SNS first. In this service, you need to invent aliases for each platform application.

For example, if you have platform application with identifier `arn:aws:sns:eu-west-1:133752156591:app/WNS/your-app-name-here`, you can add environment variable

    APP_NAME_PLATFORM_APPLICATION="arn:aws:sns:eu-west-1:133752156591:app/WNS/your-app-name-here"

This way, your Windows Phone (WNS) application will use `"platform": "app_name"` in registration requests.
{'fraction_non_alphanumeric': 0.10160724182523555, 'fraction_numerical': 0.011823388139663773, 'mean_word_length': 4.333990147783251, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2029497', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1410, 'n_words': 645}