AppEngine WebService authentication handling - python

I'm doing a JSON WebService backend for an iPhone application. Is there any best practice or existing frameworks (I use Python) to handle authentication and keeping a session between requests? I guess you use some form of ticket system because you can't use regular sessions like with web browsers?

You should definitely go for Oauth.
Have a look to the gtm-oauth library, it allows Cocoa applications to sign in to services using OAuth for authentication and authorization and it works with Google APIs and with any standard OAuth provider.
Check this blog post for further information.

Related

Firebase (client-side vs server-side)

I'm building a PWA with django/python on the server-side and vue on the client-side and want to use firebase as a database as well as make use of the firebase authentication.
After some thorough research I realised that I had to make a few choices.
Question 1: Authentication
I can do authentication on the client-side or server-side. Which one would be best (more secure) ?
Question 2: Database
In terms of CRUDS I am a bit conflicted. Do I write all my data to firestore from the client-side?
Do I rather use api's to communicate with my backend and then write data to firestore from the backend? What are the security implications of doing this?
Should I just use both in terms of context? If there are no security implications I would do my authentication client-side and my CRUDS from the server-side. I think I would also have to check authentication to write to the database from the backend.
Authentication of a user's credentials should always happen on a server, as it can't be securely done on the client's computer. What Firebase Authentication allows however, is that the authentication runs on Google's servers, while you control it from a simple client-side API call.

How to generate request to the ADFS, get session and authenticate user on Django server?

I'm configure Web SSO authentication by using ADFS on this guide. Му back-end developed using Django. How to generate Django request for user authentication? As I understand request looks like this.:
decoded: adfsresource.treyresearch.net/adfs/ls/auth/integrated/?wa=wsignin1.0&wreply=https://adfsweb.treyresearch.net/claimapp/&wct=2016-07-27T14:58:30Z&wctx=5f64b4e7-8907-47df-9526-5450b4ce0660
How generate wctx on django?
I'm found:
Wctx: This is some session data that the application wants sent back
to it after the user authenticates. How generate wctx on django
What protocols using in this process (to adfs and back)?
ADFS 1.1, django 1.9.7, firefox
Thanks
Why don't you use directly the SAML protocol?. ADFS supports SAML and I think is easier to setup than ws-fed (and also more adopted).
You will need to add SAML support to the django app, in order to do that you have 2 alternatives:
django-saml-service-provider (uses python-saml library)
djangosaml2 (uses pysaml2 library)
Both are well documented.
Info about how configure ADFS as SAML Identity Provider here
Other alternative is to use Oauth2.

GAE: Authenticating via native iOS Facebook client?

I'm developing an application where the user will be able to log in via his Facebook account to use my GAE backend. I know that I have to first create a Facebook session on my iOS device (via the Facebook SDK or SimpleAuth) and pass it to GAE, but how do I do that? I know there is an option to use Lean-Engine, however it is Java based and my app is in Python and the iOS classes aren't quite that ready yet.
I'd like to use the Endpoints API to exchange data between the iOS device and GAE, but apparently it requires to use a Google account to use for login, according to this article. However, this is not as crucial. I want to avoid the user having to fill-in any kind of username/password to log in to the backend application.
How can I achieve this?

How to make Facebook Login possible in Django app ?

