Skip to content

Multiple valid passwords per user in CredentialProvider #1069

@ramnes

Description

@ramnes

Hey there, thanks for great library!

Currently, CredentialProvider.GetCredential returns a single password per username. In some use cases, a user may have multiple valid credentials (e.g., API tokens, rotating secrets) that should all be accepted during authentication.

Would you be open to replace GetCredential by a new GetCredentials method that returns a slice of valid credentials?

Another approach if we don't want to break existing implementations of the interface would be to add a new MultiCredentialProvider interface that embeds CredentialProvider and adds that new method.

Then in the authentication flow, we could check if the provider implements MultiCredentialProvider via type assertion:

  if mcp, ok := provider.(MultiCredentialProvider); ok {
      passwords, found, err := mcp.GetCredentials(username)
      // ...
  } else {
      password, found, err := provider.GetCredential(username)
      // ...
  }

Happy to submit a PR if any of the two approaches sounds reasonable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions