def login(self, system_id, extra_data={}): """ Clients v2+ Log in routine. Return a dictionary of session token/channel information. Also sets this information in the headers. """ log_debug(5, system_id) # Authenticate the system certificate. We need the user record # to generate the tokens self.load_user = 1 server = self.auth_system('login', system_id) # log the entry log_debug(1, self.server_id) # Update the capabilities list rhnCapability.update_client_capabilities(self.server_id) # Fetch the channels this client is subscribed to channels = rhnChannel.getSubscribedChannels(self.server_id) rhnServerTime = str(time.time()) expireOffset = str(CFG.CLIENT_AUTH_TIMEOUT) signature = computeSignature(CFG.SECRET_KEY, self.server_id, self.user, rhnServerTime, expireOffset) loginDict = { 'X-RHN-Server-Id': self.server_id, 'X-RHN-Auth-User-Id': self.user, 'X-RHN-Auth': signature, 'X-RHN-Auth-Server-Time': rhnServerTime, 'X-RHN-Auth-Expire-Offset': expireOffset, # List of lists [[label,last_mod],...]: 'X-RHN-Auth-Channels': channels } # Duplicate these values in the headers so that the proxy can # intercept and cache them without parseing the xmlrpc. transport = rhnFlags.get('outputTransportOptions') for k, v in loginDict.items(): # Special case for channels if string.lower(k) == string.lower('X-RHN-Auth-Channels'): # Concatenate the channel information column-separated transport[k] = [string.join(x, ':') for x in v] else: transport[k] = v log_debug(5, "loginDict", loginDict, transport) # store route in DB (schema for RHN 3.1+ only!) server_route.store_client_route(self.server_id) return loginDict
def login(self, system_id, extra_data={}): """ Clients v2+ Log in routine. Return a dictionary of session token/channel information. Also sets this information in the headers. """ log_debug(5, system_id) # Authenticate the system certificate. We need the user record # to generate the tokens self.load_user = 1 server = self.auth_system('login', system_id) # log the entry log_debug(1, self.server_id) # Update the capabilities list rhnCapability.update_client_capabilities(self.server_id) # Fetch the channels this client is subscribed to channelList = rhnChannel.channels_for_server(self.server_id) channels = [] for each in channelList: if not each.has_key('last_modified'): # No last_modified attribute # Probably an empty channel, so ignore continue channel = [each['label'], each['last_modified']] # isBaseChannel if each['parent_channel']: flag = "0" else: flag = "1" channel.append(flag) # isLocalChannel if each['local_channel']: flag = "1" else: flag = "0" channel.append(flag) channels.append(channel) rhnServerTime = str(time.time()) expireOffset = str(CFG.CLIENT_AUTH_TIMEOUT) signature = computeSignature(CFG.SECRET_KEY, self.server_id, self.user, rhnServerTime, expireOffset) loginDict = { 'X-RHN-Server-Id': self.server_id, 'X-RHN-Auth-User-Id': self.user, 'X-RHN-Auth': signature, 'X-RHN-Auth-Server-Time': rhnServerTime, 'X-RHN-Auth-Expire-Offset': expireOffset, # List of lists [[label,last_mod],...]: 'X-RHN-Auth-Channels': channels } # Duplicate these values in the headers so that the proxy can # intercept and cache them without parseing the xmlrpc. transport = rhnFlags.get('outputTransportOptions') for k, v in loginDict.items(): # Special case for channels if string.lower(k) == string.lower('X-RHN-Auth-Channels'): # Concatenate the channel information column-separated transport[k] = map(lambda x: string.join(x, ':'), v) else: transport[k] = v log_debug(5, "loginDict", loginDict, transport) # store route in DB (schema for RHN 3.1+ only!) server_route.store_client_route(self.server_id) return loginDict
def login(self, system_id, extra_data={}): """ Clients v2+ Log in routine. Return a dictionary of session token/channel information. Also sets this information in the headers. """ log_debug(5, system_id) # Authenticate the system certificate. We need the user record # to generate the tokens self.load_user = 1 server = self.auth_system('login', system_id) # log the entry log_debug(1, self.server_id) # Update the capabilities list rhnCapability.update_client_capabilities(self.server_id) # Fetch the channels this client is subscribed to channelList = rhnChannel.channels_for_server(self.server_id) channels = [] for each in channelList: if not each.has_key('last_modified'): # No last_modified attribute # Probably an empty channel, so ignore continue channel = [each['label'], each['last_modified']] # isBaseChannel if each['parent_channel']: flag = "0" else: flag = "1" channel.append(flag) # isLocalChannel if each['local_channel']: flag = "1" else: flag = "0" channel.append(flag) channels.append(channel) rhnServerTime = str(time.time()) expireOffset = str(CFG.CLIENT_AUTH_TIMEOUT) signature = computeSignature(CFG.SECRET_KEY, self.server_id, self.user, rhnServerTime, expireOffset) loginDict = { 'X-RHN-Server-Id' : self.server_id, 'X-RHN-Auth-User-Id' : self.user, 'X-RHN-Auth' : signature, 'X-RHN-Auth-Server-Time' : rhnServerTime, 'X-RHN-Auth-Expire-Offset' : expireOffset, # List of lists [[label,last_mod],...]: 'X-RHN-Auth-Channels' : channels } # Duplicate these values in the headers so that the proxy can # intercept and cache them without parseing the xmlrpc. transport = rhnFlags.get('outputTransportOptions') for k, v in loginDict.items(): # Special case for channels if string.lower(k) == string.lower('X-RHN-Auth-Channels'): # Concatenate the channel information column-separated transport[k] = map(lambda x: string.join(x, ':'), v) else: transport[k] = v log_debug(5, "loginDict", loginDict, transport) # store route in DB (schema for RHN 3.1+ only!) server_route.store_client_route(self.server_id) return loginDict
raise rhnFault(70), None, sys.exc_info()[2] except rhnChannel.BaseChannelDeniedError, channel_error: raise rhnFault(71), None, sys.exc_info()[2] except server_lib.rhnSystemEntitlementException, e: # right now, don't differentiate between general ent issues & rhnNoSystemEntitlementsException raise rhnFault(90), None, sys.exc_info()[2] if CFG.SEND_EOL_MAIL and user and newserv.base_channel_is_eol(): self.attempt_eol_mailing(user, newserv) # XXX: until this is complete, bug: # http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=112450 # store route in DB (schema for RHN 3.1+ only!) server_route.store_client_route(newserv.getid()) return {'server' : newserv,} def new_system(self, data): """ This function expects at the INPUT a dictionary that has at least the following members: username, password, os_release, email If the username does not exist, it is created. If the username exists, then password is checked for a match. If all is well, we send back a server certificate. -- Hash -- Struct