Monday, October 13, 2008

Authentication for GWT based applications on Google App Engine

there is a way to use Java together with Google App Engine: GWT together with python-gwt-rpc. Although python-gwt-rpc has it's own means to allow authentication, there is also an easier way: just check in the Python code whether the user is authenticated and generate a login page or a page for hosting your GWT application.

...
from
google.appengine.api import users

class MyHandler(webapp.RequestHandler):
def get(self):
user
= users.get_current_user()
if user is None:
self.response.out.write('''Login page here...''')
else:
self.response.out.write('''GWT hosting page here...''')

here is how it looks in a live application

3 comments:

majo44 said...

Yes, you can use "standard" GEA authentication model. But what to do if you want to have own user accounts model (why all your users have to be google users ?). The auth pgr extension has been added for support custom user registration/autorization/authentication model.

Unknown said...

I decided to use Google accounts instead of rolling out my own authentication because:
1. there are many users with an existing Google account and they can login without registration just by entering the password
2. it's easier to implement
3. (for users that do not have a Google account) the registration is simple and supports for example CAPTCHAs

majo44 said...

OK, you can use Google accounts, but some peoples doesn't want to have Google account, next email etc. The Google accounts in GAE are related to business model of Google corporation, they want use your application to sold their products.

Also. Pgr-auth provide per method authentication, so whole app can be written in GWT (reg/sing up forms).

You can also mix the pgr-auth with google accounts. pgr-auth doesn't enforce the user accounts model, but provide simple auth technique for per method authentication.