acapy_plugin_toolbox/util.py
def require_role(role):
    """
    Verify that the current connection has a given role.

    Verify that the current connection has a given role; otherwise, send a
    problem report.
    """
    def _require_role(func):
        @functools.wraps(func)
        async def _wrapped(
                handler,
                context: RequestContext,
                responder: BaseResponder):

            if not context.connection_record \
                    or context.connection_record.their_role != role:
                report = ProblemReport(
                    explain_ltxt='This connection is not authorized to perform '
                                 'the requested action.',
                    who_retries='none'
                )
                report.assign_thread_from(context.message)
                await responder.send_reply(report)
                return

            return await func(handler, context, responder)
        return _wrapped
    return _require_role

    Verify that the current connection has a given role.

    Verify that the current connection has a given role; otherwise, send a
    problem report.
    
Verify that the current connection has a given role.
Verify that the current connection has a given role; otherwise, send a
problem report.
Verify that the current connection has a given role . Verify that the current connection has a given role ; otherwise send a problem report .
def require_role(role):
    def _require_role(func):
        @functools.wraps(func)
        async def _wrapped(
                handler,
                context: RequestContext,
                responder: BaseResponder):
            if not context.connection_record \
                    or context.connection_record.their_role != role:
                report = ProblemReport(
                    explain_ltxt='This connection is not authorized to perform '
                                 'the requested action.',
                    who_retries='none'
                )
                report.assign_thread_from(context.message)
                await responder.send_reply(report)
                return
            return await func(handler, context, responder)
        return _wrapped
    return _require_role
def require_role ( role ) : def _require_role ( func ) : @ functools . wraps ( func ) async def _wrapped ( handler , context : RequestContext , responder : BaseResponder ) : if not context . connection_record or context . connection_record . their_role != role : report = ProblemReport ( explain_ltxt = 'This connection is not authorized to perform ' 'the requested action.' , who_retries = 'none' ) report . assign_thread_from ( context . message ) await responder . send_reply ( report ) return return await func ( handler , context , responder ) return _wrapped return _require_role
Verify that the current connection has a given role.
Verify that the current connection has a given role .
"""
    Verify that the current connection has a given role.

    Verify that the current connection has a given role; otherwise, send a
    problem report.
    """
role