Beispiel #1
0
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.get("/credential/{id}", credentials_get),
        web.post("/credential/{id}/remove", credentials_remove),
        web.get("/credentials", credentials_list),
        web.get("/credential_exchange", credential_exchange_list),
        web.get("/credential_exchange/{id}", credential_exchange_retrieve),
        web.post("/credential_exchange/send", credential_exchange_send),
        web.post("/credential_exchange/send-offer",
                 credential_exchange_send_offer),
        web.post(
            "/credential_exchange/{id}/send-request",
            credential_exchange_send_request,
        ),
        web.post("/credential_exchange/{id}/issue", credential_exchange_issue),
        web.post("/credential_exchange/{id}/store", credential_exchange_store),
        web.post(
            "/credential_exchange/{id}/problem_report",
            credential_exchange_problem_report,
        ),
        web.post("/credential_exchange/{id}/remove",
                 credential_exchange_remove),
    ])
Beispiel #2
0
def setup_statics(app: web.Application):

    # NOTE: source-output and build-output have both the same subfolder structure
    cfg = app[APP_CONFIG_KEY]["main"]
    app[APP_STATICS_OUTDIR_KEY] = statics_dir = Path(
        cfg["client_outdir"]).expanduser()

    # Creating static routes
    routes = web.RouteTableDef()
    is_dev: bool = app[APP_SETTINGS_KEY].build_target in [None, "development"]
    for name in STATIC_DIRNAMES:
        folder = statics_dir / name

        # avoids problems restarting when qx-compile takes longer to product outputs
        if not folder.exists() and is_dev:
            os.makedirs(folder, exist_ok=True)

        # can navigate file index in dev mode
        routes.static(f"/{folder.name}", folder, show_index=is_dev)
    app.add_routes(routes)

    # Create dynamic route to serve front-end client
    app.router.add_get("/", get_frontend_ria, name=INDEX_RESOURCE_NAME)

    # Delayed creation of statics.json (mostly for dev mode)
    app.on_startup.append(_start_statics)
Beispiel #3
0
async def init_routes(app: web.Application) -> None:
    """
    Initializing the Routes
    :param app:
    :return:
    """
    try:
        log.info(f'Initializing the routes')
        base_prefix = '/product'

        add_route = app.router.add_route
        add_route('*', '/', index, name='index')

        # added static dir
        app.router.add_static(
            '/static/',
            path=(PROJECT_PATH / 'static'),
            name='static',
        )
        await vh.init_version_routes(app, base_prefix)
        await ph.init_product_routes(app, base_prefix)

        # Updating the version server routes
        app.add_routes(routes)

    except Exception as e:
        log.error('init_routes Error {}'.format(e))
Beispiel #4
0
async def register(app: web.Application):
    """Register routes."""
    app.add_routes([
        web.post("/revocation/create-registry", revocation_create_registry),
        web.get(
            "/revocation/registries/created",
            revocation_registries_created,
            allow_head=False,
        ),
        web.get("/revocation/registry/{rev_reg_id}",
                get_registry,
                allow_head=False),
        web.get(
            "/revocation/active-registry/{cred_def_id}",
            get_active_registry,
            allow_head=False,
        ),
        web.get(
            "/revocation/registry/{rev_reg_id}/tails-file",
            get_tails_file,
            allow_head=False,
        ),
        web.patch("/revocation/registry/{rev_reg_id}", update_registry),
        web.post("/revocation/registry/{rev_reg_id}/publish",
                 publish_registry),
    ])
def setup() -> _T:
    state: Dict[str, str] = {}

    async def reg(request: Request) -> None:
        nonlocal state
        state["method"] = request.method
        state["body"] = await request.read()

    async def handler(request: Request) -> Response:
        await reg(request)
        return Response(text="Some text")

    async def json_handler(request: Request) -> Response:
        await reg(request)
        return json_response({"key": "value"})

    app = Application()
    app.add_routes([
        web.get("/url/", handler),
        web.post("/url/", handler),
        web.options("/url/", handler),
        web.put("/url/", handler),
        web.patch("/url/", handler),
        web.delete("/url/", handler),
        web.get("/json_url/", json_handler),
    ])

    return app, state
Beispiel #6
0
async def register(app: web.Application):
    """Register routes."""
    app.add_routes([
        web.post("/revocation/create-registry", create_rev_reg),
        web.get(
            "/revocation/registries/created",
            rev_regs_created,
            allow_head=False,
        ),
        web.get("/revocation/registry/{rev_reg_id}",
                get_rev_reg,
                allow_head=False),
        web.get(
            "/revocation/active-registry/{cred_def_id}",
            get_active_rev_reg,
            allow_head=False,
        ),
        web.get(
            "/revocation/registry/{rev_reg_id}/tails-file",
            get_tails_file,
            allow_head=False,
        ),
        web.put("/revocation/registry/{rev_reg_id}/tails-file",
                upload_tails_file),
        web.patch("/revocation/registry/{rev_reg_id}", update_rev_reg),
        web.post("/revocation/registry/{rev_reg_id}/definition",
                 send_rev_reg_def),
        web.post("/revocation/registry/{rev_reg_id}/entry",
                 send_rev_reg_entry),
        web.patch(
            "/revocation/registry/{rev_reg_id}/set-state",
            set_rev_reg_state,
        ),
    ])
Beispiel #7
0
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.get("/connections", connections_list),
        web.get("/connections/{id}", connections_retrieve),
        web.post("/connections/create-invitation",
                 connections_create_invitation),
        # ************Edited Beginning************
        # Written for signature and verification
        # Begin written by Ashlin, Minto, Athul Antony
        web.post("/connections/create-signing-did", createSigningDid),
        web.post("/connections/put-key-ledger", putVerificationToLedger),
        web.post("/connections/sign-transaction", getSignedTransaction),
        web.post("/connections/verify-transaction", verifySignedTransaction),
        # Written for signature and verification
        # End written by Ashlin, Minto, Athul Antony
        # ************Edited End******************
        web.post("/connections/receive-invitation",
                 connections_receive_invitation),
        web.post("/connections/{id}/accept-invitation",
                 connections_accept_invitation),
        web.post("/connections/{id}/accept-request",
                 connections_accept_request),
        web.post(
            "/connections/{id}/establish-inbound/{ref_id}",
            connections_establish_inbound,
        ),
        web.post("/connections/{id}/remove", connections_remove),
    ])
Beispiel #8
0
def routes(app: web.Application) -> None:
    app.add_routes([
        web.get("/", login),
        web.get("/login", login),
        web.post("/logging_in", logging_in),
        web.post("/login/logging_in", logging_in),
    ])
Beispiel #9
0
    def _get_session(self, connector: TCPConnector) -> BaseTestClient:
        app = Application()
        app.add_routes([view('/1.0/certificates', CertificatesView)])

        server = TestServer(app, )

        return BaseTestClient(server, )
Beispiel #10
0
    async def test_decorator_limiter_called_correctly(self, limit_class):
        app = Application()
        routes = RouteTableDef()

        async def test_view(request):
            return json_response("bad", status=400)

        async def test_view2(request):
            return json_response("bad", status=429)

        @routes.get("/")
        @aiopylimit("root_view", (60, 1), limit_reached_view=test_view)
        async def test(request):
            return json_response({"test": True})

        app.add_routes(routes)

        request = UserDict()
        request.app = UserDict()
        request.app['limit_global_namespace_prefix'] = "aiohttp"
        request.app['limit_key_func'] = lambda x: "key"
        request.app['limit_reached_view'] = test_view2

        ret = await test(request)
        limit_class.assert_called_once_with(60, 1)
        self.assertEqual(ret.status, 400)
Beispiel #11
0
async def register(app: web.Application):
    app.add_routes(
        [
            web.post("/verifiable-services/add", add_service),
            web.post("/verifiable-services/apply", apply),
            web.post("/verifiable-services/get-issue-self", get_issue_self,),
            web.post("/verifiable-services/process-application", process_application,),
            web.get(
                "/verifiable-services/request-service-list/{connection_id}",
                request_services_list,
                allow_head=False,
            ),
            web.get(
                "/verifiable-services/self-service-list",
                self_service_list,
                allow_head=False,
            ),
            web.get(
                "/verifiable-services/DEBUGrequest/{connection_id}",
                DEBUGrequest_services_list,
                allow_head=False,
            ),
            # web.get(
            #     "/verifiable-services/get-credential-data/{data_dri}",
            #     DEBUGget_credential_data,
            #     allow_head=False,
            # ),
            # web.get(
            #     "/verifiable-services/apply-status",
            #     DEBUGapply_status,
            #     allow_head=False,
            # ),
        ]
    )
Beispiel #12
0
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.post("/connections/{conn_id}/test-protocolexample",
                 connections_send_ping)
    ])
Beispiel #13
0
async def initialize(appctx):
    @middleware
    async def context_injection_middleware(request, handler):
        if not handler.__annotations__:
            return await handler(request)
        params = {}

        new_session = handler.__annotations__.pop('__new_session', False)
        for name, t in handler.__annotations__.items():
            if t is AppConfig:
                params[name] = appctx
            elif t is AuthnSession:
                if new_session:
                    params[name] = await aiohttp_session.new_session(request)
                else:
                    params[name] = await aiohttp_session.get_session(request)
            elif t is Request:
                continue
            elif name == 'return':
                continue
            else:
                raise RuntimeError(f"don't know how to inject {name}")

        return await handler(request, **params)

    app = Application(middlewares=[
        aiohttp_session.session_middleware(
            appctx.session_store.get()), util.web.json_response_middleware,
        message_middleware, context_injection_middleware
    ])
    app.add_routes(appctx.routes.get())
    app['appctx'] = appctx

    return app
def init(cfg: Config, app: web.Application) -> None:
    global host, secret, config
    config = cfg
    secret = cfg["bridges.mautrix-facebook.secret"]
    if secret:
        host = URL(cfg["bridges.mautrix-facebook.url"])
    app.add_routes(routes)
Beispiel #15
0
def register_routes(app: web.Application):
    app.add_routes([
        web.get("/echo", echo),
        web.get("/endpoints", list_endpoints),
        web.post("/endpoints", add_endpoints),
        web.delete("/endpoints", delete_endpoints),
    ])
Beispiel #16
0
def add_routes(app: web.Application, handlers: dict) -> None:
    try:
        controller_names = handlers.keys()
        for controller_name in controller_names:
            controllers = handlers[controller_name]
            for controller in controllers:
                handler_name = next(iter(controller.keys()))
                pkg = import_module(f"controllers.{controller_name}")
                imported_handler = eval(f"pkg.{handler_name}")
                path_no_slash = str(controller[handler_name]['paths'][0])
                path_trailing_slash = f"{controller[handler_name]['paths'][0]}/"
                app.add_routes([
                    web.route(controller[handler_name]["method"],
                              path_no_slash, imported_handler),
                    web.route(controller[handler_name]["method"],
                              path_trailing_slash, imported_handler)
                ])
        app.add_routes([
            web.route("GET", "/ping", ping),
            web.route("GET", "/ping/", ping),
            web.route("GET", "/metrics", metrics),
            web.route("GET", "/metrics/", metrics),
            web.route("*", "/{tail:.*}", error_handler),
        ])
    except:
        raise
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.get("/issue-credential/mime-types/{credential_id}",
                attribute_mime_types_get),
        web.get("/issue-credential/records", credential_exchange_list),
        web.get("/issue-credential/records/{cred_ex_id}",
                credential_exchange_retrieve),
        web.post("/issue-credential/send", credential_exchange_send),
        web.post("/issue-credential/send-proposal",
                 credential_exchange_send_proposal),
        web.post("/issue-credential/send-offer",
                 credential_exchange_send_free_offer),
        web.post("/issue-credential/records/{cred_ex_id}/send-offer",
                 credential_exchange_send_bound_offer),
        web.post("/issue-credential/records/{cred_ex_id}/send-request",
                 credential_exchange_send_request),
        web.post("/issue-credential/records/{cred_ex_id}/issue",
                 credential_exchange_issue),
        web.post("/issue-credential/records/{cred_ex_id}/store",
                 credential_exchange_store),
        web.post("/issue-credential/records/{cred_ex_id}/problem-report",
                 credential_exchange_problem_report),
        web.post("/issue-credential/records/{cred_ex_id}/remove",
                 credential_exchange_remove)
    ])
Beispiel #18
0
def init_routes(app_authenticate: web.Application) -> None:
    app_authenticate.add_routes([
        web.view('/login', apis.Login, name='login'),  # type: ignore
        web.view('/refresh-token', apis.RefreshToken,
                 name='refresh-token'),  # type: ignore
        web.view('/logout', apis.Logout, name='logout')  # type: ignore
    ])
Beispiel #19
0
def routes(app: web.Application) -> None:
    app.add_routes([
        web.get("/", home),
        web.get("/{service_name}", service),
        web.get("/{service_name}/{ex_path}", service),
        web.post("/{service_name}/{ex_path}", service),
    ])
Beispiel #20
0
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.post("/connections/{conn_id}/start-introduction",
                 introduction_start)
    ])
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.get("/credential/{credential_id}",
                credentials_get,
                allow_head=False),
        web.get(
            "/credential/revoked/{credential_id}",
            credentials_revoked,
            allow_head=False,
        ),
        web.get(
            "/credential/mime-types/{credential_id}",
            credentials_attr_mime_types_get,
            allow_head=False,
        ),
        web.delete("/credential/{credential_id}", credentials_remove),
        web.get("/credentials", credentials_list, allow_head=False),
        web.get(
            "/credential/w3c/{credential_id}",
            w3c_cred_get,
            allow_head=False,
        ),
        web.delete("/credential/w3c/{credential_id}", w3c_cred_remove),
        web.post("/credentials/w3c", w3c_creds_list),
    ])
Beispiel #22
0
async def register(app: web.Application):
    """Register routes."""

    app.add_routes(
        [
            web.get("/mediation/requests", list_mediation_requests, allow_head=False),
            web.get(
                "/mediation/requests/{mediation_id}",
                retrieve_mediation_request,
                allow_head=False,
            ),
            web.delete("/mediation/requests/{mediation_id}", delete_mediation_request),
            web.post(
                "/mediation/requests/{mediation_id}/grant",
                mediation_request_grant,
            ),
            web.post("/mediation/requests/{mediation_id}/deny", mediation_request_deny),
            web.post("/mediation/request/{conn_id}", request_mediation),
            web.get("/mediation/keylists", get_keylist, allow_head=False),
            web.post(
                "/mediation/keylists/{mediation_id}/send-keylist-update",
                send_keylist_update,
            ),
            web.post(
                "/mediation/keylists/{mediation_id}/send-keylist-query",
                send_keylist_query,
            ),
            web.get(
                "/mediation/default-mediator", get_default_mediator, allow_head=False
            ),
            web.put("/mediation/{mediation_id}/default-mediator", set_default_mediator),
            web.delete("/mediation/default-mediator", clear_default_mediator),
        ]
    )
async def register(app: web.Application):
    """Register routes."""

    app.add_routes(
        [
            web.post(
                "/present-proof/request",
                request_presentation_endpoint,
            ),
            web.post(
                "/present-proof/present",
                present_proof_endpoint,
            ),
            web.post(
                "/present-proof/reject",
                present_proof_reject_endpoint,
            ),
            web.post(
                "/present-proof/acknowledge",
                acknowledge_proof,
            ),
            web.get(
                "/present-proof/exchange/record",
                retrieve_credential_exchange_api,
                allow_head=False,
            ),
        ]
    )
