semvec/pypi-packages huggingface dataset:
seamless 0.1.0
UNKNOWN
License: BSD

seamless
========

seamless provides an easy way to obtain an https session token via ssh.
It automates creation of user accounts and manages their *authorized_keys* as well as session token creation via forced ssh commands.
The authentication flow is as follows:

* A client connects to `seamless-realm@seamless-host` via ssh and authenticates with a public key.
  The key is restricted to only execute the token creation command of the seamless binary.
  The seamless command returns session token that is signed with a secret specific to `seamless-realm`.

  .. code::

      $ ssh -T seamless-realm@seamless-host
      username.VgfAwA.v-xKIZh3qYawqcm2RRh4q-LPfVE

* The client sends the obtained token in the HTTP *Authorization* header of its requests to `protected-app`.
  The app uses the shared secret to validate the token.

  .. code:: http

     GET / HTTP/1.1
     Host: protected-app
     Authorization: seamless username.VgfAwA.v-xKIZh3qYawqcm2RRh4q-LPfVE


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

From a deb package::

    $ wget https://github.com/emulbreh/seamless/releases/download/v0.1.0/seamless_0.1.0_amd64.deb
    $ sudo dpkg -i seamless_0.1.0_amd64.deb

As Python package::

    $ pip install seamless


Setting up a seamless realm
---------------------------

A seamless realm is a user account on `seamless-host`. The creation and management of *authorized_keys* of these accounts is handled by seamless.

.. code:: bash

    $ sudo seamless init seamless-realm
    $ sudo seamless add seamless-realm /path/to/public/key --user username

A user with this public key is now able to get tokens via ssh:

.. code::

    $ ssh -T seamless-realm@seamless-host
    username.VgfOLQ.EB6NTfXiyv7dWSKUMQJ38JXa5aw

or from Python

.. code:: python

    >>> import seamless
    >>> seamless.get_token('seamless-realm@seamless-host')
    'username.VgfOBA.dRBDY5EUmQvhB8OnqPDWlC1tml4'


Protecting a webservice with WSGI middleware
---------------------------------------------

seamless ships with WSGI middleware that verifies that a valid seamless token is passed via the Authorization header.

.. code:: python

    from seamless.wsgi import SeamlessMiddleware
    
    app = ...

    app = SeamlessMiddleware(app, max_age=60, secret='...')


Requests without a valid *Authorization* header will be rejected with a 401 response.


Making requests to such a protected app is made easy with an auth plugin for `requests`_:

.. code:: python

    import requests
    from seamless.requests import SeamlessAuth
    
    session = requests.Session()
    session.auth = SeamlessAuth('name@seamless-host')

    session.get('http://protected-app/')


The token obtained from `seamless-host` is cached. 
It will be be automatically refreshed when it expires, and the failing request retried.


Caveats
--------

* If token validation is performed on a different host than token creation, clock skew may result in tokens that expire too early or too late.


.. _requests: http://docs.python-requests.org/
corker 0.6.0
Another WSGI Framework
License: BSD

![TravisCI Status](https://api.travis-ci.org/jd-boyd/corker.png)

# About

I wanted a framework that was based around
[routes](https://github.com/bbangert/routes) and
[webob](http://webob.org/) without opinionation about database and
templating.

Some of the specifics of this are inspired/copied from: http://www.ianbicking.org/blog/2010/03/12/a-webob-app-example/index.html

# Installation

  `pip install corker`

# Usage

The basics are that you create controllers (classes that subclass
`BaseController`).  In a controller, you label methods with the `@route`
decorator to expose them.  You then invoke your controller's
`setup_routes` method (inheritted from `BaseController`), passing it a
routes mapper to add itself to.  Then, to create the actual wsgi app,
you create an `Application` and pass it the mapper.

In a controller, `self.request` gives you the current WebOb request
object.  The controller can return a string containing HTML (in which
case it will be given a status code of 200), or a WebOb response object.
Additionally, it is safe to raise any
[WebOb exception](http://webob.readthedocs.org/en/latest/modules/exceptions.html).

On an exposed method, the arguments (after self) are from routes
positional/regex arguments.  GET and POST arguments are accessed via
`self.request`.

The arguments for the `@route` decorator largely match the arguments for
route's `mapper.connect` method.  The decorated method is automatically
used as the action argument to `mapper.connect` and all other arguments
to `@route` are passed through to `mapper.connect` as is.

Arguments passed to `Application` after the mapper are inserted into
controllers with the same name.  So, is the `Application` was
instantiated with `Application(mapper, x=5)`, then in an exposed method
on the controller, `self.x == 5` would be `True`.

## Example

```python
from routes import Mapper

from corker.controller import BaseController, route
from corker.app import Application
from webob import Response

class Index(BaseController):
    @route('')
    def index(self, request):
        return 'Hi index!\n'

    @route('view/{item}')
    def view(self, request, item):
        return 'Hi view %d!\n' % int(item)

class Sub(BaseController):
    def __init__(self, request, arg1):
        self.request = request
        self.arg1 = arg1

    @route('')
    def index(self, request):
        return Response('Hi sub!\n' + self.arg1)

mapper = Mapper()
Index.setup_routes(mapper)
with mapper.submapper(path_prefix='/sub') as sub:
  Sub.setup_routes(sub, config={"arg1": "arg string"})

example_app = Application(mapper)

# At that point `example_app` is a wsgi app ready to be mounted by the
# server of your choice.  For example with `wsgiref`:

from wsgiref.util import setup_testing_defaults
from wsgiref.simple_server import make_server

httpd = make_server('', 8000, example_app)
print "Serving on port 8000..."
httpd.serve_forever()
```

# Bugs/Feature Requests

See [github issues](https://github.com/jd-boyd/corker/issues).

# Copyright
  This is distributed as BSD.  Copyright Joshua D. Boyd