All Projects → wndhydrnt → Python Oauth2

wndhydrnt / Python Oauth2

Licence: mit
[UNMAINTAINED] OAuth 2.0 provider written in python

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Python Oauth2

Sample Spring Oauth2 Microservices
some examples that show basic and more advanced implementations of oauth2 authorization mechanism in spring-cloud microservices environment
Stars: ✭ 109 (-12.1%)
Mutual labels:  oauth2
Spring Boot 2 Oauth2 Authorization Jwt
Spring Boot 2 OAuth2 JWT Authorization server implementation with Database for Users and Clients (JPA, Hibernate, MySQL)
Stars: ✭ 115 (-7.26%)
Mutual labels:  oauth2
Aura.auth
Provides a unified interface to local and remote authentication systems.
Stars: ✭ 121 (-2.42%)
Mutual labels:  oauth2
Ueberauth google
Google OAuth2 Strategy for Überauth.
Stars: ✭ 110 (-11.29%)
Mutual labels:  oauth2
K8s Gitops
Kubernetes cluster managed by GitOps - Git as a single source of truth, automated pipelines, declarative everything, next-generation DevOps
Stars: ✭ 110 (-11.29%)
Mutual labels:  oauth2
Swiftlysalesforce
The swiftest way to build iOS apps that connect to Salesforce
Stars: ✭ 115 (-7.26%)
Mutual labels:  oauth2
Flask Oauthlib
YOU SHOULD USE https://github.com/lepture/authlib
Stars: ✭ 1,429 (+1052.42%)
Mutual labels:  oauth2
Openiddict Core
Versatile OpenID Connect stack for ASP.NET Core and Microsoft.Owin (compatible with ASP.NET 4.6.1)
Stars: ✭ 2,275 (+1734.68%)
Mutual labels:  oauth2
Identitybase
IdentityBase is a Universal Identity Platform for web, mobile and IoT built on top of IdentityServer.
Stars: ✭ 112 (-9.68%)
Mutual labels:  oauth2
Slim Oauth2
Routes and Middleware for Using OAuth2 Server within a Slim Framework API
Stars: ✭ 121 (-2.42%)
Mutual labels:  oauth2
Blazor.auth0
The library for using Auth0 in Blazor applications.
Stars: ✭ 111 (-10.48%)
Mutual labels:  oauth2
Hoauth2
haskell oauth2 binding
Stars: ✭ 111 (-10.48%)
Mutual labels:  oauth2
Node Oauth2 Server Example
Working oauth2 server with minimal configuration
Stars: ✭ 115 (-7.26%)
Mutual labels:  oauth2
Laqul
A complete starter kit that allows you create amazing apps that look native thanks to the Quasar Framework. Powered by an API developed in Laravel Framework using the easy GraphQL queries language. And ready to use the Google Firebase features.
Stars: ✭ 110 (-11.29%)
Mutual labels:  oauth2
Yup Oauth2
An oauth2 client implementation providing the Device, Installed and Service Account flows.
Stars: ✭ 122 (-1.61%)
Mutual labels:  oauth2
Django Oauth2 Server
OAuth2 server written in Python with Django
Stars: ✭ 108 (-12.9%)
Mutual labels:  oauth2
Samples.aspnetcore Identityserver4
IdentityServer4 sample with .NET Core and ASP.NET Core 2.0
Stars: ✭ 115 (-7.26%)
Mutual labels:  oauth2
Fosite
Extensible security first OAuth 2.0 and OpenID Connect SDK for Go.
Stars: ✭ 1,738 (+1301.61%)
Mutual labels:  oauth2
Vertx Auth
Stars: ✭ 122 (-1.61%)
Mutual labels:  oauth2
Auth
Authenticator via oauth2
Stars: ✭ 118 (-4.84%)
Mutual labels:  oauth2

This project is not maintained anymore. If you are looking for a OAuth 2.0 library to integrate into your Python application, I recommend oauthlib <https://pypi.org/project/oauthlib/>_.

python-oauth2 #############

