Thanks I'll explore this route. On Sun, Feb 17, 2013 at 7:14 PM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote:
> Yes I assumed both apps are written in web2py. Yet the protocol it uses is > CAS 2.0 therefore that works even if application A is not written in web2py > as long as it suports CAS 2.0. > > Another possibility is, if application A runs under apache, to use the > server access control to delegate authentication to web2py (application B). > For this look into web2py/scripts/access.wsgi. > > On Sunday, 17 February 2013 19:10:43 UTC-6, Amber Doctor wrote: > >> Hi Massimo, >> >> I'm going to explore this option more. Just a quick question though. It >> seems like both application A and B need to be web2py. Is that true? >> Application A isn't a web2py application. >> >> Also I learned more about the client's criteria -- they mostly just want >> a form on application A's website that has a username and password blank. >> On submit it redirects to a web2py application, authenticates the >> username/password and leaves the user logged in and at a page of the web2py >> application. Will the method you described handle this or is there a >> better method? >> >> >> On Sun, Feb 17, 2013 at 5:22 PM, Massimo Di Pierro <massimo....@gmail.com >> > wrote: >> >>> Hello Amber, >>> >>> You do not need to reinvent the wheel for this. Web2py can do it out of >>> the box. >>> >>> Application B. No special code. Just any web2py application that uses >>> Auth and exposes the normal default/user action. >>> >>> Application A. Use decorators like @auth.requires_login() as normal but >>> change >>> >>> auth = Auth(db) >>> >>> into >>> >>> auth = Auth(db,cas_provider = >>> 'http://127.0.0.1:8000/**applicaiton_B/default/user/cas >>> <http://127.0.0.1:8000/applicaiton_B/default/user/cas>**') >>> >>> >>> You can read more about this here: >>> >>> >>> http://web2py.com/books/**default/chapter/29/09?search=**cas_provider<http://web2py.com/books/default/chapter/29/09?search=cas_provider> >>> >>> If the two applications have different domains you need to add a line >>> like this in application B. >>> >>> auth.settings.cas_domains.**append('application_A_domain.**com') >>> >>> >>> >>> On Sunday, 17 February 2013 12:43:28 UTC-6, Amber Doctor wrote: >>>> >>>> Currently I have an application (A) that redirects the user to a web2py >>>> application (B) to log in. I want to change it so that the application A >>>> instead calls B with a username/password and gets back dict(user:user) >>>> where user is the result of auth.login_bare(username,**passw**ord). I >>>> have made a web2py app to mock A calling B with a Post. I have also >>>> created the method in B to accept the data. Controllers provided below. >>>> When I make the call, A is correctly getting the user information based on >>>> whether or not B is able to log in the user. However, when I try to >>>> navigate around application B's pages that are behind login, I'm told that >>>> I am not logged in. >>>> >>>> For a quick sanity check, I also created a controller marked C, that >>>> uses the auth.login_bare and not a POST and it works to log me into B >>>> >>>> Can anyone please provide insight into what I need to be doing >>>> differently to allow A to log into B by passing username/password? >>>> >>>> >>>> A >>>> def test_remote_login(): >>>> form = SQLFORM(db.remote_login).**proce**ss() >>>> if form.accepted: >>>> username = form.vars.remote_login_**usernam**e >>>> password = form.vars.remote_login_**passwor**d >>>> access_method = form.vars.access_method >>>> import httplib, base64, urllib >>>> params = urllib.urlencode({'username':**u**sername, >>>> **** 'password':password >>>> **** }) >>>> base64string = base64.encodestring('%s:%s' % (username , >>>> password))[:-1] >>>> username_password_combo = "Basic " + base64string >>>> headers = {"Content-type": "application/x-www-form-**urlenc**oded", >>>> "Accept": "text/plain", "Authorization": username_password_combo} >>>> conn = httplib.HTTPConnection(task_**tr**acker_host_defined) >>>> connection_url = '/tasktracker3/default/remote_****login' + >>>> access_method >>>> conn.request("POST", connection_url, params, headers) >>>> r1 = conn.getresponse() >>>> data1 = r1.read() >>>> conn.close() >>>> response.flash='Accepted' >>>> return locals() >>>> >>>> >>>> B >>>> @request.restful() >>>> def remote_login(): >>>> def POST(username,password): >>>> user = auth.login_bare(username,**passw**ord) >>>> return dict(user=user) >>>> return locals() >>>> >>>> C >>>> def test_remote_login(): >>>> username = request.args(0) >>>> password = request.args(1) >>>> user = auth.login_bare(username,**passw**ord) >>>> return dict(user=user) >>> >>> -- >>> >>> --- >>> 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/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >>> >> >> -- > > --- > 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+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.