Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Appengine custom authentication

I would like to test appengine. At this moment it is not clear to me if there are libraries that support custom authentication. I want the user to be able to create an account on the site without having to have a google (or any other) account.

Does that kind of libraries exists or do you have to write it from scratch? Can anyone provide me with some step by step example? (if such library exists of course..)

(I would like to use Java if possible)

Thanks!

like image 983
Peter Avatar asked Mar 27 '26 00:03

Peter


1 Answers

I'm not aware about any libraries designed specifically for supporting custom login. However, what you need for is ability to store session-specific data and this is doable via Session library from gaeutilities that implements sessions based on cookies and datastore.

Link: http://gaeutilities.appspot.com/session

Example:

from appengine_utlities import sessions

def authenticate(login, password):
    user = User.all().filter('login', login).filter('password', password).get()
    if not user: return False

    s = sessions.Session()
    s["user"] = user
    return True

def is_authenticated():
    s = sessions.Session()
    return s.has_key("user")

def get_user():
    s = sessions.Session()
    return s["user"] if s.has_key("user") else None
like image 181
Xion Avatar answered Mar 28 '26 21:03

Xion



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!