Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lite version of session.pl #1882

Closed
Tracked by #5523
teolemon opened this issue Jun 6, 2019 · 8 comments
Closed
Tracked by #5523

Lite version of session.pl #1882

teolemon opened this issue Jun 6, 2019 · 8 comments
Labels
🔐 API auth The API requires auth in order to perform editing.There is a common mechanism & a Robotoff mechanism API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) ✨ Feature Features or enhancements to Open Food Facts server 🎯 P1 candidate

Comments

@teolemon
Copy link
Member

teolemon commented Jun 6, 2019

On android we used /cgi/session.pl to check the user login info. This call returns a html document that is parsed to "guess" the status.
Can we add an option to send back a much smaller payload, possibly JSON.
/cgi/session.pl?json=true
?

@teolemon teolemon added the 🐛 bug This is a bug, not a feature request. label Jun 6, 2019
@hangy
Copy link
Member

hangy commented Jun 6, 2019

You could already use /cgi/sso.pl for that. As the calling user agent, you have the user's cookie and it to verify the session is still OK. For example, with the session cookie value user_session&SOMERANDOMSESSIONIDHERE&user_id&foobar, you could call https://world.openfoodfacts.org/cgi/sso.pl?user_id=foobar&user_session=SOMERANDOMSESSIONIDHERE and would get the following JSON object for a logged in user {"user_id":"foobar","name":"ˈfoo bar","email":"foobar@example.de"}. For an invalid session, {"user_id":null} is returned.

Alternatively, wait for #1714.

@hangy hangy added 🔐 API auth The API requires auth in order to perform editing.There is a common mechanism & a Robotoff mechanism ✨ Feature Features or enhancements to Open Food Facts server and removed 🐛 bug This is a bug, not a feature request. labels Jun 6, 2019
@stephanegigandet
Copy link
Contributor

This is for the ios and android app, they have the user login and password, it's to verify it the first time.

@hangy
Copy link
Member

hangy commented Jun 6, 2019

I understand that, but IMHO we should focus on a token based authentication for apps instead of trying to patch the current way. 🤷‍♂

Just have them POST login data to /cgi/session.pl. If they get back a useful session cookie, the login was successful; otherwise the credentials were incorrect. (No need to parse the HTML.) In case they need additional information about the user or they need to verify that the session is still valid, they can query /cgi/sso.pl as described above.

@stephanegigandet
Copy link
Contributor

That approach sounds good to me. :)

@VaiTon VaiTon added the API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) label Jun 24, 2019
@teolemon
Copy link
Member Author

https://world.openfoodfacts.org/cgi/sso.pl returns null for me

@teolemon
Copy link
Member Author

@VaiTon relevant for your ongoing work

@VaiTon
Copy link
Member

VaiTon commented May 30, 2020

@hangy what about mobile native sign-up process?

@teolemon
Copy link
Member Author

I believe the new #7465 solves this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔐 API auth The API requires auth in order to perform editing.There is a common mechanism & a Robotoff mechanism API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) ✨ Feature Features or enhancements to Open Food Facts server 🎯 P1 candidate
Projects
Development

No branches or pull requests

4 participants