linotp.lib.realm module

realm processing logic


Store Realm in the DB Realm Table. If the realm already exist, we do not need to store it

Parameters:realm (string) – the realm name

:return : if realm is created(True) or already esists(False) :rtype : boolean


delete the realm from the Database Table with the given name

Parameters:realmname (string) – the to be deleted realm

return the default realm - lookup in the config for the DefaultRealm key

Returns:the realm name

:rtype : string

linotp.lib.realm.getRealmObject(name=u'', id=0)[source]

returns the Realm Object for a given realm name. If the given realm name is not found, it returns “None”

Parameters:name (string) – realmname to be searched

TODO: search by id not implemented, yet :param id: id of the realm object :type id: integer

:return : realmObject - the database object :rtype : the sql db object


lookup for a defined realm or all realms

Note:the realms dict is inserted into the LinOtp Config object

so that a lookup has not to reparse the whole config again

Parameters:aRealmName (string) – a realmname - the realm, that is of interestet, if empty, all realms are returned
Returns:a dict with realm description like
:rtype : dict : {
u’myotherrealm’: {

‘realmname’: u’myotherrealm’, ‘useridresolver’: [

‘useridresolver.PasswdIdResolver.IdResolver.myOtherRes’ ],

‘entry’: u’’},

u’mydefrealm’: {

‘default’: ‘true’, ‘realmname’: u’mydefrealm’, ‘useridresolver’: [

‘useridresolver.PasswdIdResolver.IdResolver.myDefRes’ ],

‘entry’: u’’},

u’mymixrealm’: {

‘realmname’: u’mymixrealm’, ‘useridresolver’: [

‘useridresolver.PasswdIdResolver.IdResolver.myOtherRes’, ‘useridresolver.PasswdIdResolver.IdResolver.myDefRes’ ],

entry’: u’’}}


check, if a realm already exists or not

Parameters:realm (string) – the realm, that should be verified

:return :found or not found :rtype :boolean

linotp.lib.realm.match_realms(request_realms, allowed_realms)[source]

Check if all requested realms are also allowed realms and that all allowed realms exist and return a filtered list with only the matched realms. In case of ‘*’ in reques_realms, return all allowed realms including /:no realm:/

  • allowed_realms – list of realms from request (without ‘*’)
  • request_realms – list of allowed realms according to policies

list of realms which were in both lists

linotp.lib.realm.parse_default_realm(composite_key, value)[source]

Sets the attribute pair {default: True} to the default realm in the tree.

linotp.lib.realm.parse_realm(composite_key, value)[source]

Parses realm data from a config entry


convert a list of realm names to a list of realmObjects

Parameters:realmList (list) – list of realnames
Returns:list of realmObjects
Return type:list
linotp.lib.realm.setDefaultRealm(defaultRealm, check_if_exists=True)[source]

set the defualt realm attrbute

Note:verify, if the defualtRealm could be empty :”“
Parameters:defaultRealm – the default realm name
Returns:success or not
Return type:boolean