Open source cms for mobile and desktop websites

nive.security

User and security functions.

nive.security.GetUsers(app)

Loads all users from user database if available.

class nive.security.User(name, id=0)

A fake user object for testing.

InGroups(groups)

check if user has one of these groups

exception nive.security.Unauthorized

failed login

exception nive.security.UserFound(user)

Can be used in getuser listeners to break user lookup and pass a session user to LookupUser. The second argument is the session user

class nive.security.AdminUser(values, ident)

Admin User object with groups and login possibility.

Login()
Logout()
GetGroups(context=None)
InGroups(groups)

check if user has one of these groups

nive.security.SetupRuntimeAcls(acl, context)

Can be used during object initialisation to process acls. Acls can have a additional callback parameter called with the context to find out whetther to apply the single acl or not. The callback should return true or false. e.g.

(Allow, "group:reader", "read", lambda context: context.meta.pool_state),

or

def check(context):
    return context.meta.pool_state

(Allow, "group:reader", "read", check),
Parameters:
  • acl
  • context
Returns:

tuple of acls to be stored as __acl__

nive.extensions.localgroups

LocalGroups extension module

Security extension to handle local group assginments for users. Can be used for Roots and Objects or any other python class supporting events and id attribute (number). Uses idhash for root objects.

class nive.extensions.localgroups.LocalGroups
GetLocalGroups(username, user=None)

Group assignments use the user name. returns a list of all local user groups, including parent settings

AllLocalGroups()

returns a list of all local user group settings as list including [username, group, id]. This function does not include parent level settings.

AddOwner(user, **kw)

Add the current user as group:owner to local roles

AddLocalGroup(username, group)

Add a local group assignment for username.

RemoveLocalGroups(username, group=None)

Remove a local group assignment. If group is None all local groups will be removed.

RemoveGroups(**kw)

Remove all group assignments before deleting the object.

© 2013 Nive GmbH