Ejemplo n.º 1
0
    def __init__(self,
                 yosai,
                 settings,
                 realms=None,
                 cache_handler=None,
                 authenticator=None,
                 authorizer=ModularRealmAuthorizer(),
                 serialization_manager=None,
                 session_manager=None,
                 remember_me_manager=None,
                 subject_store=DefaultSubjectStore()):

        self.yosai = yosai
        self.subject_store = subject_store
        self.realms = realms
        self.remember_me_manager = remember_me_manager

        if not session_manager:
            session_manager = NativeSessionManager(settings)
        self.session_manager = session_manager

        self.authorizer = authorizer

        if not authenticator:
            authenticator = DefaultAuthenticator(settings)
        self.authenticator = authenticator

        if serialization_manager and self.remember_me_manager:
            self.remember_me_manager.serialization_manager = serialization_manager

        self.event_logger = EventLogger(event_bus)
        self.apply_event_bus(event_bus)

        self.apply_cache_handler(cache_handler)
        self.apply_realms()
Ejemplo n.º 2
0
Archivo: mgt.py Proyecto: hoatle/yosai
    def __init__(self,
                 realms=None,
                 event_bus=event_bus,
                 cache_handler=None,
                 authenticator=DefaultAuthenticator(),
                 authorizer=ModularRealmAuthorizer(),
                 session_manager=DefaultNativeSessionManager(),
                 session_attributes_schema=None,
                 remember_me_manager=None,
                 subject_store=DefaultSubjectStore(),  # unlike shiro, yosai defaults
                 subject_factory=DefaultSubjectFactory(),  # unlike shiro, yosai defaults
                 authz_info_resolver=AuthzInfoResolver(IndexedAuthorizationInfo),
                 credential_resolver=CredentialResolver(Credential),
                 permission_resolver=PermissionResolver(DefaultPermission),
                 role_resolver=RoleResolver(SimpleRole)):
        """
        :type realms: tuple
        :type session_attributes_schema: marshmallow.Schema
        """
        self._event_bus = event_bus
        self._cache_handler = cache_handler
        self.authz_info_resolver = authz_info_resolver
        self.credential_resolver = credential_resolver
        self.permission_resolver = permission_resolver
        self.role_resolver = role_resolver
        self.session_manager = session_manager
        self.realms = realms
        self.authenticator = authenticator
        self.authorizer = authorizer
        self.remember_me_manager = remember_me_manager
        self.subject_store = subject_store
        self.subject_factory = subject_factory

        if session_attributes_schema:
            SimpleSession.set_attributes_schema(session_attributes_schema)
Ejemplo n.º 3
0
def modular_realm_authorizer(account_store_realm):
    mra = ModularRealmAuthorizer()
    asr = account_store_realm
    mra.realms = (account_store_realm, )
    mra.event_bus = event_bus
    return mra
Ejemplo n.º 4
0
def modular_realm_authorizer_patched(monkeypatch, authz_realms_collection,
                                     event_bus):
    a = ModularRealmAuthorizer()
    monkeypatch.setattr(a, 'realms', authz_realms_collection)
    monkeypatch.setattr(a, 'event_bus', event_bus)
    return a
Ejemplo n.º 5
0
def modular_realm_authorizer(account_store_realm): 
    mra = ModularRealmAuthorizer()
    asr = account_store_realm
    mra.realms = (account_store_realm,)
    mra.event_bus = event_bus
    return mra