From 0dc0668e134a655dc2c53737c2e6c7553e7582a0 Mon Sep 17 00:00:00 2001 From: Andrii Holovko Date: Fri, 20 Oct 2023 14:36:49 +0300 Subject: [PATCH] feat: support for authorization-request-uri in wallet cli (#1488) Signed-off-by: Andrii Holovko --- component/wallet-cli/README.md | 1 + component/wallet-cli/cmd/oidc4vp_cmd.go | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/component/wallet-cli/README.md b/component/wallet-cli/README.md index 88b045971..4ce23e068 100644 --- a/component/wallet-cli/README.md +++ b/component/wallet-cli/README.md @@ -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 diff --git a/component/wallet-cli/cmd/oidc4vp_cmd.go b/component/wallet-cli/cmd/oidc4vp_cmd.go index c8effd004..d00271cc4 100644 --- a/component/wallet-cli/cmd/oidc4vp_cmd.go +++ b/component/wallet-cli/cmd/oidc4vp_cmd.go @@ -29,6 +29,7 @@ import ( type oidc4vpCommandFlags struct { serviceFlags *serviceFlags qrCodePath string + authorizationRequestURI string walletDIDIndex int enableLinkedDomainVerification bool enableTracing bool @@ -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=") @@ -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")