network icon indicating copy to clipboard operation
network copied to clipboard

Missing ClientSubmitSelfServiceLoginFlowBody and ClientSubmitSelfServiceSettingsFlowBody constructors

Open roboptics opened this issue 4 years ago • 7 comments

Preflight checklist

Describe the bug

Hi,

Using the .NET client SDK, the model classes ClientSubmitSelfServiceLoginFlowBody and ClientSubmitSelfServiceSettingsFlowBody are missing the constructors below:

public ClientSubmitSelfServiceLoginFlowBody(ClientSubmitSelfServiceLoginFlowWithLookupSecretMethodBody body)
public ClientSubmitSelfServiceLoginFlowBody(ClientSubmitSelfServiceLoginFlowWithWebAuthnMethodBodybody)
public ClientSubmitSelfServiceSettingsFlowBody(ClientSubmitSelfServiceSettingsFlowWithLookupMethodBody body)
public ClientSubmitSelfServiceSettingsFlowBody(ClientSubmitSelfServiceSettingsFlowWithWebAuthnMethodBody body)

required to submit the corresponding flow methods. Tried to manually set the ActualInstance property, but the setter performs type checking and fails.

Please advise.

Reproducing the bug

  1. Create a .NET application.
  2. Add the Ory.Client Nuget.
  3. Try to build the code below:
ClientSubmitSelfServiceSettingsFlowBody body =
  new ClientSubmitSelfServiceSettingsFlowBody(
    new ClientSubmitSelfServiceSettingsFlowWithLookupMethodBody());

Relevant log output

No response

Relevant configuration

No response

Version

0.0.1-alpha.30

On which operating system are you observing this issue?

No response

In which environment are you deploying?

No response

Additional Context

No response

roboptics avatar Jan 14 '22 13:01 roboptics

So sorry to hear you having trouble with this! The SDK is unfortunately fully autogenerated and the generator is known to have some bugs. Unfortunately we don’t yet have someone responsible for DotNet.

Would the equal raw HTTP request suffice as a workaround?

aeneasr avatar Jan 14 '22 15:01 aeneasr

Hi,

If no other solution is available, that is an option. Thank you for your support.

roboptics avatar Jan 14 '22 18:01 roboptics

Could you share the full call in the SDK you are making? Will translate to REST then :)

aeneasr avatar Jan 17 '22 09:01 aeneasr

Hi,

Below is a snippet of the relevant part of the code calling the SDK. Note that this code does not build because the called ClientSubmitSelfServiceLoginFlowBody constructor does not exist with argument type of ClientSubmitSelfServiceLoginFlowWithLookupSecretMethodBody. If it helps I can send samples for the other 3 missing constructors, but it is more of the same.

        [Inject]
        private V0alpha2Api Api { get; set; }

        protected async Task OnSubmit()
        {
            ClientSubmitSelfServiceLoginFlowBody body;

            body = new ClientSubmitSelfServiceLoginFlowBody(
                new ClientSubmitSelfServiceLoginFlowWithLookupSecretMethodBody(
                    _form.Model.CsrfToken,
                    _form.Model.LookupSecret,
                    "lookup_secret"));

            var login = await Api.SubmitSelfServiceLoginFlowAsync(
                _flow.Id,
                null,
                body);
        }

Let me know if you need any further input on our part.

roboptics avatar Jan 17 '22 12:01 roboptics

Sorry, I missed the notification! I’ll answer tomorrow if you’re still looking for a solution :)

aeneasr avatar Jan 19 '22 22:01 aeneasr

No problem. This issue is still on the pending tasks list. If you have any update, let me know and we will try it out.

roboptics avatar Jan 20 '22 09:01 roboptics

Ok! So, the way you submit this form with REST would be like this:

curl 'https://<project>.projects.oryapis.com/api/kratos/public/self-service/login?flow=<the flow id you have>' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -H 'cookie: csrf_token_<a unique hash from the server>=<the csrf cookie>; ory_session_<a unique id from the server>=<the session cookie>' \
  --data-raw 'csrf_token=Lo%2F4J2Jrb82dpmmONHmWCzd2b2axYw6U2eWZX3%2BOm%2F5r0BB3yIqMDXlbE1zWgnh2qTNH513c9aM%2FG8xi7yMU2w%3D%3D&totp_code=&lookup_secret=<the code frmo the user>&method=lookup_secret' \
  --compressed

The cookies csrf_token_... and ory_session_... should be copied from the request that ends up at your server. So you can basically just "pipe" the Set-Cookie header that arrives in your handler to Ory Kratos. That should do the trick! Make sure those cookies are set in the request with some printf statement. If they are not set, the flow will fail!

Hope this helps :)

aeneasr avatar Jan 20 '22 10:01 aeneasr

This should be fixed by now!

aeneasr avatar Nov 16 '22 10:11 aeneasr