linotp.useridresolver.HTTPIdResolver module

This module implements the UserIdResolver to access an user store via http and json

Dependencies: UserIdResolver

class linotp.useridresolver.HTTPIdResolver.IdResolver[source]

Bases: linotp.useridresolver.UserIdResolver.UserIdResolver


check the given sql field map against the sql table definition

checkPass(uid, password)[source]

checkPass - checks the password for a given uid.

  • uid (string) – userid to be checked
  • password (string) – user password

:return : true in case of success, false if password does not match :rtype : boolean

Todo:extend to support htpasswd passwords:

Hook to close down the resolver after one request

db_prefix = 'useridresolver.HTTPIdResolver.IdResolver'
classmethod getResolverClassDescriptor()[source]

return the descriptor of the resolver, which is - the class name and - the config description

Returns:resolver description dict
Return type:dict

TODO: adjust

classmethod getResolverClassType()[source]

provide the resolver type for registration


return the descriptor of the resolver, which is - the class name and - the config description

Returns:resolver description dict
Return type:dict

getResolverId - provide the resolver identifier

Returns:returns the resolver identifier string or empty string if not exist

:rtype : string


getResolverType - return the type of the resolver

Returns:returns the string ‘sqlresolver’
Return type:string

return all fields on which a search could be made

Returns:dictionary of the search fields and their types
Return type:dict

return the userId which mappes to a loginname

Parameters:loginName (string) – login name of the user
Returns:userid - unique idenitfier for this unser
Return type:string

return all user related information

@param userId: specied user @type userId: string @return: dictionary, containing all user related info @rtype: dict


retrieve a list of users

Parameters:searchDict (dict) – dictionary of the search criterias
Returns:list of user descriptions (as dict)

get the loginname from the given userid

Parameters:userId (string) – userid descriptor
Return type:string
loadConfig(config, conf='')[source]

loadConfig - load the config for the resolver

  • config (dict) – configuration for the sqlresolver
  • conf (string) – configuration postfix
classmethod setup(config=None, cache_dir=None)[source]

this setup hook is triggered, when the server starts to serve the first request

Parameters:config (the linotp config dict) – the linotp config
static testconnection(params)[source]

test the http connection - with a POST request on the userlist

dict: { ‘timeout’: u’5’,

‘type’: u’http’,

‘password’: u’Test123!’, ‘authuser’: u’admin’, ‘certificate’: u’ ‘, ‘resolvername’: u’dadas’, ‘uri’: u’’,

‘userlist_request_path’: u’/admin/userlist’, ‘userlist_result_path’: u’/result/value’, ‘userlist_request_mapping’: u’{“username”:”{USERNAME}”,


‘userlist_result_mapping’: u’{}’,

‘userid_result_mapping’: u’{}’, ‘userid_request_path’: u’/admin/userlist’, ‘userid_request_mapping’: u’{“userid”:”{USERID}”,


‘userid_result_path’: u’/result/value’,

‘username_request_mapping’: u’{“username”:”{USERNAME}”,

‘username_request_path’: u’/admin/userlist’} ‘username_result_path’: u’/result/value’, ‘username_result_mapping’: u’{}’,


urllib requires the parameters to be in UTF-8

Parameters:in_dict – the incomming dictionary
Returns:return a UTF-8 encoded dictionary
linotp.useridresolver.HTTPIdResolver.urllib_request(url, parameter, username=None, password=None, method='POST', config=None, timeout=10.0)[source]

build the urllib request and check the response for success or fail

  • url – target url
  • parameter – additonal parameter to append to the url request
  • username – basic authentication with username (optional)
  • password – basic authentication with password (optional)
  • method – run an GET or POST request
  • config – in case of Proxy support, the proxy settings are taken from
  • timeout – timeout for waiting on connect/reply

the response of the request