# Auth proxy
## Authorization proxy app for Atlas-um app.


## Purpose

The primary purposes of atlas-auth-proxy is to provide a way to handle cookies  
in cross-origin environments, required for authorization with atlas-um
for client apps.

This app is intended to be available on `auth` subdomains of the client 
applications domains to allow cookie sharing.

For integration logic description refer to [docs/sequence_diagram.png](docs/sequence_diagram.png) scheme.
For endpoints descriptions refer to [docs/endpoints_description.md](docs/endpoints_description.md).

## Configuration

### Environment variables

  - SESSION_SECRET (session secret key)
  - LOGIN_URL (atlas-um login url: `/usm/login` on the respective domain)
  - LOGOUT_URL (atlas-um logout url: `/usm/logout` on the respective domain)
  - PUBLIC_KEY_URL (url to shared public RSA key to verify JWT tokens)
  - ALLOWED_HOSTS (domains where this app is accessible, e.g. `auth.<yourapp>.stream`)
  - ORIGINS (origins from where there is a need to access the `/token` endpoint with 
    fetch/XMLHttpRequest, e.g. `https://<yourapp>.stream`)
  - ALLOWED_REDIRECT_URLS (urls whitelist for response_type=token cases, e.g. for mobile apps)
  - DNA_BEARER_TOKEN_COOKIE_NAME (dafault: dna_bearer_token)
  - DNA_REFRESH_TOKEN_COOKIE_NAME (default: dna_refresh_token)

## Development

Python package dependencies are specified using
[pipenv](https://github.com/pypa/pipenv). The expected version of
Python is also specified in pipenv’s Pipfile. 

To develop atlas-auth-proxy,
install pipenv, then `pipenv install --dev`.

Or use `web` service from the docker-compose config for your local 
development needs.

## Code style
[Flake8](https://github.com/PyCQA/flake8) linter is being used to
keep the code style in a good and PEP8 compliant shape. 

[Black](https://github.com/psf/black) is being used for code autoformatting. 

Use `make docker/lint` to check code style

## Security check
[Pip-audit](https://pypi.org/project/pip-audit/) if being used for the 
security check of the project dependencies. 

[Bandit](https://github.com/PyCQA/bandit) is being used for the 
security check of the project code.

Use `make docker/bandit` to run the security check with Bandit

Use `make docker/dependencies-check` to run the deps check with pip-audit

## Code updates

Before you push code and create a PR, run the following command:

`make pre-commit`
