Skip to content

Support connect-go v2 #31

Open
Open

Description

@jferrl

connect-go v2 is out (v2.0.2), and authn-go still depends on connectrpc.com/connect v1. On a v2 server, two parts of the package break:

  • Middleware writes errors with v1's connect.NewErrorWriter. It doesn't recognise a v2 *connect.Error returned by an AuthFunc, so an expired or invalid token reaches the client as unknown (HTTP 500) instead of unauthenticated (401).
  • Errorf returns a v1 *connect.Error. A v2 handler that returns it sends unknown with no message.

The rest (AuthFunc, BearerToken, SetInfo / GetInfo) doesn't touch connect-go and works unchanged.

We migrated a service to v2 and worked around this with a small copy of Middleware and Errorf built on connecthttp.NewErrorWriter and v2's connect.Errorf.

Is v2 support planned? If not, would you accept a PR? One option is a connectrpc.com/authn/v2 module that depends on connect-go v2. It would keep the same API, with Middleware taking connecthttp options, while v1 stays as it is. I'm happy to follow a different layout if you'd prefer one.

Activity

  1. emcfarlane commented on Nov 11, 2026

    @emcfarlane
    Collaborator

    Hi @jferrl, thanks for creating the issue. We need a better story for the authn-go v2 behaviour. We don't have a v1 release of this module so a /v2/ module would skip a v1 release. See related issue connectrpc/otelconnect-go#227.

    I looked at moving to a pure v2 implementation in the branch connect-v2. In connect-go v1 it was a security issue to run authentication as an interceptor. See the v2 interceptor documentation for the background. So the issue with moving this to v2 is that it removes lots of the benefit of this module as it becomes trivial to implement in an interceptor. The authn-go helpers are still helpful though.

    Users have written custom interceptors to replace the authn-go module: https://go.dev/play/p/ZGIWI1AaisT
    We could provide helpers for users to implement interceptors and an interceptor like that.

    So I propose we add some v2 helpers to authn-go and make a new release. Happy to accept a PR, but I can look at adding this now too.

  2. jferrl commented on Nov 11, 2026

    @jferrl
    Author

    Hi @jferrl, thanks for creating the issue. We need a better story for the authn-go v2 behaviour. We don't have a v1 release of this module so a /v2/ module would skip a v1 release. See related issue connectrpc/otelconnect-go#227.

    Thanks, that direction LGTM. We’ll keep our small compatibility middleware until the v2 helpers are available. Happy to test them against our migration.

  3. emcfarlane commented on Nov 12, 2026

    @emcfarlane
    Collaborator

    @jferrl added the API in #32, please let me know if you test it and its suitable for your use case?

  4. jferrl commented on Nov 12, 2026

    @jferrl
    Author

    @jferrl added the API in #32, please let me know if you test it and its suitable for your use case?

    Thanks! let me take a look! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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