Coder Social home page Coder Social logo

aeoid's Introduction

AEoid - An easy OpenID library for App Engine

What's this?

AEoid is a library for App Engine that makes it quick and easy to handle user authentication with OpenID. It follows the mantra of "convention over configuration", allowing you to get started as quickly as possible, and its interface is as close to the App Engine Users API as possible, allowing you to leverage your existing knowledge.

No knowledge of OpenID workings are expected. To see how easy it is, read on...

Status

AEoid is currently in an alpha 'first look' phase. Its features are fairly limited, and the interface is subject to change. Your feedback is appreciated, so please file bug reports and feature requests.

Installation

The first thing you need to do is download AEoid. After downloading, unpack it and copy the 'aeoid' subdirectory into your App Engine app's root directory.

AEoid does its magic by using a piece of WSGI middleware. In order to use it in your app, you need to include the middleware in your app. If you're using App Engine's built in webapp framework, or any other framework that calls the run_wsgi_app function, you can use App Engine's configuration framework to install AEoid. Create a file called "appengine_config.py" in your app's root directory, and put the following in it:

from aeoid import middleware

def webapp_add_wsgi_middleware(app):
  app = middleware.AeoidMiddleware(app)
  return app

If your framework doesn't use run_wsgi_app, you need to insert the middleware into your processing chain. For example, here's how it's done in the webapp framework without run_wsgi_app:

application = webapp.WSGIApplication([
    # ...
], debug=True)
application = middleware.AeoidMiddleware(application)

Using AEoid

Now that you've installed AEoid, you can start using it in almost the same manner as the App Engine Users API. For example:

from aeoid import users

class SomeData(db.Model):
  user = users.UserProperty() # Note, _not_ db.UserProperty
  # ...

user = users.get_current_user()
if user:
  logging.debug("Nickname is %s, email is %s, ID is %s", 
                user.nickname(), user.email(), user.user_id())
  data = SomeData(user=user)
  data.put()

A few differences between AEoid's interface and that of the Users API warrant mention:

  • You can't construct a User object without supplying an OpenID URL.
  • Nicknames are user-supplied, and not guaranteed to be unique.
  • Email addresses are likewise user-supplied, and not guaranteed to be unique, or even owned by the user claiming them. If unsure, validate!
  • is_current_user_admin() is not currently implemented.
  • login: required and login: admin clauses in app.yaml are not affected by AEoid, and still use the regular Users API. Don't use them unless you want to authenticate using the regular API.

That's it! Go wild!

Components

AEoid uses the python-openid library for the grunt work of authenticating with OpenID, and the beaker sessions library for tracking user sessions.

The current beaker session can be accessed via the 'beaker.session' variable of the WSGI environment, though this keyword may change in future. Beaker can be configured by passing a dictionary of arguments to the AeoidMiddleware function as a second argument.

Currently, it's not possible to configure the OpenID library, though this will likely change in the near future.

Compatibility

AEoid should be compatible with most frameworks, though so far it has only been tested with the webapp framework. It may have problems integrating with frameworks that include their own copy of beaker or python-openid.

If you are using AEoid with a framework other than webapp, please let us know so we can add it to the list. If it's not working, please file a bug!

aeoid's People

Contributors

evank 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  avatar

Watchers

 avatar  avatar  avatar

aeoid's Issues

Make beaker and python-openid into subpackages.

Modify the beaker and python-openid libraries to be subpackages, so they can be imported directly rather than requiring path manipulations, which may interfere with frameworks that include one or both of these libraries. This will require changing import statements throughout the libraries.

Enhance documentation

More complete documentation is needed, including information for users on how to include login forms directly rather than sending users to a login page.

Extend the users API

We should add additional features such as requires_login decorators to the users module.

a javascript target is permitted in the logout view no url

In the logout view the 'continue' parameter is placed directly into the href value of the 'no' option without rejecting invalid url/locations (url which are not actual http link). So a javascript target is permitted ... for example   http://SITE.lol/_openid/logout?continue=javascript:alert(1)
results in the following html for the 'No' option : '<a href="javascript:alert(1)">No</a>'.

Support configuration of python-openid

Modify the library to support configuration of the openid module. Specifically, users should be able to choose what profile fields to request, as well as adding entirely different extensions to the openid request.

Change beaker's session key

Change the environment key beaker uses for sessions in order to work well with frameworks that already use beaker.

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.