Coder Social home page Coder Social logo

jwt_provider2's Introduction

JWT Provider v2

This module is a completely rework of the original jwt_provider, with a nice and cleaner codebase for developers to easily implement into their app.

Please note that this version is only compatible with odoo 14 (and above, maybe).


Quick link: Documentation


What's included?

  • Basic JWT auth that you can extend or write your own
  • Middleware mechanism - keep your controller logic nice and clean
# middleware
from odoo.addons.jwt_provider2.JwtRequest import JwtRequest, jwt_request
from odoo.addons.jwt_provider2.middleware.MiddlewareException import MiddlewareException

def require_api_key(req: JwtRequest, *kargs, **kwargs):
    api_key = req.headers.get('X-Api-Key')
    if api_key != 'secret':
        raise MiddlewareException('Invalid Api Key', 400, 'invalid_api_key')

# alias middleware
jwt_request.register_middleware('api_key', require_api_key)


# controller
from odoo import http
from odoo.addons.jwt_provider2.JwtRequest import jwt_request

class MyController(http.Controller):
    @http.route('/api/hello-world', type='json')
    @jwt_request.middlewares('api_key', 'middleware_first', '...')
    def hello(self, *kargs, **kwargs):
        return jwt_request.response({ 'message': 'hello world!' })

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.