Skip to content

Commit

Permalink
Add delete wallet credential endpoint
Browse files Browse the repository at this point in the history
Added a new endpoint to delete specific credentials from a wallet in both the YAML document and the IAM API. This update adds a new DELETE method to the /internal/auth/v2/{did}/wallet/{id} path, where the id parameter defines the credential to delete. Updates were made across multiple files to ensure full implementation of the feature.
  • Loading branch information
rolandgroen committed Jan 31, 2024
1 parent cb1f773 commit aeec3e3
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 0 deletions.
22 changes: 22 additions & 0 deletions auth/api/iam/api_mitzxnuts.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,28 @@ func (r Wrapper) SearchWallet(ctx context.Context, request SearchWalletRequestOb
return response, nil
}

func (r Wrapper) DeleteWalletCredential(ctx context.Context, request DeleteWalletCredentialRequestObject) (DeleteWalletCredentialResponseObject, error) {
holderDid, err := did.ParseDID(request.Did)
if err != nil {
return nil, err
}
list, err := r.vcr.Wallet().List(ctx, *holderDid)
if err != nil {
return nil, err
}
for i := range list {
resolvedVC := list[i]
if resolvedVC.ID.String() == request.Id {
err = r.vcr.Wallet().Delete(ctx, *holderDid, *resolvedVC.ID)
if err != nil {
return nil, err
}
continue
}
}
return nil, nil
}

func (r Wrapper) iamClient() iam.HTTPClient {
return iam.NewHTTPClient(r.strictMode, r.httpClientTimeout, r.httpClientTLS)
}
Expand Down
97 changes: 97 additions & 0 deletions auth/api/iam/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions docs/_static/auth/iam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ paths:
* 503 - the authorizer could not be reached or returned an error
tags:
- auth
- wallet
parameters:
- name: did
in: path
Expand All @@ -631,6 +632,39 @@ paths:
description: The Verifiable Presentations that were used to request the access token using the same encoding as used in the access token request.
default:
$ref: '../common/error_response.yaml'
/internal/auth/v2/{did}/wallet/{id}:
delete:
summary: Delete a specific credential in a wallet
description: |
Removes the credential from the wallet.
error returns:
* 404 - Corresponding credential could not be found
* 500 - An error occurred while processing the request
tags:
- auth
- wallet
parameters:
- name: did
in: path
required: true
description: The did of the owner.
schema:
type: string
example: did:web:example.com:55d7a35d-d7bf-436f-80f7-3fef4077f8a8
- name: id
in: path
required: true
description: The id of the credential.
schema:
type: string
example: did:web:example.com:55d7a35d-d7bf-436f-80f7-3fef4077f8a8#dadas
operationId: deleteWalletCredential
responses:
"204":
description: Credential was successfully deleted
default:
$ref: '../common/error_response.yaml'
/internal/auth/v2/accesstoken/introspect:
post:
operationId: introspectAccessToken
Expand Down

0 comments on commit aeec3e3

Please sign in to comment.