Example #1
0
 def __init__(self, env_var=None, file_path=None, session_attributes=None):
     """
     :type session_attributes: tuple
     """
     # you can configure LazySettings in one of two ways: env or file_path
     self.settings = LazySettings(env_var=env_var, file_path=file_path)
     self.security_manager = \
         self.generate_security_manager(self.settings, session_attributes)
Example #2
0
def create_totp_factory(env_var=None, file_path=None, authc_settings=None):
    if not authc_settings:
        yosai_settings = LazySettings(env_var=env_var, file_path=file_path)
        authc_settings = AuthenticationSettings(yosai_settings)

    totp_context = authc_settings.totp_context

    return TOTP.using(**totp_context)
Example #3
0
def test_del_attr_from_empty_wrapped(settings_file):
    """
    test case:
    self._wrapped is empty, so trying to delete from it will invoke _setup()

    delete an attribute that doesnt exist, ignoring the exception, and confirm
    that _setup() was called
    """
    lazy_settings = LazySettings(settings_file)
    with mock.patch.object(LazySettings, '_setup', return_value=None) as setup:
        try:
            del lazy_settings.blabla
        except AttributeError:
            setup.assert_called_once_with()
Example #4
0
def lazy_settings():
    return LazySettings('YOSAI_SETTINGS')
Example #5
0
def test_setup_envvar_exception(monkeypatch):
    lazy_settings = LazySettings('env_var')
    with pytest.raises(MisconfiguredException):
        lazy_settings._setup()
    CredentialType,
    User,
    Domain,
    Action,
    Resource,
    Permission,
    Role,
    role_membership,
    role_permission,
)
import datetime
from sqlalchemy import case, func, distinct
from passlib.context import CryptContext
from yosai.core import LazySettings

settings = LazySettings(env_var='YOSAI_SETTINGS')
engine = init_engine(settings=settings)
Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)
import pprint
pp = pprint.PrettyPrinter(indent=1)

Session = init_session(settings=settings)

# Please watch 'The Big Lebowski' so that you may understand the following data.
users = [
    User(first_name='Jeffrey',
         last_name='Lebowski',
         identifier='thedude',
         phone_number='11234567890'),
    User(first_name='Walter', last_name='Sobchak', identifier='walter'),
Example #7
0
def web_settings():
    return LazySettings(env_var='YOSAI_WEB_SETTINGS')
Example #8
0
def core_settings():
    return LazySettings(env_var='YOSAI_CORE_SETTINGS')
Example #9
0
def settings():
    return LazySettings(env_var='YOSAI_SETTINGS')