def login(self, tx_id, auth_token, client_protocol = None, client_version = None, flags = 0): '''Client is trying to login.''' # check protocol version if client_protocol < version.CLIENT_PROTOCOL: return c2s.LoginResponse.STATUS_PROTOCOL_MISMATCH, None if client_protocol: self.client_protocol = client_protocol self.flags = flags try: userid = token.verify_user_token(auth_token, self.broker.keyring, str(self.config['server']['fingerprint'])) except: import traceback traceback.print_exc() log.debug("[%s] token verification failed: %s" % (tx_id, auth_token)) userid = None if userid: log.debug("[%s] user %s logged in." % (tx_id, userid)) self.userid = userid self.broker.register_user_consumer(userid, self, self.can_broadcast_presence(), self.supports_mailbox()) return c2s.LoginResponse.STATUS_LOGGED_IN, self.userid return c2s.LoginResponse.STATUS_AUTH_FAILED, None
def login(self, tx_id, auth_token, client_protocol=None, client_version=None, flags=0): '''Client is trying to login.''' # check protocol version if client_protocol < version.CLIENT_PROTOCOL: return c2s.LoginResponse.STATUS_PROTOCOL_MISMATCH, None if client_protocol: self.client_protocol = client_protocol self.flags = flags try: userid = token.verify_user_token( auth_token, self.broker.keyring, str(self.config['server']['fingerprint'])) except: import traceback traceback.print_exc() log.debug("[%s] token verification failed: %s" % (tx_id, auth_token)) userid = None if userid: log.debug("[%s] user %s logged in." % (tx_id, userid)) self.userid = userid self.broker.register_user_consumer(userid, self, self.can_broadcast_presence(), self.supports_mailbox()) return c2s.LoginResponse.STATUS_LOGGED_IN, self.userid return c2s.LoginResponse.STATUS_AUTH_FAILED, None
def authenticate(self, tx_id, auth_token): '''Client tried to authenticate.''' log.debug("[%s] deprecated authentication mode" % (tx_id, )) try: userid = token.verify_user_token(auth_token, self.broker.keyring, str(self.config['server']['fingerprint'])) except: import traceback traceback.print_exc() log.debug("[%s] token verification failed: %s" % (tx_id, auth_token)) userid = None if userid: log.debug("[%s] user %s logged in." % (tx_id, userid)) self.userid = userid self.broker.register_user_consumer(userid, self) return True return False
def login(self, request, data): '''Create a channel for the requested userid.''' try: auth = data['auth'] userid = token.verify_user_token(auth, self.broker.keyring, self.broker.fingerprint) except: import traceback traceback.print_exc() log.debug("token verification failed!") return utils.unauthorized(request) sid = utils.rand_str(40, utils.CHARSBOX_AZN_LOWERCASE) ch = EndpointChannel(self, sid, userid) self.broker.register_user_consumer(userid, ch, supports_mailbox=True, pending=False) log.debug("user %s logged in." % (userid, )) self.channels[sid] = ch return { 'id' : sid }
def authenticate(self, tx_id, auth_token): '''Client tried to authenticate.''' log.debug("[%s] deprecated authentication mode" % (tx_id, )) try: userid = token.verify_user_token( auth_token, self.broker.keyring, str(self.config['server']['fingerprint'])) except: import traceback traceback.print_exc() log.debug("[%s] token verification failed: %s" % (tx_id, auth_token)) userid = None if userid: log.debug("[%s] user %s logged in." % (tx_id, userid)) self.userid = userid self.broker.register_user_consumer(userid, self) return True return False
def login(self, request, data): '''Create a channel for the requested userid.''' try: auth = data['auth'] userid = token.verify_user_token(auth, self.broker.keyring, self.broker.fingerprint) except: import traceback traceback.print_exc() log.debug("token verification failed!") return utils.unauthorized(request) sid = utils.rand_str(40, utils.CHARSBOX_AZN_LOWERCASE) ch = EndpointChannel(self, sid, userid) self.broker.register_user_consumer(userid, ch, supports_mailbox=True, pending=False) log.debug("user %s logged in." % (userid, )) self.channels[sid] = ch return {'id': sid}