Ejemplo n.º 1
0
 def getGui(self, type_):
     try:
         return self.addDefaultFields(
             auths.factory().lookup(type_).guiDescription(),
             ['name', 'comments', 'tags', 'priority', 'small_name'])
     except Exception:
         raise NotFound('type not found')
Ejemplo n.º 2
0
 def getGui(self, type_: str) -> typing.List[typing.Any]:
     try:
         tgui = auths.factory().lookup(type_)
         if tgui:
             g = self.addDefaultFields(
                 tgui.guiDescription(),
                 ['name', 'comments', 'tags', 'priority', 'small_name'])
             self.addField(
                 g, {
                     'name':
                     'visible',
                     'value':
                     True,
                     'label':
                     ugettext('Visible'),
                     'tooltip':
                     ugettext(
                         'If active, transport will be visible for users'),
                     'type':
                     gui.InputField.CHECKBOX_TYPE,
                     'order':
                     107,
                     'tab':
                     ugettext('Display'),
                 })
             return g
         raise Exception()  # Not found
     except Exception:
         raise NotFound('type not found')
Ejemplo n.º 3
0
def __init__():
    '''
    This imports all packages that are descendant of this package, and, after that,
    it register all subclases of authenticator as 
    '''
    import os.path, pkgutil
    import sys
    from uds.core import auths

    # Dinamycally import children of this package. The __init__.py files must register, if needed, inside AuthsFactory
    pkgpath = os.path.dirname(sys.modules[__name__].__file__)
    for _, name, _ in pkgutil.iter_modules([pkgpath]):
        __import__(name, globals(), locals(), [], -1)

    a = auths.Authenticator
    for cls in a.__subclasses__():
        auths.factory().insert(cls)
Ejemplo n.º 4
0
def __init__():
    '''
    This imports all packages that are descendant of this package, and, after that,
    it register all subclases of authenticator as 
    '''
    import os.path, pkgutil
    import sys
    from uds.core import auths
    
    # Dinamycally import children of this package. The __init__.py files must register, if needed, inside AuthsFactory
    pkgpath = os.path.dirname(sys.modules[__name__].__file__)
    for _, name, _ in pkgutil.iter_modules([pkgpath]):
        __import__(name, globals(), locals(), [], -1)
    
    a = auths.Authenticator
    for cls in a.__subclasses__():
        auths.factory().insert(cls)
Ejemplo n.º 5
0
def __init__():
    """
    This imports all packages that are descendant of this package, and, after that,
    it register all subclases of authenticator as
    """
    from uds.core import auths

    # Dinamycally import children of this package. The __init__.py files must declare authenticators as subclasses of auths.Authenticator
    pkgpath = os.path.dirname(sys.modules[__name__].__file__)
    for _, name, _ in pkgutil.iter_modules([pkgpath]):
        # __import__(name, globals(), locals(), [], 1)
        importlib.import_module('.' + name, __name__)  # import module

    importlib.invalidate_caches()

    a = auths.Authenticator
    for cls in a.__subclasses__():
        auths.factory().insert(cls)
Ejemplo n.º 6
0
 def getGui(self, type_: str) -> typing.List[typing.Any]:
     try:
         gui = auths.factory().lookup(type_)
         if gui:
             return self.addDefaultFields(
                 gui.guiDescription(),
                 ['name', 'comments', 'tags', 'priority', 'small_name'])
         raise Exception()  # Not found
     except Exception:
         raise NotFound('type not found')
Ejemplo n.º 7
0
    def getType(self):
        '''
        Get the type of the object this record represents.

        The type is Python type, it obtains this type from ServiceProviderFactory and associated record field.

        Returns:
            The python type for this record object

        :note: We only need to get info from this, not access specific data (class specific info)
        '''
        from uds.core import auths
        return auths.factory().lookup(self.data_type)
Ejemplo n.º 8
0
    def getType(self):
        """
        Get the type of the object this record represents.

        The type is Python type, it obtains this type from ServiceProviderFactory and associated record field.

        Returns:
            The python type for this record object

        :note: We only need to get info from this, not access specific data (class specific info)
        """
        from uds.core import auths
        return auths.factory().lookup(self.data_type)
