gws.base.auth.user

Source code: gws.base.auth.user

Module Contents

class gws.base.auth.user.Props(*args, **kwargs)

Bases: gws.Props

Object properties.

displayName: str
attributes: dict
class gws.base.auth.user.User(provider, roles)

Bases: gws.User

User object.

isGuest = False
props(user)

Generate a Props struct for this object.

Parameters:

user – The user for which the props should be generated.

has_role(role)
can_use(obj, *context)

Check if the user has “read” permission on an object.

can_read(obj, *context)

Check if the user has “read” permission on an object.

can_write(obj, *context)

Check if the user has “write” permission on an object.

can_create(obj, *context)

Check if the user has “create” permission on an object.

can_edit(obj, *context)

Check if the user has “edit” permissions on an object.

can_delete(obj, *context)

Check if the user has “delete” permission on an object.

can(access, obj, *context)

Check if the user can access an object.

Parameters:
  • access – Access mode.

  • obj – Requested object.

  • *context – Further objects to check.

Returns:

True is access is granted.

acl_bit(access, obj)

Get the ACL bit for a specific object.

Parameters:
  • access – Access mode.

  • obj – Requested object.

Returns:

1 or 0 if the user’s permissions have the bit and None otherwise.

require(uid=None, classref=None, access=None)

Get a readable object by uid and fail if not found.

Parameters:
  • uid – Object uid.

  • classref – Class reference. If provided, ensures that the object matches the reference.

  • access – Access mode, assumed Access.read if omitted.

Returns:

A readable object.

Raises:
  • NotFoundError if the object doesn't exist.

  • ForbiddenError if the user cannot read the object.

acquire(uid=None, classref=None, access=None)

Get a readable object by uid.

Parameters:
  • uid – Object uid.

  • classref – Class reference. If provided, ensures that the object matches the reference.

  • access – Access mode, assumed Access.read if omitted.

Returns:

A readable object or None if the object does not exists or user doesn’t have a permission.

require_project(uid=None)

Get a readable Project object.

Parameters:

uid – Project uid.

Returns:

A Project object.

require_layer(uid=None)

Get a readable Layer object.

Parameters:

uid – Layer uid.

Returns:

A Layer object.

class gws.base.auth.user.GuestUser(provider, roles)

Bases: User

User object.

isGuest = True
class gws.base.auth.user.SystemUser(provider, roles)

Bases: User

User object.

acl_bit(access, obj)

Get the ACL bit for a specific object.

Parameters:
  • access – Access mode.

  • obj – Requested object.

Returns:

1 or 0 if the user’s permissions have the bit and None otherwise.

class gws.base.auth.user.NobodyUser(provider, roles)

Bases: User

User object.

acl_bit(access, obj)

Get the ACL bit for a specific object.

Parameters:
  • access – Access mode.

  • obj – Requested object.

Returns:

1 or 0 if the user’s permissions have the bit and None otherwise.

class gws.base.auth.user.AuthorizedUser(provider, roles)

Bases: User

User object.

class gws.base.auth.user.AdminUser(provider, roles)

Bases: User

User object.

acl_bit(access, obj)

Get the ACL bit for a specific object.

Parameters:
  • access – Access mode.

  • obj – Requested object.

Returns:

1 or 0 if the user’s permissions have the bit and None otherwise.

gws.base.auth.user.to_dict(usr) dict
gws.base.auth.user.from_dict(provider: gws.AuthProvider, d: dict) gws.User
gws.base.auth.user.init(provider: gws.AuthProvider, **kwargs) gws.User