Skip to content

Commit

Permalink
add endpoint which exposes invitation url with admin rights
Browse files Browse the repository at this point in the history
  • Loading branch information
Karol Krzosa committed May 15, 2020
1 parent 8696e75 commit d4c3991
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "aries-acapy-plugin-toolbox"]
path = aries-acapy-plugin-toolbox
url = https://github.com/THCLab/aries-acapy-plugin-toolbox
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions aries-acapy-plugin-toolbox
30 changes: 30 additions & 0 deletions aries_cloudagent/protocols/connections/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
21 changes: 10 additions & 11 deletions aries_cloudagent/protocols/credentials/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down
13 changes: 13 additions & 0 deletions startup.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d4c3991

Please sign in to comment.