auth0 / go-auth0

Go SDK for the Auth0 Management API.
https://auth0.com
MIT License
121 stars 52 forks source link

Json Marshalling a ConnectionOptionsOIDC is causing failures when creating a new connection #422

Open alexTendo opened 1 month ago

alexTendo commented 1 month ago

Checklist

Description

When I attempt to create an oidc connection with just a discovery url I am receiving the following error. "options.issuer" must be a string This was working previously I'm not exactly sure when this broke as we don't use this endpoint very often

Expectation

expected: json to marshal correctly into the following with no null values actual: json includes null values example incorrect payload with null values:

{
  "name": "TestConnectionNameNew",
  "display_name": "Test Connection Name New",
  "strategy": "oidc",
  "is_domain_connection": false,
  "options": {
    "client_id": "testClientId",
    "client_secret": "testClientSecret",
    "discovery_url": "[myDiscoveryURL](https://accounts.google.com/.well-known/openid-configuration)",
    "authorization_endpoint": null,
    "issuer": null,
    "jwks_uri": null,
    "type": "back_channel",
    "userinfo_endpoint": null,
    "token_endpoint": null,
    "scope": "openid profile email",
  }
}

If I remove the null values and hit the endpoint directly this is a valid request

Reproduction

  1. Run the following code to create a new connection
    connection := &management.Connection{
        Name:               auth0.String(input.Name),
        DisplayName:        auth0.String(input.DisplayName),
        Strategy:           auth0.String(strategyOidc),
        IsDomainConnection: auth0.Bool(false),
        Options: &management.ConnectionOptionsOIDC{
            Type:         auth0.String(connectionTypeBackChannel),
            ClientID:     auth0.String(input.ClientId),
            ClientSecret: auth0.String(input.ClientSecret),
            DiscoveryURL: auth0.String(input.DiscoveryUrl),
            Scope:        auth0.String(connectionScopes),
        },
    }
    err = client.management.Connection.Create(ctx, connection)

Auth0 Go SDK version

v1.8.0

alexTendo commented 1 month ago

I opened this PR to address the issue. Not sure if this is the actual root cause but it at least unblocks the issue I am currently seeing https://github.com/auth0/go-auth0/pull/423

developerkunal commented 1 month ago

Hi @alexTendo,

I hope you are having a nice day!

We are aware of this issue, and our team is actively working on resolving it. It might take some time, but we don't anticipate needing any changes on the SDK side. The new changes should be compatible with the existing setup. I will update you as soon as the team resolves the issue on the API side.

Thank you for your contribution.