Exemplo n.º 1
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------------------
""" Start the LDAP provider with initial sync and listener outbound delta.
"""
import time
from rbac.common.logs import get_logger
from rbac.common.config import get_config
from rbac.providers.common.threading import DeltaSyncThread
from rbac.providers.ldap.delta_outbound_sync import ldap_outbound_listener
from rbac.providers.ldap.initial_inbound_sync import initialize_ldap_sync

LOGGER = get_logger(__name__)


def main():
    """Start the initial sync and outbound delta thread."""
    ldap_server = get_config("LDAP_SERVER")
    if not ldap_server:
        LOGGER.warning("No LDAP provider configured, exiting...")
        return

    # wait 5 seconds before starting, to provide time for dependent services to start up
    time.sleep(5)
    initialize_ldap_sync()
    # Create sync listener threads.
    outbound_sync_thread = DeltaSyncThread("LDAP Outbound",
                                           ldap_outbound_listener)
Exemplo n.º 2
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------------------

from sanic.response import json
from sanic import Blueprint
from sanic.exceptions import SanicException
from sanic.exceptions import NotFound

import rbac.common.logs as logging

ERRORS_BP = Blueprint("errors")
LOGGER = logging.get_logger(__name__)
DEFAULT_MSGS = {
    400: "Bad Request",
    401: "Unauthorized",
    403: "Forbidden",
    404: "Not Found",
    501: "Not Implemented",
    503: "Internal Error",
}


def add_status_code(code):
    """
    Decorator used for adding exceptions to _sanic_exceptions.
    """
    def class_decorator(cls):