I have created a Django application. The app has a login functionality.
Can somebody help to find a way to make it possible to login using Facebook credential or point me some tutorials to implement it ?
Summary;
https://github.com/mlavin/django-all-access
https://github.com/pennersr/django-allauth
https://github.com/omab/django-social-auth
https://github.com/uswaretech/Django-Socialauth
https://github.com/hiidef/oauth2app
https://github.com/timetric/django-oauth
https://github.com/daaku/django-oauth-consumer
https://github.com/eldarion/django-oauth-access
https://github.com/dgouldin/python-oauth2
https://github.com/henriklied/django-twitter-oauth
https://launchpad.net/django-openid-auth
https://www.djangopackages.com/grids/g/oauth/
http://peterhudec.github.io/authomatic/
django-all-access
django-all-access is a reusable application for user registration and authentication from OAuth 1.0 and OAuth 2.0 providers such as Twitter and Facebook.
The goal of this project is to make it easy to create your own workflows for authenticating with these remote APIs. django-all-access will provide the simple views with sane defaults along with hooks to override the default behavior.
There is a simple demo application running on at http://allaccess-mlavin.dotcloud.com/ The full source of this application is include in the repository.
django-allauth
Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.
Supported Flows
Signup of both local and social accounts
Connecting more than one social account to a local account
Disconnecting a social account -- requires setting a password if only the local account remains
Optional instant-signup for social accounts -- no questions asked
E-mail address management (multiple e-mail addresses, setting a primary)
Password forgotten flow
E-mail address verification flow
Supported Providers
Dropbox (OAuth)
Facebook (both OAuth2 and JS SDK)
Github
Google (OAuth2)
LinkedIn
OpenId
Persona
SoundCloud (OAuth2)
Stack Exchange (OAuth2)
Twitch (OAuth2)
Twitter
Weibo (OAuth2)
Django Social Auth
Django Social Auth is an easy way to setup social authentication/authorization mechanism for Django projects.
Crafted using base code from django-twitter-oauth and django-openid-auth, it implements a common interface to define new authentication providers from third parties.
Supported Providers
Google OpenID
Google OAuth
Google OAuth2
Yahoo OpenID
OpenId like myOpenID
Twitter OAuth
Facebook OAuth
Django-Socialauth
What it does
Allow logging in via various providers.
Import contacts from various third party sites, to find out which of your
friends already use our service.
Logging In
This is a application to enable authentication via various third party sites.
In particular it allows logging in via
Twitter
Gmail
Facebook
Yahoo(Essentially openid)
OpenId
oauth2app
The oauth2app module helps Django site operators provide an OAuth 2.0 interface. The module is registered as an application.
django-oauth
This is a forked version of David Larlet's django-oauth.
One very important difference is that this version requires that you be running a real cache behind Django's caching framework.
django-oauth-access
Supported Providers
Twitter
LinkedIn
Yahoo
Facebook (using OAuth 2.0 — it is functional, but needs more work)
Likely any OAuth 1.0a compliant site
django-oauth-consumer
A django application providing infrastructure for consuming OAuth services. It is not for providing OAuth services.
Also useful:
http://developers.facebook.com/docs/guides/web/#login
http://developers.facebook.com/docs/guides/canvas/#auth
https://github.com/dgouldin/python-oauth2
https://github.com/henriklied/django-twitter-oauth
https://launchpad.net/django-openid-auth
https://www.djangopackages.com/grids/g/oauth/
http://peterhudec.github.io/authomatic/examples/django-simple.html
I highly recommend using django-social-auth. The README is very complete, and it also includes information for authenticating against other OAuth sources such as twitter, and against OpenID sources like Google and Yahoo. Of course, if you just wanted Facebook authentication, you can just use it for that.
There's also an included example application, which gives you some sample code to play with.
FOR MOBILE APPLICATION, if you are developing an application for ios/android with django in the backend, what you can do is login to facebook in the frontend using the facebook ios/android api. But this is not the final login for your app. Upon facebook-login, facebook gives you an access token which you can then send to your django backend along with your facebook username/email. In the back, django can use something like facebook python sdk to verify the username-access token pair by communicating with facebook. If verified, you can finally log in the user for your app.
Using the python sdk is easy, just read the tutorial and you will be communicating with facebook in seconds.
The new way of doing that is by using python-social-auth, as django-social-auth was deprecated in favor of python-social-auth and now supports other frameworks than Django such as Flask, Pyramid, Web.py and Tornado.
It also supports other major auth providers such as Microsoft, Google, Twitter, Amazon, GitHub and many more.
Here is a quick get-started way to configure it on Django:
How to sign in with the Google+ API using Django?
I can totally recommend django-allauth.
It just works!

Google App Engine Python Authentication from API

I'm currently building a Python webapp on the Google App Engine and I want to expose various parts of my application via a JSON API. This API may be used in the form of a mobile client, or (for the purposes of testing) a headless Python script.
I need to be able to authenticate users before they perform operations on the API. I notice that the Users API does not support simple authentication [in the form of authenticate(username, password)] so merely sending the username/password to a URL and then later using some given token would not work.
Ultimately, I would like the application to use Facebook Connect in addition to its own logins.
Could somebody please suggest how is the best way to authenticate users in this situation, using a remote JSON API and the Google App Engine?
Cheers
You might want to check out the recently released oauth support. Failing that, you can implement your own authentication, for example by using simple or digest authentication.
Just for the record, I ended up going with the wonderful Tipfy framework in the end.

Categories

Resources