semvec/pypi-packages huggingface dataset:
django-shirow 0.4
Django Shirow package
License: http://www.apache.org/licenses/LICENSE-2.0

|pypi|

Django Shirow
=============

To connect to the RPC servers based on
`Shirow <https://github.com/tolstoyevsky/shirow>`__, clients have to be
authenticated using the `Django authentication
system <https://docs.djangoproject.com/en/2.0/topics/auth/>`__. Thus,
the package provides the ``create_token_if_needed`` decorator which is
intended for Django views. First, the decorator tries to obtain a token
from Redis. Then, in case the try doesn't succeed,
``create_token_if_needed`` will create and put it into Redis and the
user's session. Finally, the client can get the token from the session
and prove the RPC server he/she is an authenticated user.

The decorator uses JWT for generating tokens. JWT (JSON Web Token) is
the open standard defined in `RFC
7519 <https://tools.ietf.org/html/rfc7519>`__.

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

::

    $ pip install django-shirow

Usage
-----

This Django application uses the following configuration keys:

-  ``SECRET_KEY`` is a string which contains a secret. Django uses the
   configuration key for `cryptographic
   signing <https://docs.djangoproject.com/en/2.0/topics/signing/>`__,
   but ``create_token_if_needed`` uses it for signing the tokens, using
   the algorithm specified by ``TOKEN_ALGORITHM_ENCODING`` (see below).
-  ``TOKEN_TTL`` is a number which contains a time-in-seconds value. It
   indicates how long tokens are considered valid. If ``TOKEN_TTL`` is
   not set, then TTL is set to ``900`` (15 minutes).
-  ``TOKEN_ALGORITHM_ENCODING`` is a string which contains `one of the
   algorithms <https://pyjwt.readthedocs.io/en/latest/algorithms.html#digital-signature-algorithms>`__
   used for signing tokens. If ``TOKEN_ALGORITHM_ENCODING`` is not set,
   then the algorithm is set to ``HS256``.
-  ``REDIS_HOST`` is a string which contains the Redis host. If
   ``REDIS_HOST`` is not set, then the host is set to ``127.0.0.1``.
-  ``REDIS_PORT`` is a number which contains the port the Redis server
   listens on. If ``REDIS_PORT`` is not set, then the port is set to
   ``6379``.

.. |pypi| image:: https://img.shields.io/pypi/v/django-shirow.svg
   :target: https://pypi.org/project/django-shirow/
shirow 0.4
Shirow package
License: http://www.apache.org/licenses/LICENSE-2.0

|pypi|

Shirow
======

Shirow is an RPC server framework based on top of
`Tornado <http://tornadoweb.org/en/stable/>`__. It relies on the
WebSocket protocol for transport and uses JSON-messages as payload.

The project was named after Masamune Shirow, a mangaka who is best known
for such mangas as `Black
Magic <https://en.wikipedia.org/wiki/Black_Magic_(manga)>`__,
`Appleseed <https://en.wikipedia.org/wiki/Appleseed_(manga)>`__ and
`Ghost in the
Shell <https://en.wikipedia.org/wiki/Ghost_in_the_Shell_(manga)>`__.

Features
--------

The primary goal of Shirow is to simplify creating microservices using
Tornado, allowing clients to leverage some Django facilities. Thus,
Shirow expands the Tornado implementation of the WebSocket protocol with
an authentication layer, so that clients have to be authenticated using
the `Django authentication
system <https://docs.djangoproject.com/en/2.0/topics/auth/>`__ to
connect to the RPC server. The client has to pass a valid token to the
RPC server, which was received after a successful authentication
procedure, to prove Shirow that it's an authenticated. See the
`create\_token\_if\_needed <https://github.com/tolstoyevsky/shirow/tree/master/django-shirow>`__
decorator to learn how to make Django views create the tokens.

Authors
-------

See `AUTHORS <AUTHORS.md>`__.

Licensing
---------

Shirow is available under the `Apache License, Version 2.0 <LICENSE>`__.

.. |pypi| image:: https://img.shields.io/pypi/v/shirow.svg
   :target: https://pypi.org/project/shirow/