Ejemplo n.º 9
0
    def test(self, type_):
        from uds.core.Environment import Environment

        authType = auths.factory().lookup(type_)
        self.ensureAccess(authType, permissions.PERMISSION_MANAGEMENT, root=True)

        dct = self._params.copy()
        dct['_request'] = self._request
        res = authType.test(Environment.getTempEnv(), dct)
        if res[0]:
            return self.success()
        else:
            return res[1]
Ejemplo n.º 10
0
    def getType(self) -> typing.Type[auths.Authenticator]:
        """
        Get the type of the object this record represents.

        The type is Python type, it obtains this type from ServiceProviderFactory and associated record field.

        Returns:
            The python type for this record object

        :note: We only need to get info from this, not access specific data (class specific info)
        """
        # If type is not registered (should be, but maybe a database inconsistence), consider this a "base empty auth"
        return auths.factory().lookup(self.data_type) or auths.Authenticator
Ejemplo n.º 11
0
    def test(self, type_):
        from uds.core.Environment import Environment

        authType = auths.factory().lookup(type_)
        self.ensureAccess(authType,
                          permissions.PERMISSION_MANAGEMENT,
                          root=True)

        dct = self._params.copy()
        dct['_request'] = self._request
        res = authType.test(Environment.getTempEnv(), dct)
        if res[0]:
            return self.success()
        else:
            return res[1]
Ejemplo n.º 12
0
    def test(self, type_: str):
        from uds.core.environment import Environment

        authType = auths.factory().lookup(type_)
        if not authType:
            raise self.invalidRequestException(
                'Invalid type: {}'.format(type_))

        self.ensureAccess(authType,
                          permissions.PERMISSION_MANAGEMENT,
                          root=True)

        dct = self._params.copy()
        dct['_request'] = self._request
        res = authType.test(Environment.getTempEnv(), dct)
        if res[0]:
            return self.success()
        return res[1]
Ejemplo n.º 13
0
 def enum_types(self) -> typing.Iterable[typing.Type[auths.Authenticator]]:
     return auths.factory().providers().values()
Ejemplo n.º 14
0
 def getGui(self, type_):
     try:
         return self.addDefaultFields(auths.factory().lookup(type_).guiDescription(), ['name', 'comments', 'tags', 'priority', 'small_name'])
     except:
         raise NotFound('type not found')
Ejemplo n.º 15
0
 def enum_types(self):
     return auths.factory().providers().values()
Ejemplo n.º 16
0
#
#    * Redistributions of source code must retain the above copyright notice,
#      this list of conditions and the following disclaimer.
#    * Redistributions in binary form must reproduce the above copyright notice,
#      this list of conditions and the following disclaimer in the documentation
#      and/or other materials provided with the distribution.
#    * Neither the name of Virtual Cable S.L. nor the names of its contributors
#      may be used to endorse or promote products derived from this software
#      without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
Dummy test authenticator. Not used in production (it doesn't registers itself)

@author: Adolfo Gómez, dkmaster at dkmon dot com
'''
from uds.core import auths
from SampleAuth import SampleAuth

# Commented, this auth exists for testing purposes only
auths.factory().insert(SampleAuth)
Ejemplo n.º 17
0
#      this list of conditions and the following disclaimer.
#    * Redistributions in binary form must reproduce the above copyright notice, 
#      this list of conditions and the following disclaimer in the documentation 
#      and/or other materials provided with the distribution.
#    * Neither the name of Virtual Cable S.L. nor the names of its contributors 
#      may be used to endorse or promote products derived from this software 
#      without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


'''
Dummy test authenticator. Not used in production (it doesn't registers itself)

@author: Adolfo Gómez, dkmaster at dkmon dot com
'''
from uds.core import auths 
from SampleAuth import SampleAuth 

# Commented, this auth exists for testing purposes only
auths.factory().insert(SampleAuth) 
Ejemplo n.º 18
0
 def enum_types(self):
     return auths.factory().providers().values()