About this tutorial
This post explains how to implement in AppEngine a login system with the usual functionalities we’ll want to provide in all our apps: password encryption, mail reset…
The tutorial is actually part of a more general tutorial (PENDING) which includes also the client side because it’s based on the work I had to do when I moved to the JQuery + AppEngine technology. I had previously worked in AppInventor where I faced the same needs and also wrote a tutorial (https://eixerits.wordpress.com/2013/02/03/a-login-template/ ) that has received (and continues to receive) quite a few visits, so I’ve thought providing an analogous work for AppEngine could also be helpful for others.
What are we building
We’re going to implement server side support for an app that requires user identification. This will require publishing some services to:
- Create a new user account
- Verify the validity of a user-password combination
- Change an account information
- Change an account’s password
- Reset an account’s password and send it by email to the owner
As we can see, the sources contain a test page where we can try our services. For example:
- Create a user
- Verify the user can login
- Reset the password, forcing a new one to be randomly generated and sent by email
How to install
The steps to follow are the usual ones for any AppEngine project:
- Download the sources in any folder
- Create a project in AppEngine Console (https://console.cloud.google.com/)
- In the login-template-server folder, edit the app.yaml file in order to indicate the name of the project you’ve just created
- Deploy the project (e.g. using AppEngineLauncher or typing py update . from the login-template-server folder)
At this point, you should be able to execute the test page in the URL:
There’s only one functionality that requires some extra configuration, namely the ability to send emails in case of password reset. The post https://eixerits.wordpress.com/xxx explains how to perform this configuration.
However, this should not be the end of it, but rather the start. You should definitely delve into the sources in order to fully understand the code and adapt it to your specific needs. In order to work comfortably, you should be able to test the services locally, and here’s where you might experience some difficulties as it happened to me. If this is the case, you can have a look at these two posts:
– http://xxx.wordpress.com: several ways to solve problems when using the pycrypto library locally.
– http://xxx.wordpress.com: how to enable mail sending in the local development server
How it works
For a matter of space, we’ll explain the most complex aspects in 3 separate posts:
- Sending low-cost emails
- Encrypting passwords
- Using python libraries with the appengine local development server
The remainder should not be difficult to understand so I simply show the main class code here. Of course, I’ll be pleased to clarify any doubt you may encounter.