Exemplo n.º 1
0
class IUser(IFolder, IPrincipal):

    username = schema.TextLine(title=_("Username"), required=False)

    index_field("email", index_name="user_email", type="keyword")
    email = schema.TextLine(title=_("Email"), required=False)

    index_field("name", index_name="user_name", type="textkeyword")
    name = schema.TextLine(title=_("Name"), required=False)

    read_permission(password="******")
    password = schema.TextLine(title=_("Password"), required=False)

    write_permission(user_groups="guillotina.ManageUsers")
    user_groups = schema.List(title=_("Groups"),
                              value_type=schema.TextLine(),
                              required=False)

    write_permission(user_roles="guillotina.ManageUsers")
    index_field("user_roles", type="textkeyword")
    user_roles = schema.List(title=_("Roles"),
                             value_type=schema.TextLine(),
                             required=False)

    write_permission(user_permissions="guillotina.ManageUsers")
    user_permissions = schema.List(title=_("Permissions"),
                                   value_type=schema.TextLine(),
                                   required=False,
                                   default=[])

    write_permission(disabled="guillotina.ManageUsers")
    index_field("disabled", type="boolean")
    disabled = schema.Bool(title=_("Disabled"), default=False)

    properties = schema.Dict(required=False, default={})
Exemplo n.º 2
0
class IPrincipal(Interface):  # pylint: disable=E0239
    """Principals are security artifacts that execute actions in a security
    environment.

    The most common examples of principals include user and group objects.

    It is likely that IPrincipal objects will have associated views
    used to list principals in management interfaces. For example, a
    system in which other meta-data are provided for principals might
    extend IPrincipal and register a view for the extended interface
    that displays the extended information. We'll probably want to
    define a standard view name (e.g.  'inline_summary') for this
    purpose.
    """

    id = TextLine(
        title=_("Id"),
        description=_("The unique identification of the principal."),
        required=True,
        readonly=True,
    )

    groups = List(value_type=TextLine())

    read_permission(password="******")
    _groups_cache = Dict(
        key_type=TextLine(),
        value_type=Object(schema=Interface))  # value_type=IPrincipal

    async def set_password(new_password: str,
                           old_password: typing.Optional[str]):
        """
Exemplo n.º 3
0
class ITestBehavior(Interface):
    foobar = schema.TextLine(required=False)
    foobar_context = schema.TextLine(required=False, default="default-foobar")

    bucket_dict = fields.BucketDictField(bucket_len=10,
                                         required=False,
                                         default=None,
                                         key_type=schema.Text(),
                                         value_type=schema.Text())

    read_permission(no_read_field="example.MyPermission")
    no_read_field = schema.TextLine(required=False, default="")
Exemplo n.º 4
0
class IFollowing(Interface):

    index_field("favorites", type="keyword", store=True)

    read_permission(favorites="guillotina.")
    write_permission(favorites="guillotina.NoBody")
    favorites = schema.List(title=u"favorites",
                            default=[],
                            value_type=schema.TextLine(title="follower"))

    favorite = schema.Bool(title=u"Current user has it favorited",
                           default=False)
Exemplo n.º 5
0
class IFollowing(Interface):

    index_field('favorites', type='keyword', store=True)

    read_permission(favorites='guillotina.')
    write_permission(favorites='guillotina.NoBody')
    favorites = schema.List(title=u'favorites',
                            default=[],
                            value_type=schema.TextLine(title='follower'))

    favorite = schema.Bool(title=u'Current user has it favorited',
                           default=False)
Exemplo n.º 6
0
class IUser(IFolder, IPrincipal):

    username = schema.TextLine(
        title=_('Username'),
        required=False)

    email = schema.TextLine(
        title=_('Email'),
        required=False)

    name = schema.TextLine(
        title=_('Name'),
        required=False)

    read_permission(password='******')
    password = schema.TextLine(
        title=_('Password'),
        required=False)

    user_groups = schema.List(
        title=_('Groups'),
        value_type=schema.TextLine(),
        required=False
    )

    user_roles = schema.List(
        title=_('Roles'),
        value_type=schema.TextLine(),
        required=False
    )

    user_permissions = schema.List(
        title=_('Permissions'),
        value_type=schema.TextLine(),
        required=False,
        default=[]
    )

    disabled = schema.Bool(
        title=_('Disabled'),
        default=False
    )

    properties = schema.Dict(
        required=False,
        default={}
    )