Skip to content
This repository was archived by the owner on Sep 22, 2023. It is now read-only.

Commit

Permalink
feat: Add revocation support to credentials
Browse files Browse the repository at this point in the history
Signed-off-by: Colton Wolkins <[email protected]>
  • Loading branch information
TheTechmage committed Sep 13, 2021
1 parent 4bc557e commit 686b1f5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
14 changes: 12 additions & 2 deletions acapy_plugin_toolbox/credential_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class CredDefRecord(BaseRecord):
STATE_UNWRITTEN = "unwritten"
STATE_WRITTEN = "written"

REVOCATION_SUPPORTED = True
REVOCATION_UNSUPPORTED = False

class Meta:
"""CredDefRecord metadata."""

Expand All @@ -78,6 +81,7 @@ def __init__(
attributes: [str] = None,
author: str = None,
state: str = None,
support_revocation: bool = False,
**kwargs
):
"""Initialize a new SchemaRecord."""
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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")

Expand All @@ -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:
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions demo/configs/alice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions demo/docker-compose.alice-bob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

0 comments on commit 686b1f5

Please sign in to comment.