Skip to content

Commit

Permalink
feat: support for authorization-request-uri in wallet cli (trustbloc#…
Browse files Browse the repository at this point in the history
…1488)

Signed-off-by: Andrii Holovko <[email protected]>
  • Loading branch information
aholovko authored Oct 20, 2023
1 parent c1b9371 commit 0dc0668
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions component/wallet-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ To trace HTTP requests between `wallet-cli` and `vcs`, use the `--enable-tracing
Use the `oidc4vp` command to present Verifiable Credential(s) to the Verifier:
```bash
--authorization-request-uri string authorization request uri, starts with 'openid-vc://?request_uri=' prefix
--disable-domain-matching disables domain matching for issuer and verifier when presenting credentials (only for did:web)
--enable-linked-domain-verification enables linked domain verification
--enable-tracing enables http tracing
Expand Down
16 changes: 13 additions & 3 deletions component/wallet-cli/cmd/oidc4vp_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
type oidc4vpCommandFlags struct {
serviceFlags *serviceFlags
qrCodePath string
authorizationRequestURI string
walletDIDIndex int
enableLinkedDomainVerification bool
enableTracing bool
Expand Down Expand Up @@ -122,9 +123,17 @@ func NewOIDC4VPCommand() *cobra.Command {
wallet: w,
}

authorizationRequest, err := readQRCode(flags.qrCodePath)
if err != nil {
return fmt.Errorf("read qr code: %v", err)
var authorizationRequest string

if flags.authorizationRequestURI != "" {
authorizationRequest = flags.authorizationRequestURI
} else if flags.qrCodePath != "" {
authorizationRequest, err = readQRCode(flags.qrCodePath)
if err != nil {
return fmt.Errorf("read qr code: %v", err)
}
} else {
return fmt.Errorf("either --qr-code-path or --authorization-request-uri flag must be set")
}

requestURI := strings.TrimPrefix(authorizationRequest, "openid-vc://?request_uri=")
Expand Down Expand Up @@ -169,6 +178,7 @@ func createFlags(cmd *cobra.Command, flags *oidc4vpCommandFlags) {
cmd.Flags().StringVar(&flags.serviceFlags.mongoDBConnectionString, "mongodb-connection-string", "", "mongodb connection string")

cmd.Flags().StringVar(&flags.qrCodePath, "qr-code-path", "", "path to file with qr code")
cmd.Flags().StringVar(&flags.authorizationRequestURI, "authorization-request-uri", "", "authorization request uri, starts with 'openid-vc://?request_uri=' prefix")
cmd.Flags().BoolVar(&flags.enableLinkedDomainVerification, "enable-linked-domain-verification", false, "enables linked domain verification")
cmd.Flags().BoolVar(&flags.disableDomainMatching, "disable-domain-matching", false, "disables domain matching for issuer and verifier when presenting credentials (only for did:web)")
cmd.Flags().IntVar(&flags.walletDIDIndex, "wallet-did-index", -1, "index of wallet did, if not set the most recently created DID is used")
Expand Down

0 comments on commit 0dc0668

Please sign in to comment.