简体   繁体   中英

Java - Google Cloud Endpoints custom authentication with sessions

I like Google Cloud Endpoints but I do not want to use the OAUTH2 authentication with Google Accounts.

Instead, my idea is to create my own authentication. Upon successful login, I would like the client to receive a unique session key that it can then use for all authenticated future calls for a given period.

Is there some established way to do this with Google Cloud Endpoints? Or has someone achieved something similar themselves?

Thank you.

In general what you need to:

1) on server side in login method generate session key, store it (indexed) with your custom User object to datastore and return from method;

2) on client side -- store this key as Cookie in browser with expiration time of your choice.

3) send session key (take it from cookie) as custom header ( example )

4) on server side in all methods (except login()) add your own Authentificator . In authenticate method compare key from request to one you stored.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM