Cross-domain authentication for REST api

71 views
Skip to first unread message

Ur. Kr.

unread,
Mar 28, 2017, 7:31:22 AM3/28/17
to web...@googlegroups.com
We need to make a REST api service for our website that will be accessed from arbitrary domains by partner companies, but we're having trouble with authentication.

We tried auth.is_logged_in(), but the problem is that login doesn't seem to work cross domain. A session is created on the server, but the request still doesn't get passed authentication. 

Is there anything built-in in web2py for this use case?


@request.restful()
def f():
    response
.headers["Access-Control-Allow-Origin"] = "*"
   
def GET(*args, **vars):
       
if auth.is_logged_in():

curl --user username:password http://127.0.0.1:8080/...  
Also doesn't seem to work. 

Kiran Subbaraman

unread,
Mar 28, 2017, 12:30:21 PM3/28/17
to web...@googlegroups.com
Just checking if you have set the response headers, to support CORS requests on web2py? This thread talks about it: https://groups.google.com/forum/#!searchin/web2py/CORS%7Csort:relevance/web2py/afT_SdNjt7k/QCLjOCAsCAAJ

In any case, I suspect you are facing something more here. A quick search for "CORS" and "login" on the web2py forum does come back with some interesting threads. You could, perhaps, take a look at them: https://groups.google.com/forum/#!searchin/web2py/CORS$20login%7Csort:relevance
________________________________________
Kiran Subbaraman
http://subbaraman.wordpress.com/about/
On Tue, 28-03-2017 5:01 PM, Ur. Kr. wrote:
We need to make a REST api service for our website that will be accessed from arbitrary domains by partner companies, but we're having trouble with authentication.

We tried auth.is_logged_in(), but the problem is that login doesn't seem to work cross domain. A session is created on the server, but the request still doesn't get passed authentication. 

Is there anything built-in in web2py for this use case?
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages