Skip to content

Credential provider protocol fails with strings containing escaped characters #13615

Open
@arlosi

Description

@arlosi

Problem

The structures defined in the credential provider protocol use borrowed string (&'a str) types that can only be deserialized if they don't contain any characters that need to be escaped by JSON. If escaping is required then the deserialization fails with:

invalid type: string "test\ning", expected a borrowed string

This can occur if, for example, the user attempts to use a " in a registry auth token. This is not a bug in the JSON protocol itself.

Steps

  1. Set up a credential provider
  2. Run cargo login
  3. Use a token that contains a "

Possible Solution(s)

  1. Switch to using Cow<'a, str> in the credential struct definitions.
  2. Switch to using String in the struct definitions.

Any solution seems to require a breaking change to the credential struct definitions.

Notes

No response

Version

cargo 1.78.0-nightly (fc1d58fd0 2024-02-09)
release: 1.78.0-nightly
commit-hash: fc1d58fd0531a57a6b942a14cdcdbcb82ece16f3
commit-date: 2024-02-09
host: x86_64-pc-windows-msvc
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.71+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.26085 (Windows 11 Enterprise) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-credential-providerArea: credential provider for storing and retreiving credentialsC-bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions