From d4c39913688a54eda00e91e7bd2defeb01818154 Mon Sep 17 00:00:00 2001 From: Karol Krzosa Date: Fri, 15 May 2020 11:14:52 +0200 Subject: [PATCH] add endpoint which exposes invitation url with admin rights --- .gitmodules | 3 + Dockerfile | 58 +++++++++++++++++++ aries-acapy-plugin-toolbox | 1 + .../protocols/connections/routes.py | 30 ++++++++++ .../protocols/credentials/routes.py | 21 ++++--- startup.sh | 13 +++++ 6 files changed, 115 insertions(+), 11 deletions(-) create mode 100644 .gitmodules create mode 100644 Dockerfile create mode 160000 aries-acapy-plugin-toolbox create mode 100755 startup.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..85477a241c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "aries-acapy-plugin-toolbox"] + path = aries-acapy-plugin-toolbox + url = https://github.com/THCLab/aries-acapy-plugin-toolbox diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..2dd701b8e4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,58 @@ +FROM bcgovimages/von-image:py36-1.11-1 + +ENV ENABLE_PTVSD 0 + +ADD requirements*.txt ./ + +RUN pip3 install --no-cache-dir -r requirements.txt -r requirements.dev.txt -r requirements.indy.txt + +COPY aries_cloudagent ./aries_cloudagent +COPY aries-acapy-plugin-toolbox ./aries-acapy-plugin-toolbox +COPY bin ./bin +COPY README.md ./ +COPY setup.py ./ +COPY startup.sh ./ + +USER root + +RUN pip3 install --no-cache-dir -e ".[indy]" +RUN /bin/bash -c "python3 -m venv env" +RUN /bin/bash -c "source env/bin/activate" +RUN /bin/bash -c "pip3 install -e /home/indy/aries-acapy-plugin-toolbox" +RUN pip3 install --no-cache-dir -r /home/indy/aries-acapy-plugin-toolbox/requirements.txt + +RUN apt-get update +RUN apt-get install -y wget gcc openssl pkg-config libssl-dev +# Rust +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + RUST_VERSION=1.41.1 + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b' ;; \ + armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='6c6c3789dabf12171c7f500e06d21d8004b5318a5083df8b0b02c0e5ef1d017b' ;; \ + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='26942c80234bac34b3c1352abbd9187d3e23b43dae3cf56a9f9c1ea8ee53076d' ;; \ + i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='27ae12bc294a34e566579deba3e066245d09b8871dc021ef45fc715dced05297' ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + url="https://static.rust-lang.org/rustup/archive/1.21.1/${rustArch}/rustup-init"; \ + wget "$url"; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ + chmod +x rustup-init; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + rustup --version; \ + cargo --version; \ + rustc --version; + +ADD https://github.com/sovrin-foundation/libsovtoken/archive/v1.0.1.tar.gz libsovtoken.tar.gz +ENV LIBINDY_DIR=/home/indy/.local/lib +ENV LD_LIBRARY_PATH=/home/indy/.local/lib +RUN tar xzvf libsovtoken.tar.gz; \ + cd libsovtoken-1.0.1/libsovtoken; \ + cargo build +ENV LIBSOVTOKEN=/home/indy/libsovtoken-1.0.1/libsovtoken/target/debug/libsovtoken.so diff --git a/aries-acapy-plugin-toolbox b/aries-acapy-plugin-toolbox new file mode 160000 index 0000000000..fa0e9c9a3f --- /dev/null +++ b/aries-acapy-plugin-toolbox @@ -0,0 +1 @@ +Subproject commit fa0e9c9a3fa2c67a57d6bb56ea63bdaea9e9e262 diff --git a/aries_cloudagent/protocols/connections/routes.py b/aries_cloudagent/protocols/connections/routes.py index 508d41f2fb..6b2ed16887 100644 --- a/aries_cloudagent/protocols/connections/routes.py +++ b/aries_cloudagent/protocols/connections/routes.py @@ -281,6 +281,35 @@ async def connections_create_invitation(request: web.BaseRequest): return web.json_response(result) +@docs(tags=["connection"], + summary="Create an invitation url which has admin rights") +@response_schema(InvitationResultSchema(), 200) +async def connections_create_admin_invitation_url(request: web.BaseRequest): + """ + Request handler for creating invitation url with admin rights + + Args: + request: aiohttp request object + + Returns: + Brand new invitation url with admin rights + """ + context = request.app["request_context"] + base_url = context.settings.get("invite_base_url") + + connection_mgr = ConnectionManager(context) + connection, invitation = await connection_mgr.create_invitation( + their_role=context.settings.get("debug.invite_role"), + my_label=context.settings.get("debug.invite_label"), + multi_use=context.settings.get("debug.invite_multi_use", False), + public=context.settings.get("debug.invite_public", False), + ) + result = { + "invitation_url": invitation.to_url(base_url), + } + + return web.json_response(result) + @docs( tags=["connection"], summary="Receive a new connection invitation", @@ -506,6 +535,7 @@ async def register(app: web.Application): web.get("/connections/{id}", connections_retrieve), web.post("/connections/create-static", connections_create_static), web.post("/connections/create-invitation", connections_create_invitation), + web.post("/connections/create-admin-invitation-url", connections_create_admin_invitation_url), web.post("/connections/receive-invitation", connections_receive_invitation), web.post( "/connections/{id}/accept-invitation", connections_accept_invitation diff --git a/aries_cloudagent/protocols/credentials/routes.py b/aries_cloudagent/protocols/credentials/routes.py index 91352a5a21..def1efba7e 100644 --- a/aries_cloudagent/protocols/credentials/routes.py +++ b/aries_cloudagent/protocols/credentials/routes.py @@ -9,7 +9,7 @@ from ...connections.models.connection_record import ConnectionRecord from ...holder.base import BaseHolder -from ...messaging.valid import INDY_CRED_DEF_ID, INDY_REV_REG_ID, INDY_SCHEMA_ID +from ...messaging.valid import INDY_CRED_DEF_ID, INDY_REV_REG_ID, INDY_SCHEMA_ID, UUID4 from ...storage.error import StorageNotFoundError from ...wallet.error import WalletNotFoundError @@ -107,10 +107,17 @@ class WitnessSchema(Schema): class CredentialSchema(Schema): """Result schema for a credential query.""" + attrs = fields.Dict( + description="Credential attributes", + ) schema_id = fields.Str( description="Schema identifier", **INDY_SCHEMA_ID ) + referent = fields.Str( + description="Credential referent", + **UUID4 + ) cred_def_id = fields.Str( description="Credential definition identifier", **INDY_CRED_DEF_ID @@ -119,17 +126,9 @@ class CredentialSchema(Schema): description="Revocation registry identifier", **INDY_REV_REG_ID ) - values = fields.Dict( - keys=fields.Str( - description="Attribute name" - ), - values=fields.Nested(RawEncCredAttrSchema), - description="Attribute names mapped to their raw and encoded values" + cred_rev_id = fields.Str( + description="Credential revocation identifier" ) - signature = fields.Dict(description="Digital signature") - signature_correctness_proof = fields.Dict(description="Signature correctness proof") - rev_reg = fields.Nested(RevRegSchema) - witness = fields.Nested(WitnessSchema) class CredentialListSchema(Schema): diff --git a/startup.sh b/startup.sh new file mode 100755 index 0000000000..200302ff75 --- /dev/null +++ b/startup.sh @@ -0,0 +1,13 @@ +aca-py start \ + -it http 0.0.0.0 80 \ + -ot http \ + -e $ACAPY_ENDPOINT \ + --label $AGENT_NAME \ + --auto-accept-requests --auto-ping-connection \ + --auto-respond-credential-proposal --auto-respond-credential-offer --auto-respond-credential-request --auto-store-credential \ + --auto-respond-presentation-proposal --auto-respond-presentation-request --auto-verify-presentation \ + --invite --invite-role admin --invite-label "$AGENT_NAME (admin)" \ + --genesis-url $GENESIS_URL \ + --wallet-type indy \ + --wallet-name $AGENT_NAME \ + --plugin acapy_plugin_toolbox