python-oauth2 is a framework that aims at making it easy to provide authentication via OAuth 2.0 <http://tools.ietf.org/html/rfc6749>_ within an application stack.

Documentation <http://python-oauth2.readthedocs.org/en/latest/index.html>_

Status


.. image:: https://travis-ci.org/wndhydrnt/python-oauth2.png?branch=master :target: https://travis-ci.org/wndhydrnt/python-oauth2

python-oauth2 has reached its beta phase. All main parts of the OAuth 2.0 RFC <http://tools.ietf.org/html/rfc6749>_ such as the various types of Grants, Refresh Token and Scopes have been implemented. However, bugs might occur or implementation details might be wrong.

Installation


python-oauth2 is available on PyPI <http://pypi.python.org/pypi/python-oauth2/>_.

pip install python-oauth2

Usage


Example Authorization server

.. code-block:: python

from wsgiref.simple_server import make_server
import oauth2
import oauth2.grant
import oauth2.error
import oauth2.store.memory
import oauth2.tokengenerator
import oauth2.web.wsgi


# Create a SiteAdapter to interact with the user.
# This can be used to display confirmation dialogs and the like.
class ExampleSiteAdapter(oauth2.web.AuthorizationCodeGrantSiteAdapter,
                         oauth2.web.ImplicitGrantSiteAdapter):
    TEMPLATE = '''
<html>
    <body>
        <p>
            <a href="{url}&confirm=confirm">confirm</a>
        </p>
        <p>
            <a href="{url}&deny=deny">deny</a>
        </p>
    </body>
</html>'''

    def authenticate(self, request, environ, scopes, client):
        # Check if the user has granted access
        if request.post_param("confirm") == "confirm":
            return {}

        raise oauth2.error.UserNotAuthenticated

    def render_auth_page(self, request, response, environ, scopes,
                         client):
        url = request.path + "?" + request.query_string
        response.body = self.TEMPLATE.format(url=url)
        return response

    def user_has_denied_access(self, request):
        # Check if the user has denied access
        if request.post_param("deny") == "deny":
            return True
        return False

# Create an in-memory storage to store your client apps.
client_store = oauth2.store.memory.ClientStore()
# Add a client
client_store.add_client(client_id="abc", client_secret="xyz",
                        redirect_uris=["http://localhost/callback"])

site_adapter = ExampleSiteAdapter()

# Create an in-memory storage to store issued tokens.
# LocalTokenStore can store access and auth tokens
token_store = oauth2.store.memory.TokenStore()

# Create the controller.
provider = oauth2.Provider(
    access_token_store=token_store,
    auth_code_store=token_store,
    client_store=client_store,
    token_generator=oauth2.tokengenerator.Uuid4()
)

# Add Grants you want to support
provider.add_grant(oauth2.grant.AuthorizationCodeGrant(site_adapter=site_adapter))
provider.add_grant(oauth2.grant.ImplicitGrant(site_adapter=site_adapter))

# Add refresh token capability and set expiration time of access tokens
# to 30 days
provider.add_grant(oauth2.grant.RefreshToken(expires_in=2592000))

# Wrap the controller with the Wsgi adapter
app = oauth2.web.wsgi.Application(provider=provider)

if __name__ == "__main__":
    httpd = make_server('', 8080, app)
    httpd.serve_forever()

This example only shows how to instantiate the server. It is not a working example as a client app is missing. Take a look at the examples <docs/examples/>_ directory.

Supported storage backends


python-oauth2 does not force you to use a specific database. It currently supports these storage backends out-of-the-box:

  • MongoDB
  • MySQL
  • Redis
  • Memcached

However, you are not not bound to these implementations. By adhering to the interface defined by the base classes in oauth2.store, you can easily add an implementation of your backend. It also is possible to mix different backends and e.g. read data of a client from MongoDB while saving all tokens in memcached for fast access.

Take a look at the examples in the examples directory of the project.

Site adapter


Like for storage, python-oauth2 does not define how you identify a user or show a confirmation dialogue. Instead your application should use the API defined by oauth2.web.SiteAdapter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].