Giter VIP home page Giter VIP logo

eve-auth-jwt's People

Contributors

bretkikehara avatar carl-chinatomby avatar eventh avatar reallyangrydude avatar rs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eve-auth-jwt's Issues

why JWTAuth extend BasicAuth?

the JWTAuth extend the BasicAuth what mean that it should implement the check_auth method, which is
not implemented.

when i add it in my module : app = Eve(auth=JWTAuth), i get the following error:

{
"status": "ERR",
"error": {
"message": "Please provide proper credentials",
"code": 401
}
}

My Question: is this module uptodate? when yes, how it should be used

Add asynk key token generate

Here is my contribution, if you want to join in your project.

# -*- coding: utf-8 -*-
import datetime
import jwt
from jwt.algorithms import RSAAlgorithm

import logging
logger = logging.getLogger(__name__)

class Token(object):
    """Usage:
    t = Token()
    str_token = t.generate(payload_dict, path_to_private_key, expiration_in_seconds)
    payload_dict = t.verify(str_token, path_to_public_key)
    """

    def verify(self, token, prublic_key_file):
        """ Verify token. """
        algo = RSAAlgorithm(RSAAlgorithm.SHA256)

        logger.debug("reading pub shakey")
        with open(prublic_key_file, 'r') as f:
            shakey = algo.prepare_key(f.read())
        logger.debug(shakey)

        payload = jwt.decode(token, key=shakey)
        logger.debug("payload = {0}".format(payload))

        return payload

    def generate(self, payload, private_key_file, expiration=600):
        """ Generate token. """
        algo = RSAAlgorithm(RSAAlgorithm.SHA256)

        with open(private_key_file, 'r') as f:
            shakey = algo.prepare_key(f.read())

        payload.update({
            'exp': datetime.datetime.utcnow() + datetime.timedelta(seconds=expiration)
        })
        logger.debug("payload = {0}".format(payload))

        token = jwt.encode(payload, key=shakey, algorithm='RS256')
        logger.debug("token generated = {0}".format(token.decode('ascii')))

        return token.decode('ascii')

Release of a new version

Would it be possible to create a new release of eve-auth-jwt? The last release was over 1.5 years ago :)

check_token fails for endpoints without DOMAIN entry

check_token fails for endpoints without DOMAIN entry, this is for example the case if you set SCHEMA_ENDPOINT, on the root /schema it will always fail because this resource_conf = config.DOMAIN[resource] it is a pretty easy fix, I changed it to this resource_conf = config.DOMAIN.get(resource, {}) .

I fixed it on my own fork, but did not add unit tests, if you accept pr, i will make one to fix this. I am leaving this for reference here, because it seems like the repo is not being updated lately.
Cheers,

Wrong header returned by authenticate()

The authenticate method is returning:

('WWW-Authenticate', 'Bearer realm="eve_auth_jwt", error="invalid_token"'): ('Content-Type', 'text/html; charset=utf-8')

instead of

WWW-Authenticate: Bearer realm="eve_auth_jwt", error="invalid_token"

which, apart of being an invalid header, makes gunicorn fail with HTTP error code 400, and the message "Invalid HTTP header name".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.