Package vita :: Package modules :: Package s3 :: Module s3aaa :: Class AuthS3
[hide private]
[frames] | no frames]

Class AuthS3

source code

gluon.tools.Auth --+
                   |
                  AuthS3

S3 extensions of the gluon.tools.Auth class

Instance Methods [hide private]
 
__init__(self, environment, deployment_settings, db=None)
Initialise parent class & make any necessary modifications
source code
 
__get_migrate(self, tablename, migrate=True) source code
 
define_tables(self, migrate=True)
to be called unless tables are defined manually
source code
 
login_bare(self, username, password)
Logs user in
source code
 
set_cookie(self)
Set a Cookie to the client browser so that we know this user has registered & so we should present them with a login form instead of a register form
source code
 
login(self, next=DEFAULT, onvalidation=DEFAULT, onaccept=DEFAULT, log=DEFAULT)
Overrides Web2Py's login() to use custom flash styles & utcnow
source code
 
register(self, next=DEFAULT, onvalidation=DEFAULT, onaccept=DEFAULT, log=DEFAULT)
Overrides Web2Py's register() to add new functionality:
source code
 
s3_register(self, form)
S3 framework function
source code
 
s3_link_to_person(self, user=None)
Links user accounts to person registry entries
source code
 
s3_approver(self, user)
Returns the Approver for a new Registration & the organisation_id field
source code
 
verify_email(self, next=DEFAULT, onaccept=DEFAULT, log=DEFAULT)
action user to verify the registration email, XXXXXXXXXXXXXXXX
source code
 
s3_update_staff_membership(self, record, delete=False)
Updates the staff's memberships of the roles associated with the organisation and/or site instance record which the staff is a component of Called from onaccept & ondelete
source code
 
s3_site_resource(self, site_id)
Returns the prefix, resource and id which a site refers to
source code
 
s3_logged_in(self)
Check whether the user is currently logged-in...
source code
 
s3_has_role(self, role)
Check whether the currently logged-in user has a role
source code
 
s3_group_members(self, group_id)
Get a list of members of a group
source code
 
s3_user_to_person(self, user_id)
Get the person_id for a given user_id
source code
 
s3_person_to_user(self, person_id)
Get the user_id for a given person_id
source code
 
person_id(self)
Get the person record ID for the current logged-in user
source code
 
s3_has_permission(self, method, table, record_id=0)
S3 framework function to define whether a user can access a record in manner "method" Designed to be called from the RESTlike controller
source code
 
s3_accessible_query(self, method, table)
Returns a query with all accessible records for the current logged in user
source code
 
s3_has_membership(self, group_id=None, user_id=None, role=None)
Checks if user is member of group_id or role
source code
 
has_membership(self, group_id=None, user_id=None, role=None)
Checks if user is member of group_id or role
source code
 
s3_requires_membership(self, role)
Decorator that prevents access to action if not logged in or if user logged in is not a member of group_id.
source code
 
requires_membership(self, role)
Decorator that prevents access to action if not logged in or if user logged in is not a member of group_id.
source code
 
s3_create_role(self, role, description, *acls)
Back-end method to create roles with ACLs
source code
 
s3_update_acl(self, role, c=None, f=None, t=None, oacl=None, uacl=None)
Back-end method to update an ACL
source code
 
s3_make_session_owner(self, table, record_id)
Makes the current session owner of this record
source code
 
s3_session_owns(self, table, record_id)
Checks whether the current session owns a record
source code
Method Details [hide private]

__init__(self, environment, deployment_settings, db=None)
(Constructor)

source code 

Initialise parent class & make any necessary modifications

__get_migrate(self, tablename, migrate=True)

source code 

define_tables(self, migrate=True)

source code 

to be called unless tables are defined manually

usages:

   # defines all needed tables and table files
   # UUID + "_auth_user.table", ...
   auth.define_tables()

   # defines all needed tables and table files
   # "myprefix_auth_user.table", ...
   auth.define_tables(migrate="myprefix_")

   # defines all needed tables without migration/table files
   auth.define_tables(migrate=False)

login_bare(self, username, password)

source code 

Logs user in

  • extended to understand session.s3.roles

set_cookie(self)

source code 

Set a Cookie to the client browser so that we know this user has registered & so we should present them with a login form instead of a register form

login(self, next=DEFAULT, onvalidation=DEFAULT, onaccept=DEFAULT, log=DEFAULT)

source code 

Overrides Web2Py's login() to use custom flash styles & utcnow

Returns:
a login form

register(self, next=DEFAULT, onvalidation=DEFAULT, onaccept=DEFAULT, log=DEFAULT)

source code 

Overrides Web2Py's register() to add new functionality:

  • Checks whether registration is permitted
  • Custom Flash styles
  • Allow form to be embedded in other pages
  • Optional addition of Mobile Phone field to the Register form
  • Optional addition of Organisation field to the Register form
  • Lookup Domains/Organisations to check for Whitelists &/or custom Approver
Returns:
a registration form

s3_register(self, form)

source code 

S3 framework function

Designed to be used as an onaccept callback for register()

Whenever someone registers, it:

  • adds them to the 'Authenticated' role
  • adds their name to the Person Registry
  • creates an entry in the Org_Staff table

s3_link_to_person(self, user=None)

source code 

Links user accounts to person registry entries

Policy for linking to pre-existing person records:

If and only if:

  • a person record with exactly the same first name and last name exists, which has a contact information record with exactly the same email address as used in the user account, and which is not linked to another user account, then this person record will be linked to this user account,

otherwise:

  • a new person record is created, and a new email contact record with the email address from the user record is registered for that person

s3_approver(self, user)

source code 

Returns the Approver for a new Registration & the organisation_id field

verify_email(self, next=DEFAULT, onaccept=DEFAULT, log=DEFAULT)

source code 

action user to verify the registration email, XXXXXXXXXXXXXXXX

.. method:: Auth.verify_email([next=DEFAULT [, onvalidation=DEFAULT
    [, onaccept=DEFAULT [, log=DEFAULT]]]])

s3_update_staff_membership(self, record, delete=False)

source code 

Updates the staff's memberships of the roles associated with the organisation and/or site instance record which the staff is a component of Called from onaccept & ondelete

s3_site_resource(self, site_id)

source code 

Returns the prefix, resource and id which a site refers to

To Do: Should this functionality be shifted to the super entity code? (But then can't be visible from Auth)

s3_logged_in(self)

source code 

Check whether the user is currently logged-in
- tries Basic if not

s3_has_role(self, role)

source code 

Check whether the currently logged-in user has a role

Parameters:
  • role - can be integer or a name

s3_group_members(self, group_id)

source code 

Get a list of members of a group

Parameters:
  • group_id - the group record ID
Returns:
a list of the user_ids for members of a group

s3_user_to_person(self, user_id)

source code 

Get the person_id for a given user_id

Parameters:
  • user_id - the user record ID
Returns:
the person record ID for this user ID

Note: unsafe method - do not expose to users

s3_person_to_user(self, person_id)

source code 

Get the user_id for a given person_id

Parameters:
  • person_id - the person record ID
Returns:
the user record ID associated with this person record

Note: unsafe method - do not expose to users

person_id(self)

source code 

Get the person record ID for the current logged-in user

s3_has_permission(self, method, table, record_id=0)

source code 

S3 framework function to define whether a user can access a record in manner "method" Designed to be called from the RESTlike controller

Parameters:
  • table - the table or tablename

Note: This is planned to be rewritten: http://eden.sahanafoundation.org/wiki/BluePrintAuthorization

s3_accessible_query(self, method, table)

source code 

Returns a query with all accessible records for the current logged in user

Note: This method does not work on GAE because it uses JOIN and IN

s3_has_membership(self, group_id=None, user_id=None, role=None)

source code 

Checks if user is member of group_id or role

Extends Web2Py's requires_membership() to add new functionality:

  • Custom Flash style
  • Uses s3_has_role()

has_membership(self, group_id=None, user_id=None, role=None)

source code 

Checks if user is member of group_id or role

Extends Web2Py's requires_membership() to add new functionality:

  • Custom Flash style
  • Uses s3_has_role()

s3_requires_membership(self, role)

source code 

Decorator that prevents access to action if not logged in or if user logged in is not a member of group_id. If role is provided instead of group_id then the group_id is calculated.

Extends Web2Py's requires_membership() to add new functionality:

  • Custom Flash style
  • Uses s3_has_role()
  • Administrators (id=1) are deemed to have all roles

requires_membership(self, role)

source code 

Decorator that prevents access to action if not logged in or if user logged in is not a member of group_id. If role is provided instead of group_id then the group_id is calculated.

Extends Web2Py's requires_membership() to add new functionality:

  • Custom Flash style
  • Uses s3_has_role()
  • Administrators (id=1) are deemed to have all roles

s3_create_role(self, role, description, *acls)

source code 

Back-end method to create roles with ACLs

s3_update_acl(self, role, c=None, f=None, t=None, oacl=None, uacl=None)

source code 

Back-end method to update an ACL

s3_make_session_owner(self, table, record_id)

source code 

Makes the current session owner of this record

s3_session_owns(self, table, record_id)

source code 

Checks whether the current session owns a record