def post(web_req): action = web_req.get_argument("action") auth_hdr = web_req.get_argument('Authorization') if not auth_hdr: raise NotImplementedError("auth header not found") auth_decoded = base64.decodestring(auth_hdr) newpwd = None if action == 'changepwd': # fetch/decode old/new passwords account, user, passwd, newpwd = auth_decoded.split(':', 3) passwd = base64.decodestring(passwd) newpwd = base64.decodestring(newpwd) remember = 'yes' if (web_req.get_cookie("remember") == 'true') else 'no' else: account, user, passwd = auth_decoded.split(':', 2) remember = web_req.get_argument("remember") if config.getboolean('test', 'usemock') == False: auth = TokenAuthenticator( config.get('server', 'clchost'), config.getint('server', 'session.abs.timeout') + 60) creds = auth.authenticate(account, user, passwd, newpwd) session_token = creds.session_token access_id = creds.access_key secret_key = creds.secret_key else: # assign bogus values so we never mistake them for the real thing (who knows?) session_token = "Larry" access_id = "Moe" secret_key = "Curly" # create session and store info there, set session id in cookie while True: sid = os.urandom(16).encode('hex') if sid in sessions: continue break if using_ssl: web_req.set_cookie("session-id", sid, secure='yes') else: web_req.set_cookie("session-id", sid) if remember == 'yes': expiration = datetime.now() + timedelta(days=180) web_req.set_cookie("account", account, expires=expiration) web_req.set_cookie("username", user, expires=expiration) web_req.set_cookie("remember", 'true' if remember else 'false', expires=expiration) else: web_req.clear_cookie("account") web_req.clear_cookie("username") web_req.clear_cookie("remember") sessions[sid] = UserSession(account, user, session_token, access_id, secret_key) sessions[sid].host_override = None return LoginResponse(sessions[sid])
def post(web_req): auth_hdr = web_req.get_argument('Authorization') if not auth_hdr: raise NotImplementedError("auth header not found") auth_decoded = base64.decodestring(auth_hdr) account, user, passwd = auth_decoded.split(':', 2) remember = web_req.get_argument("remember") ec2_endpoint = None try: ec2_endpoint = config.get('test', 'ec2.endpoint') access_id = config.get('test', 'ec2.accessid') secret_key = config.get('test', 'ec2.secretkey') session_token = None #print "ec2: %s, $s, %s" %(ec2_endpoint, access_id, secret_key) except ConfigParser.Error: pass if ec2_endpoint == None: if config.getboolean('test', 'usemock') == False: auth = TokenAuthenticator( config.get('server', 'clchost'), config.getint('server', 'session.abs.timeout') + 60) creds = auth.authenticate(account, user, passwd) session_token = creds.session_token access_id = creds.access_key secret_key = creds.secret_key else: # assign bogus values so we never mistake them for the real thing (who knows?) session_token = "Larry" access_id = "Moe" secret_key = "Curly" # create session and store info there, set session id in cookie while True: sid = os.urandom(16).encode('hex') if sid in sessions: continue break if using_ssl: web_req.set_cookie("session-id", sid, secure='yes') else: web_req.set_cookie("session-id", sid) if remember == 'yes': expiration = datetime.now() + timedelta(days=180) web_req.set_cookie("account", account, expires=expiration) web_req.set_cookie("username", user, expires=expiration) web_req.set_cookie("remember", 'true' if remember else 'false', expires=expiration) else: web_req.clear_cookie("account") web_req.clear_cookie("username") web_req.clear_cookie("remember") sessions[sid] = UserSession(account, user, session_token, access_id, secret_key) return LoginResponse(sessions[sid])
def post(web_req): auth_hdr = web_req.get_argument('Authorization') if not auth_hdr: raise NotImplementedError("auth header not found") auth_decoded = base64.decodestring(auth_hdr) account, user, passwd = auth_decoded.split(':', 2) remember = web_req.get_argument("remember") ec2_endpoint = None try: ec2_endpoint = config.get('test', 'ec2.endpoint') access_id = config.get('test', 'ec2.accessid') secret_key = config.get('test', 'ec2.secretkey') session_token = None #print "ec2: %s, $s, %s" %(ec2_endpoint, access_id, secret_key) except ConfigParser.Error: pass if ec2_endpoint == None: if config.getboolean('test', 'usemock') == False: auth = TokenAuthenticator(config.get('server', 'clchost'), config.getint('server', 'session.abs.timeout')+60) creds = auth.authenticate(account, user, passwd) session_token = creds.session_token access_id = creds.access_key secret_key = creds.secret_key else: # assign bogus values so we never mistake them for the real thing (who knows?) session_token = "Larry" access_id = "Moe" secret_key = "Curly" # create session and store info there, set session id in cookie while True: sid = os.urandom(16).encode('hex') if sid in sessions: continue break if using_ssl: web_req.set_cookie("session-id", sid, secure='yes') else: web_req.set_cookie("session-id", sid) if remember == 'yes': expiration = datetime.now() + timedelta(days=180) web_req.set_cookie("account", account, expires=expiration) web_req.set_cookie("username", user, expires=expiration) web_req.set_cookie("remember", 'true' if remember else 'false', expires=expiration) else: web_req.clear_cookie("account") web_req.clear_cookie("username") web_req.clear_cookie("remember") sessions[sid] = UserSession(account, user, session_token, access_id, secret_key) return LoginResponse(sessions[sid])
def post(web_req): action = web_req.get_argument("action") auth_hdr = web_req.get_argument('Authorization') if not auth_hdr: raise NotImplementedError("auth header not found") auth_decoded = base64.decodestring(auth_hdr) newpwd = None if action == 'changepwd': # fetch/decode old/new passwords account, user, passwd, newpwd = auth_decoded.split(':', 3) passwd = base64.decodestring(passwd) newpwd = base64.decodestring(newpwd) remember = 'yes' if (web_req.get_cookie("remember") == 'true') else 'no'; else: account, user, passwd = auth_decoded.split(':', 2); remember = web_req.get_argument("remember") if config.getboolean('test', 'usemock') == False: auth = TokenAuthenticator(config.get('server', 'clchost'), config.getint('server', 'session.abs.timeout')+60) creds = auth.authenticate(account, user, passwd, newpwd) session_token = creds.session_token access_id = creds.access_key secret_key = creds.secret_key else: # assign bogus values so we never mistake them for the real thing (who knows?) session_token = "Larry" access_id = "Moe" secret_key = "Curly" # create session and store info there, set session id in cookie while True: sid = os.urandom(16).encode('hex') if sid in sessions: continue break if using_ssl: web_req.set_cookie("session-id", sid, secure='yes') else: web_req.set_cookie("session-id", sid) if remember == 'yes': expiration = datetime.now() + timedelta(days=180) web_req.set_cookie("account", account, expires=expiration) web_req.set_cookie("username", user, expires=expiration) web_req.set_cookie("remember", 'true' if remember else 'false', expires=expiration) else: web_req.clear_cookie("account") web_req.clear_cookie("username") web_req.clear_cookie("remember") sessions[sid] = UserSession(account, user, session_token, access_id, secret_key) sessions[sid].host_override = None return LoginResponse(sessions[sid])