Exemplo n.º 1
0
class SQLAuthPluginSearchForm(SearchForm):  # pylint: disable=abstract-method
    """SQL authentication plug-in search form"""

    title = _("Users search form")

    @property
    def back_url(self):
        """Form back URL getter"""
        return absolute_url(self.request.root, self.request, 'security-plugins.html')
Exemplo n.º 2
0
class SQLAuthPluginSearchNameColumn(I18nColumnMixin, GetAttrColumn):
    """SQL authentication plug-in search name column"""

    i18n_header = _("Name")

    weight = 20

    def get_value(self, obj):
        """Column value getter"""
        return self.context.title_format.format(**obj)
Exemplo n.º 3
0
class SQLAuthPluginSearchEmailColumn(I18nColumnMixin, GetAttrColumn):
    """SQL authentication plug-in search email column"""

    i18n_header = _("Email")

    @property
    def attr_name(self):
        """Column attribute getter"""
        return self.context.mail_attribute

    weight = 30
Exemplo n.º 4
0
class SQLAuthPluginSearchLoginColumn(I18nColumnMixin, GetAttrColumn):
    """SQL authentication plug-in search login column"""

    i18n_header = _("Login")

    @property
    def attr_name(self):
        """Column attribute getter"""
        return self.context.login_attribute

    weight = 10
Exemplo n.º 5
0
class SQLAuthPluginSearchView(SearchView):
    """SQL authentication plug-in search view"""

    title = _("Users search form")
    search_form = SQLAuthPluginSearchForm
Exemplo n.º 6
0
class SQLAuthPluginPropertiesEditForm(SecurityPluginPropertiesEditForm):
    """SQL authentication plug-in properties edit form"""

    title = _("SQL authentication plug-in")
    plugin_interface = ISQLAuthPlugin
Exemplo n.º 7
0
class SQLAuthPluginAddForm(SecurityPluginAddForm):
    """SQL authentication plug-in add form"""

    legend = _("Add SQL authentication plug-in")
    content_factory = ISQLAuthPlugin
Exemplo n.º 8
0
class SQLAuthPluginAddMenu(SecurityPluginAddMenu):
    """SQL authentication plug-in add menu"""

    label = _("Add SQL authentication plugin...")
    href = 'add-sql-auth-plugin.html'
Exemplo n.º 9
0
class SQLAuthPluginSearchResultsView(SearchResultsView):
    """SQL authentication plug-in search results view"""

    table_label = _("Search results")
    table_class = SQLAuthPluginSearchResultsTable
Exemplo n.º 10
0
class ISQLAuthPlugin(IAuthenticationPlugin, IDirectorySearchPlugin):
    """SQL authentication plug-in interface"""

    sql_engine = Choice(
        title=_("SQL engine"),
        description=_("SQLAlchemy engine used for database connection"),
        vocabulary=ALCHEMY_ENGINES_VOCABULARY,
        required=True)

    schema_name = TextLine(title=_("Schema name"),
                           description=_("Database schema name"),
                           required=False)

    table_name = TextLine(title=_("Table name"),
                          description=_("Users table name"),
                          required=True,
                          default='users')

    login_attribute = TextLine(
        title=_("Login field name"),
        description=_("Field name used to store login information"),
        required=True,
        default='login')

    password_attribute = TextLine(
        title=_("Password field name"),
        description=_("Field name used to store encoded password"),
        required=True,
        default='password')

    title_format = TextLine(title=_("Title format"),
                            description=_("Principal's title format string"),
                            required=True,
                            default='{name}')

    search_attributes = TextLine(
        title=_("Search attributes"),
        description=_("Users will be searched against these attributes, "
                      "which can be provided by separating them with "
                      "commas; login attribute is automatically "
                      "selected"),
        required=False,
        default='login,name')

    login_with_email = Bool(title=_("Allow login with email"),
                            description=_(
                                "If 'yes', users can log in using their email "
                                "address or their base login"),
                            required=True,
                            default=False)

    mail_attribute = TextLine(
        title=_("Email field name"),
        description=_("Field name used to store email address"),
        required=True,
        default='email')