From 686b1f59ffb0ab004a445966cc42978780d7440e Mon Sep 17 00:00:00 2001 From: Colton Wolkins Date: Mon, 13 Sep 2021 13:47:07 -0600 Subject: [PATCH] feat: Add revocation support to credentials Signed-off-by: Colton Wolkins --- .../credential_definitions.py | 14 ++++++++++-- demo/configs/alice.yml | 2 ++ demo/docker-compose.alice-bob.yml | 22 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/acapy_plugin_toolbox/credential_definitions.py b/acapy_plugin_toolbox/credential_definitions.py index ad12f08b..b32439ef 100644 --- a/acapy_plugin_toolbox/credential_definitions.py +++ b/acapy_plugin_toolbox/credential_definitions.py @@ -64,6 +64,9 @@ class CredDefRecord(BaseRecord): STATE_UNWRITTEN = "unwritten" STATE_WRITTEN = "written" + REVOCATION_SUPPORTED = True + REVOCATION_UNSUPPORTED = False + class Meta: """CredDefRecord metadata.""" @@ -78,6 +81,7 @@ def __init__( attributes: [str] = None, author: str = None, state: str = None, + support_revocation: bool = False, **kwargs ): """Initialize a new SchemaRecord.""" @@ -86,6 +90,7 @@ def __init__( self.schema_id = schema_id self.attributes = attributes self.author = author + self.support_revocation = support_revocation @property def record_id(self) -> str: @@ -102,7 +107,7 @@ def record_tags(self) -> dict: """Get tags for record.""" return { prop: getattr(self, prop) - for prop in ("cred_def_id", "schema_id", "state", "author") + for prop in ("cred_def_id", "schema_id", "state", "author", "support_revocation") } @classmethod @@ -125,13 +130,14 @@ class Meta: schema_id = fields.Str(required=False) attributes = fields.List(fields.Str(), required=False) author = fields.Str(required=False) + support_revocation = fields.Bool(required=False) SendCredDef, SendCredDefSchema = generate_model_schema( name="SendCredDef", handler="acapy_plugin_toolbox.credential_definitions" ".SendCredDefHandler", msg_type=SEND_CRED_DEF, - schema={"schema_id": fields.Str(required=True)}, + schema={"schema_id": fields.Str(required=True), "support_revocation": fields.Bool(required=False)}, ) CredDefID, CredDefIDSchema = generate_model_schema( @@ -151,6 +157,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): session = await context.session() ledger: BaseLedger = session.inject(BaseLedger) issuer: IndyIssuer = session.inject(IndyIssuer) + support_revocation: bool = context.message.support_revocation # If no schema record, make one try: schema_record = await SchemaRecord.retrieve_by_schema_id( @@ -170,6 +177,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): attributes=schema["attrNames"], state=SchemaRecord.STATE_WRITTEN, author=SchemaRecord.AUTHOR_OTHER, + support_revocation=support_revocation, ) await schema_record.save(session, reason="Retrieved from ledger") @@ -182,6 +190,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): tag="{}_{}".format( schema_record.schema_name, schema_record.schema_version ), + support_revocation=support_revocation, ) ) except Exception as err: @@ -200,6 +209,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): attributes=list(map(canon, schema_record.attributes)), state=CredDefRecord.STATE_WRITTEN, author=CredDefRecord.AUTHOR_SELF, + support_revocation=support_revocation, ) await cred_def_record.save( session, reason="Committed credential definition to ledger" diff --git a/demo/configs/alice.yml b/demo/configs/alice.yml index ccc2d363..11612f23 100644 --- a/demo/configs/alice.yml +++ b/demo/configs/alice.yml @@ -43,6 +43,8 @@ auto-respond-presentation-proposal: true auto-respond-presentation-request: true auto-verify-presentation: true +tails-server-base-url: http://tails-server:6543 + # Wallet wallet-type: indy wallet-key: "insecure, for use in demo only" diff --git a/demo/docker-compose.alice-bob.yml b/demo/docker-compose.alice-bob.yml index f4b681c5..656850d4 100644 --- a/demo/docker-compose.alice-bob.yml +++ b/demo/docker-compose.alice-bob.yml @@ -33,3 +33,25 @@ services: ports: - "3003:3003" command: poetry run aca-py start --arg-file ./configs/bob.yml + + ngrok-tails-server: + image: wernight/ngrok +# networks: +# - tails-server + ports: + - 4044:4040 + command: ngrok http tails-server:6543 --log stdout + tails-server: + image: docker_tails-server + ports: + - 6543:6543 +# networks: +# - tails-server + command: > + tails-server + --host 0.0.0.0 + --port 6543 + --storage-path ${STORAGE_PATH:-/tmp/tails-files} + --log-level ${LOG_LEVEL:-INFO} +#networks: +# tails-server: