Exemple #1
0
 def doBasicLogin(self, params):
     config_params = {}
     config_params['password'] = params['password']
     userid = params['userid']
     form_data = simplejson.dumps(config_params)
     url = backend_auth_server+"/user/login/"+userid
     results = urlfetch.fetch(url=url,
                     payload=form_data,
                     method=urlfetch.POST,
                     headers={'Content-Type': 'application/json'})
     login_data = json.loads(results.content)
     logger.info("Login results")
     logger.info(login_data)
     sid = json_utils.convert(login_data[u'sid'])
     expires = json_utils.convert(login_data[u'expires'])
     userid = json_utils.convert(login_data[u'userid'])
     decision = json_utils.convert(login_data[u'decision'])
     decision_data = {};
     logger.info("decision: ")
     logger.info(decision)
     decision_data['decision'] = decision
     self.response.set_cookie('SACSID',value=sid)
     self.response.set_cookie('dev_appserver_login', value=sid)
     self.response.set_cookie('user', value=userid)
     self.response.headers['Content-Type'] = 'application/json'
     batch_json = simplejson.dumps(decision_data)
     self.response.out.write(batch_json)
Exemple #2
0
 def doLogin(self):
     logger.info('self.query')
     logger.info(self.query)
     if 'submit' in self.query:
         if 'user' in self.query:
             self.user = self.query['user']
             results = self.submitOpenId(self.user)
             login_data = json.loads(results.content)
             logger.info("Login results")
             logger.info(login_data)
             sid = json_utils.convert(login_data[u'sid'])
             expires = json_utils.convert(login_data[u'expires'])
             userid = json_utils.convert(login_data[u'userid'])
             self.response.set_cookie('SACSID',value=sid)
             self.response.set_cookie('dev_appserver_login', value=sid)
             self.response.set_cookie('user', value=userid)
         else:
             self.user = None
         self.redirect(self.query['success_to'])
     elif 'cancel' in self.query:
         self.redirect(self.query['fail_to'])
     else:
         assert 0, 'strange login %r' % (self.query,)
Exemple #3
0
    def post(self,method):
        #print "in OpenID AUth service post with request: "
        #print self.request
        self.path = self.request.url
        self.parsed_uri = urlparse(self.path)

        data = json.loads(self.request.body)
        data = json_utils.convert(data)

        path = self.parsed_uri[2]
        if path == '/login':
            logger.info(data)
            self.doBasicLogin(data)
        elif path == '/allow':
            self.handleAllow(self.query)
        else:
            self.response.status ='404 Not Found'