Python authentication/authorization framework - python

I'm developing a REST API in python with tornado and I'm going to implement the authentication and authorization, trying to avoid lock-in to other big projects i.e django. I'm looking around through forums and SO too and I've fond a solution that could fit: repoze.who/what.
It seems a good solution but I'm a bit scared about the activity of the projects (repoze.what last release seems to be 1.0.9 (2010-03-04)) and if it can work with async IO.
Anyone have tried it and/or knows something else?

Few months ago, I wrote python-auth. It's simple to use with a RESTFul API.
Install:
pip install auth
Run:
auth-server
Usage:
In your code:
from auth.client import Client
service = Client('srv201', '<Auth-Server IP:PORT>')
print(service)
service.get_roles()
service.add_role(role='admin')
Or use RESTFul API

Related

What is a good alternative to Firebase for user management, more specifically for Python?

What is an alternative to firebase for user management/auth for python apps. I know I can use node.js w/ firebase but, I would rather authenticate users through a managed 3rd party API in python using HTTPS requests,if possible. Appery.io has this feature but, I do not need all that comes with appery.io
Check out Amazon Cognito . They offer a quite nice package for small projects. Backendless is also a fantastic service, providing authentication and database with very helpful documentation and also SDK for different platforms including iOS, Android, Javascript, Rest API, Angular, React and React Native. I have been using Backendless for a couple of months and I highly recommend you use it, too.
If you're looking for a self-hosted solution, Keycloak is a pretty robust option. If you want a service, Auth0 and Okta have quite a lot of features. They also offer a free tier with reasonable limits.
You could try using Auth0 for pure authentication management. The Auth0 python package can be found here.

Django 1.10 & Socket.IO with Python 3

I'm trying to find some "django-socketio" repo to use in my project. I using django 1.10 and python3. I really searched but I do not found working examples with python3.
My poor workaround
I started node project and put socket.io inside route
In my django view I send returning data to node route with my django session
I manage session coming from django inside my node and emit inside
route to client.
This work but I can't believe this is a good solution.. Anyone have other ideas? Or working examples with python3 and socketio?
Thanks!
If you want to use Websockets and Django you should consider https://github.com/django/channels. The alternative in Python would be using python tornado http://www.tornadoweb.org/en/stable/ or aiohttp (Python3.4+) http://aiohttp.readthedocs.io/en/stable/. Many of the implementations of Django with asynchronousity through gevent are outdated, experimental or abandoned, I found this https://github.com/jrief/django-websocket-redis but it uses Redis so no reason to not going back to django-channels.
In my opinion, as Socket.io is a layer over Websockets you will not find any project that supports fully the Socket.io spec as a ws server in Python as it is a native Node.js not officially ported to Python project, at least the latest one you are probably using, if you really need Socket.io features stick to Node.js and create a simple REST API in Django to load the backend data asynchronously from Nodejs (the REST django API will always be synchronous by nature), this is the best shot you would likely have.
https://github.com/django/channels/blob/master/docs/getting-started.rst
django-channels works with python3 and django >=1.8 :)
And you can change pip to pip3

GAE and Google API

I am trying to build a GAE application that shell use GCM API.
(I am working with Eclipse Juno, having GWT, ADT installed).
I am using Google's python example, and I can't make it work, I'd be really grateful
if you could advise me where am I loosing my way.
First it's probably important to note that I have created a project in the Console, activated
the API, and got my project whitelisted by Google. So far so good?
I have created a python GAE project, based on Google's example in the following link -
http://developer.android.com/google/gcm/ccs.html
At this point I face the following difficulty -
client = xmpp.Client('gcm.googleapis.com', debug=['socket'])
The Client class is not recognized by the pre-interpreter. When I check in the XMPP package,
it looks though this class actually doesn't exist there... - how to handle this one?
I've tried to add the GCM APIs to the project, thinking that this might be the problem,
but the G->Add Google APIs...->Selection proposes all APIs but GCM.
My next step was to try installing google-api-python-client-gae-1.2.
I've found the following guide -
https://developers.google.com/api-client-library/python/start/get_started#simple
I've installed the lib, and then paid attention to the fact that in GAE, all source should be present in the project lib - so I have manually copied "apiclient" lib's content to my src lib.
Nevertheless, for the following line I've added from Google's example -
service = build('my_service', 'v1', developerKey=api_key)
when I run the GCC application, the following error occurs:
from apiclient.discovery import build
ImportError: No module named apiclient.discovery
I'm struggling through those issues quite a while, please help...
You're mostly headed in the wrong direction.
App Engine's XMPP API lets you send and respond to XMPP messages. See the docs:
https://developers.google.com/appengine/docs/python/xmpp/
There's no "Client" class. You have to code against the API provided by the XMPP service.
You're better off just using the HTTP connection server instead of XMPP. It's more straightfoward:
http://developer.android.com/google/gcm/http.html
http://developer.android.com/google/gcm/server.html says
Note that Google AppEngine does not support connections to CCS

RESTful Web service or API for a Python program in WebFaction

I have developed a few python programs that I want to make available online.
I am new to web services, and I am not sure what I need to do in order to create a service where somebody makes a request to an URL (for example), and the URL triggers a Python program that displays something in the user's browser, or a set of inputs are given to the program via browser, and then python does whatver it is supposed to do.
I was playing with the google app engine, which runs fine with the tutorial, and was planning to use it becuase it looks easy, but the problem with GAE is that it does not work well (or does not work at all) with some libraries that I plan to use.
I guess what I am trying to do is some sort of API using my WebFaction account.
Can anybody point me in the right directions? What choices do I have in WebFaction? What are the easiest tools available?
Thank you very much for your help in advance.
Cheers
Well, your question is a little bit generic, but here are a few pointers/tips:
Webfaction allows you to install pretty much anything you want (you need to compile it / or ask the admins to install some CentOS package for you).
They provide some default Apache server with mod_wsgi, so you can run web2py, Django or any other wsgi frameworks.
Most popular Python web frameworks have available installers in Webfaction (web2py, django...), so I would recommend you to go with one of them.
I would also install supervisord to keep your service running after some reboot/crash/problem.
I would be glad to help you if you have any specific question...

What python based ajax push servers are good to work with

I have a web application im currently working on in python. I'm using Django as my web framework currently. I intend to integrate real-time web features into the application using ajax push. However, I'm a bit confused as to what python based push server i should adopt. I've heard of a few of them, Orbited, Gevent, Tornado, but my main issue right now is that i'm a green horn when it comes to realtime web applications. I'd like to use python and i'd like a framework with good documentation.
A lot of people choose gevent for webapps with real-time features because of the speed, ease of use and a number of supporting packages.
Take a look at these packages:
gevent-socketio
django-socketio
and these tutorials:
Evented Django part one: Socket.IO and gevent
New and hot, part 4: Pyramid, Socket.IO and Gevent
Real-time Web Apps with Django and WebSockets
Hope this helps.
APE seems a cool thing.
I think it's not a problem to make it work with PDjango as a backend.
I think the most popular is tornado open-sourced by facebook. It also has pretty decent documentation.

Categories

Resources