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

checkMapping()[source]

check the given sql field map against the sql table definition

Returns:
checkPass(uid, password)[source]

checkPass - checks the password for a given uid.

Parameters:
  • 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: http://httpd.apache.org/docs/2.2/misc/password_encryptions.html
close()[source]
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]
getResolverDescriptor()[source]
getResolverId()[source]

getResolverId - provide the resolver identifier

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

:rtype : string

getResolverType()[source]

getResolverType - return the type of the resolver

Returns:returns the string ‘sqlresolver’
Return type:string
getSearchFields()[source]

return all fields on which a search could be made

Returns:dictionary of the search fields and their types
Return type:dict
getUserId(loginName)[source]

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
getUserInfo(userId)[source]

return all user related information

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

getUserList(searchDict)[source]

retrieve a list of users

Parameters:searchDict (dict) – dictionary of the search criterias
Returns:list of user descriptions (as dict)
getUsername(userId)[source]

get the loginname from the given userid

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

loadConfig - load the config for the resolver

Parameters:
  • 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’http://127.0.0.1:5001‘,

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

“page”:”{PAGE}”}’,

‘userlist_result_mapping’: u’{}’,

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

“page”:”{PAGE}”}’,

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

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

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

linotp.useridresolver.HTTPIdResolver.urllib_encoded_dict(in_dict)[source]

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

Parameters:
  • 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
Returns:

the response of the request

Table Of Contents

This Page