Beispiel #24
0
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.get("/presentation_exchange", presentation_exchange_list),
        web.get("/presentation_exchange/{id}", presentation_exchange_retrieve),
        web.get(
            "/presentation_exchange/{id}/credentials",
            presentation_exchange_credentials_list,
        ),
        web.get(
            "/presentation_exchange/{id}/credentials/{referent}",
            presentation_exchange_credentials_list,
        ),
        web.post(
            "/presentation_exchange/create_request",
            presentation_exchange_create_request,
        ),
        web.post(
            "/presentation_exchange/send_request",
            presentation_exchange_send_request,
        ),
        web.post(
            "/presentation_exchange/{id}/send_presentation",
            presentation_exchange_send_credential_presentation,
        ),
        web.post(
            "/presentation_exchange/{id}/verify_presentation",
            presentation_exchange_verify_credential_presentation,
        ),
        web.post("/presentation_exchange/{id}/remove",
                 presentation_exchange_remove),
    ])
Beispiel #25
0
async def register(app: web.Application):
    """Register routes."""
    app.add_routes([
        web.post("/schemas", schemas_send_schema),
        web.get("/schemas/created", schemas_created, allow_head=False),
        web.get("/schemas/{schema_id}", schemas_get_schema, allow_head=False),
    ])
Beispiel #26
0
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.get("/connections", connections_list, allow_head=False),
        web.get("/connections/{conn_id}",
                connections_retrieve,
                allow_head=False),
        web.post("/connections/create-static", connections_create_static),
        web.post("/connections/create-invitation",
                 connections_create_invitation),
        web.post("/connections/receive-invitation",
                 connections_receive_invitation),
        web.post(
            "/connections/{conn_id}/accept-invitation",
            connections_accept_invitation,
        ),
        web.post("/connections/{conn_id}/accept-request",
                 connections_accept_request),
        web.post(
            "/connections/{conn_id}/establish-inbound/{ref_id}",
            connections_establish_inbound,
        ),
        web.post("/connections/{conn_id}/remove", connections_remove),
    ])
Beispiel #27
0
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.post("/connections/{id}/send-ping", connections_send_ping),
        web.post("/connections/{id}/send-ping-v2", connections_send_ping_v2),
    ])
Beispiel #28
0
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.post("/connections/{conn_id}/send-message",
                 connections_send_message)
    ])
async def register(app: web.Application):
    """Register routes."""

    app.add_routes([
        web.get("/discover-features/query", query_features, allow_head=False),
        web.get("/discover-features/records", query_records, allow_head=False),
    ])
def init(cfg: Config, app: web.Application) -> None:
    global host, secret, config
    config = cfg
    secret = cfg["bridges.mx-puppet-twitter.secret"]
    if secret:
        host = URL(cfg["bridges.mx-puppet-twitter.url"])
    app.add_routes(routes)
Beispiel #31
0
def setup_routes(app: web.Application) -> None:
    app.add_routes([web.view('/connect/authorize', AuthorizeView),
                    web.view('/connect/token', TokenView),
                    web.view('/client', ClientListView),
                    web.view('/client/register', RegisterClientView),
                    web.view('/account', AccountListView),
                    web.view('/account/create', CreateAccountView),
                    web.view('/account/{username}', GetAccountView),
                    web.route('*', '/{tail:.*}', catch_all)])

    project_root = pathlib.Path(__file__).parent.parent
    app.add_routes([web.static('/static/',
                               path=project_root / 'static',
                               name='static')])
Beispiel #32
0
def setup_routes(app: web.Application) -> None:
    app.add_routes([web.route('*', '/.well-known/webfinger', negotiate.route)])