Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnmarshalJSON fails for the LoginFlow type in kratos-client-go #347

Open
5 tasks done
agiix opened this issue Mar 28, 2024 · 0 comments
Open
5 tasks done

UnmarshalJSON fails for the LoginFlow type in kratos-client-go #347

agiix opened this issue Mar 28, 2024 · 0 comments
Labels
bug Something is not working.

Comments

@agiix
Copy link

agiix commented Mar 28, 2024

Preflight checklist

Ory Network Project

No response

Describe the bug

The Kratos Go client (version 1.1.0) fails to correctly unmarshal the JSON response into the LoginFlow object.
This happens because it defines the state field as a required property, which is not provided within the response from the Kratos instance (version 1.1.0)
An easy fix for it would be to remove the state field as a required property, like on this fork.

Reproducing the bug

When initiating a native login flow using something like:

kratosClient := client.NewAPIClient(configuration)
loginFlow, _, err := kratosClient.FrontendAPI.CreateNativeLoginFlow(context.Background()).Execute()
if err != nil {
	fmt.Println(err)
}

the error occurs.

Inspecting the response using curl to initiate the flow:

curl -X GET \                                          
    -H 'Content-Type: application-json' \
    127.0.0.1:4433/self-service/login/api

shows that there is no state field being returned at this stage of the flow:

{
  "id": "b63875be-64ea-48d5-84a6-ad2a04793687",
  "type": "api",
  "expires_at": "2024-03-28T22:26:36.416713342Z",
  "issued_at": "2024-03-28T22:16:36.416713342Z",
  "request_url": "http://127.0.0.1:4433/self-service/login/api",
  "ui": {
    "action": "http://kratos:4433/self-service/login?flow=b63875be-64ea-48d5-84a6-ad2a04793687",
    "method": "POST",
    "nodes": [
      {
        "type": "input",
        "group": "default",
        "attributes": {
          "name": "csrf_token",
          "type": "hidden",
          "value": "",
          "required": true,
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {}
      },
      {
        "type": "input",
        "group": "default",
        "attributes": {
          "name": "identifier",
          "type": "text",
          "value": "",
          "required": true,
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070004,
            "text": "ID",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "password",
        "attributes": {
          "name": "password",
          "type": "password",
          "required": true,
          "autocomplete": "current-password",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070001,
            "text": "Password",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "password",
        "attributes": {
          "name": "method",
          "type": "submit",
          "value": "password",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1010001,
            "text": "Sign in",
            "type": "info",
            "context": {}
          }
        }
      }
    ]
  },
  "created_at": "2024-03-28T22:16:36.446211Z",
  "updated_at": "2024-03-28T22:16:36.446211Z",
  "refresh": false,
  "requested_aal": "aal1"
}

Relevant log output

2024/03/28 20:21:00 stdout: no value given for required property state

Relevant configuration

No response

Version

1.1.0

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Docker Compose

Additional Context

No response

@agiix agiix added the bug Something is not working. label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant