Skip to main content

Eve JWT authentication

Project description

https://img.shields.io/pypi/v/eve-auth-jwt.svg https://travis-ci.org/rs/eve-auth-jwt.svg?branch=master

An OAuth 2 JWT token validation module for Eve.

Installation

To install eve-auth-jwt, simply:

$ pip install eve-auth-jwt

At Eve initialization:

from eve import Eve
from eve_auth_jwt import JWTAuth

app = Eve(auth=JWTAuth, settings=SETTINGS)

Configuration

This module reads its configuration form Eve settings. Here is the list of new directives:

  • JWT_SECRET (required): Defines the symetric secret token secret used to de/encode the token (async keys support is a TODO).

  • JWT_ISSUER (required): Defines the required token issuer (iss claim).

  • JWT_AUDIENCES: Defines a list of accepted audiences (aud claim). If not provided, only tokens with no audience set will be accepted. The resource level audiences parameter is also available.

  • JWT_ROLES_CLAIM: Defines the claim name for roles. If set, Eve roles check will be activated, and any resources with allowed_roles set will require to have those roles present in the defined token’s claim.

  • JWT_SCOPE_CLAIM: Defines the claim name for scope. If set and the token has a claim of the same name containing the string viewer, only GET and HEAD methods will be granted. All other values are ignored and added to the list of exposed roles with the scope: prefix.

Reading Roles

If access is granted, the authentication module exposes roles and token’s claims thru get_authen_roles() and get_authen_claims() methods. You may access those values from your event hook as follow:

def my_hook(...)
    resource_def = app.config['DOMAIN'][resource_name]
    auth = resource_def['authentication']
    if 'somerole' in auth.get_authen_roles():
        # grant some finer access

Licenses

All source code is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eve-auth-jwt-1.0.4.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

eve_auth_jwt-1.0.4-py2.py3-none-any.whl (6.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file eve-auth-jwt-1.0.4.tar.gz.

File metadata

File hashes

Hashes for eve-auth-jwt-1.0.4.tar.gz
Algorithm Hash digest
SHA256 a684438cd787538dcec9b8313f0903d694073aa069b8d50724f31ac877ea7568
MD5 3d9cf60279c6072656f20957af9e5c88
BLAKE2b-256 6ebbf44c8ad441f970021c39458d9d57e378cbeb889c33bc431d28da75f48b22

See more details on using hashes here.

File details

Details for the file eve_auth_jwt-1.0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for eve_auth_jwt-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6dfefaad11d38987db9a6cb4e3629ae938180f02e2164780314d0b55aa36841d
MD5 73f2cd49d915f21bf035e309e895594e
BLAKE2b-256 c6ed7bc18a8f18a8aaf5574b9fc774fc05355a5bd31e51a2ee41a304d89e7e8f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page