Coder Social home page Coder Social logo

ory / sdk Goto Github PK

View Code? Open in Web Editor NEW
137.0 137.0 85.0 150.14 MB

The place where ORY's SDKs are being auto-generated

License: Apache License 2.0

Dockerfile 0.01% Shell 0.05% PHP 20.45% Python 12.32% Ruby 10.49% TypeScript 7.86% Dart 8.70% Rust 2.88% C# 16.58% Scala 0.01% Java 19.20% Elixir 1.41% Mustache 0.05%

sdk's Introduction

Generated SDKs for the Ory Ecosystem

All SDKs provided in this repository are generated using openapi-generator.

Ory Network SDKs

When developing against Ory Network, use the latest client or ory-client SDK for your preferred language. It bundles the individual SDKs (Identities, OAuth2, Permissions) and works with Ory API keys.

Ory self-hosted SDKs

When developing against self-hosted Ory components (Kratos, Hydra, Keto), use the corresponding individual SDKs for your language and match the SDK version to the version of Kratos/Hydra/Keto you have deployed.

Publish the Docker Image

To publish the SDK Builder Docker Image, create a new GitHub release with the desired version.

You may also manually build and publish this image using:

docker build --platform linux/adm64 -t oryd/sdk:latest .
docker tag oryd/sdk:latest oryd/sdk:v0.0.53
docker push oryd/sdk:v0.0.53

Running the Image Locally

If you wish to debug some generators or build steps, you can run the image locally:

docker build -t oryd/sdk:latest .
docker run --mount type=bind,source="$(pwd)",target=/project --name sdk --user "$(id -u):$(id -g)" -it oryd/sdk:latest /bin/sh

Debugging Failing Tests on CI

If a test fails in CI, you may run the following code snippet to reproduce the failure locally:

docker build -t oryd/sdk:latest .
docker run --mount type=bind,source="$(pwd)",target=/project --name sdk -it oryd/sdk:latest /bin/bash

export FORCE_PROJECT=client # or hydra or something else
export FORCE_VERSION=$(cat /project/spec/$FORCE_PROJECT/latest) # or a specific version, e.g. v1.2.17
cd /project

./scripts/generate.sh
./scripts/test.sh

Commit a new spec

Place the spec in spec/<project>/<version>.json (e.g. spec/hydra/v0.0.0-alpha.1.json) and create a commit that references both the project and the version git commit -a -m "Add spec for <project>:<version>" (e.g. git commit -a -m "Add spec for hydra:v0.0.0-alpha.1").

Do not create multiple commits adding several specs in one PR, as only the latest commit will be checked when it lands on master.

Because this is an automated process, it is highly recommended to add, commit, and push the spec file directly to master in one go!

You can create a PR if you're making changes to the build chain.

Upgrading OpenAPI Generator

Upgrading OpenAPI Generator versions requires careful upgrading of the Java pom.xml. The file might contain new versions for dependencies, but if overwritten, will not work with the release pipeline.

Therefore, the pom.xml file is being always overwritten from the contrib/poms directory for each project. To update any dependencies, the changes must thus be made there. We recommend running the openapi generator manually on the local machine and diffing the changes with contents in contrib/poms.

Publishing

PHP - Packagist

Install PHP and composer. Then, run the install command to initialize everything:

export PROJECT=hydra
cd clients/${PROJECT}/php
composer install

Then, push the directory to a git remote of your choosing and also publish the tag you want to release the package as. You can take a look at ./scripts/publish.sh to understand how to accomplish that.

Python - PyPi / pip

First, install all the necessary tools and python3:

python3 -m pip install --user --upgrade setuptools wheel twine

Next, create a PyPi account and API Token and set the env vars to:

export TWINE_USERNAME=__token__
export TWINE_PASSWORD=<token>

Then, publish the project (and set the project name):

export PROJECT=hydra
cd clients/${PROJECT}/python
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*

Ruby

You need to set GEM_HOST_API_KEY

Java - Maven Central

For keys read https://blackdoor.github.io/blog/maven-cd/

Due to a bug in openapi-generator that appears in Java11+, please disable javadoc generation:

mvn <cmd> -Dmaven.javadoc.skip=true

To test the build for Java, run:

$ ./scripts/generate.sh
$ cd clients/<project>/java
$ mvn test-compile

You will also need a PGP keypair that is associated with one of the owners of the sh.ory group and that is published on one of the public key servers. For more details, see: https://dzone.com/articles/publish-your-artifacts-to-maven-central

mvn clean

# THESE VALUES ARE EXAMPLES - PLEASE PICK THE APPROPRIATE `tag`, etc
mvn -Dtag=client-0.0.1-alpha.1 release:update-version \
  -DreleaseVersion=0.0.1-alpha.1 -DdevelopmentVersion=0.0.1-alpha.1-SNAPSHOT \
  -Darguments="-Dmaven.javadoc.skip=true" -Dresume=false

mvn release:perform -Darguments="-Dmaven.javadoc.skip=true" -Dresume=false

sdk's People

Contributors

adamwalach avatar aeneasr avatar allenkaplan avatar alnr avatar benehiko avatar gen1us2k avatar hperl avatar ichordedionysos avatar jmlind avatar jonas-jonas avatar k-yle avatar kevgo avatar kolotaev avatar maltebellmann avatar marcuzz avatar mojotalantikite avatar nekuromento avatar nickufer avatar ory-bot avatar tobbbles avatar ukonnra avatar vinckr avatar woodywoodsta avatar yholkamp avatar zageron avatar zepatrik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk's Issues

Retry flaky jobs

Some jobs (e.g. uploading archives to Maven) are flaky and fail with network errors. Instead of failing the script as a whole, these tasks should be retried.

Dotnet SDK generation fails

+ dotnet pack
Process terminated. Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
   at System.Environment.FailFast(System.String)
   at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
   at System.Globalization.GlobalizationMode..cctor()
   at System.Globalization.CultureData.CreateCultureWithInvariantData()
   at System.Globalization.CultureData.get_Invariant()
   at System.Globalization.CultureInfo..cctor()
   at System.String.ToLowerInvariant()
   at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetArch()
   at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment..cctor()
   at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()
   at Microsoft.DotNet.Cli.MulticoreJitProfilePathCalculator.CalculateProfileRootPath()
   at Microsoft.DotNet.Cli.MulticoreJitActivator.StartCliProfileOptimization()
   at Microsoft.DotNet.Cli.MulticoreJitActivator.TryActivateMulticoreJit()
   at Microsoft.DotNet.Cli.Program.Main(System.String[])
./scripts/release.sh: line 109:  4253 Aborted                 (core dumped) dotnet pack

See https://app.circleci.com/pipelines/github/ory/sdk/181/workflows/688e5aae-2b58-41d1-a6c0-e4deb95a6299/jobs/180

/cc @Marcuzz

Python client syntax error in v1.9.2 - duplicate parameter name

It appears in v1.9.2 there is a duplicate parameter name in the constructor of PluginConfig which causes
Python to complain of a syntax error.

https://github.com/ory/sdk/blob/master/clients/hydra/python/ory_hydra_client/model/plugin_config.py#L150

>   from ory_hydra_client.model.plugin_config import PluginConfig
E     File "/home/circleci/project/.nox/test-3-8-authorization/lib/python3.8/site-packages/ory_hydra_client/model/plugin_config.py", line 150
E       def __init__(self, args, description, documentation, entrypoint, env, interface, ipc_host, linux, mounts, network, pid_host, propagated_mount, work_dir, *args, **kwargs):  # noqa: E501
E       ^
E   SyntaxError: duplicate argument 'args' in function definition

This is probably an issue for https://openapi-generator.tech but I guess they won't be able to fix this specific case.

[Kratos Ruby SDK] How to setup the sdk in ruby.

Hello,

I have some problems when start to use the sdk on a ruby gem.

Traceback (most recent call last):
	7: from bin/console:4:in `<main>'
	6: from bin/console:4:in `require'
	5: from /home/lucas/workspaces/ferreri/prever/ferreri_kratos_sdk/lib/ferreri_kratos_sdk.rb:3:in `<top (required)>'
	4: from /home/lucas/workspaces/ferreri/prever/ferreri_kratos_sdk/lib/ferreri_kratos_sdk.rb:3:in `require'
	3: from /home/lucas/workspaces/ferreri/prever/ferreri_kratos_sdk/lib/ferreri_kratos_sdk/clients/ory.rb:1:in `<top (required)>'
	2: from /home/lucas/workspaces/ferreri/prever/ferreri_kratos_sdk/lib/ferreri_kratos_sdk/clients/ory.rb:1:in `require'
	1: from /home/lucas/.rvm/gems/ruby-2.7.3/gems/ory-kratos-client-0.6.3.alpha1/lib/ory-kratos-client.rb:17:in `<top (required)>'
/home/lucas/.rvm/gems/ruby-2.7.3/gems/ory-kratos-client-0.6.3.alpha1/lib/ory-kratos-client.rb:17:in `require': /home/lucas/.rvm/gems/ruby-2.7.3/gems/ory-kratos-client-0.6.3.alpha1/lib/ory-kratos-client/configuration.rb:228: syntax error, unexpected ',' (SyntaxError)
            in: ,
                ^
/home/lucas/.rvm/gems/ruby-2.7.3/gems/ory-kratos-client-0.6.3.alpha1/lib/ory-kratos-client/configuration.rb:229: syntax error, unexpected ',', expecting `end'
...     key: 'ory_kratos_session',
...                              ^
/home/lucas/.rvm/gems/ruby-2.7.3/gems/ory-kratos-client-0.6.3.alpha1/lib/ory-kratos-client/configuration.rb:231: syntax error, unexpected '}', expecting `end'
          },
          ^
/home/lucas/.rvm/gems/ruby-2.7.3/gems/ory-kratos-client-0.6.3.alpha1/lib/ory-kratos-client/configuration.rb:232: syntax error, unexpected =>, expecting `end'
        'sessionToken' =>
                       ^~
/home/lucas/.rvm/gems/ruby-2.7.3/gems/ory-kratos-client-0.6.3.alpha1/lib/ory-kratos-client/configuration.rb:238: syntax error, unexpected ',', expecting `end'
          },
           ^
/home/lucas/.rvm/gems/ruby-2.7.3/gems/ory-kratos-client-0.6.3.alpha1/lib/ory-kratos-client/configuration.rb:291: syntax error, unexpected end-of-input, expecting `end'

I am trying:

# the error occurred here
require 'ory-kratos-client'

configuration = OryHydraClient::Configuration.New(
    host = "http://localhost:4433"
)

module FerreriKratosSdk
    module Clients        
        class ClientOry
            def initialize
                # configuration = OryHydraClient::Configuration.New(
                #     host = "http://localhost:4433"
                # )
                # @cli = OryHydraClient::PublicApi.new(config=configuration)

            end 

Inaccurate pip command for installation of ory-kratos-client

In the README.md file of the ory-kratos-client for python it is written that the command to install this package via pip is

pip install git+https://github.com/ory/sdk.git

However, pip complains that the file setup.py doesn't exist.
I ended up using this line in order to make it work:

pip install git+https://github.com/ory/sdk.git#subdirectory=clients/kratos/python

PHP deserialise problem for \Ory\Kratos\Client\Model\UiNode

Describe the bug

Getting error when calling initializeSelfServiceLoginFlowWithoutBrowser()

To Reproduce

Steps to reproduce the behavior:

    $configuration = new Configuration();
    $configuration->setHost("http://kratos:4433");
    $kratosApi = new V0alpha1Api(null, $configuration);
    $loginFlow = $kratosApi->initializeSelfServiceLoginFlowWithoutBrowser();

produces this error:

array:7 [
"message" => "settype(): Invalid type"
"class" => "ErrorException"
"localized_message" => null
"code" => null
"errors" => array:79 [
0 => array:4 [
"function" => "handleError"
"class" => "Illuminate\Foundation\Bootstrap\HandleExceptions"
"type" => "->"
"args" => array:5 [
0 => 2
1 => "settype(): Invalid type"
2 => "/home/default/app/vendor/ory/kratos-client-php/lib/ObjectSerializer.php"
3 => 335
4 => array:3 [
"data" => ""
"class" => "mixed"
"httpHeaders" => null
]
]
]
1 => array:4 [
"file" => "/home/default/app/vendor/ory/kratos-client-php/lib/ObjectSerializer.php"
"line" => 335
"function" => "settype"
"args" => array:2 [
0 => ""
1 => "mixed"
]
]
2 => array:6 [
"file" => "/home/default/app/vendor/ory/kratos-client-php/lib/ObjectSerializer.php"
"line" => 385
"function" => "deserialize"
"class" => "Ory\Kratos\Client\ObjectSerializer"
"type" => "::"
"args" => array:3 [
0 => ""
1 => "mixed"
2 => null
]
]
3 => array:6 [
"file" => "/home/default/app/vendor/ory/kratos-client-php/lib/ObjectSerializer.php"
"line" => 385
"function" => "deserialize"
"class" => "Ory\Kratos\Client\ObjectSerializer"
"type" => "::"
"args" => array:3 [
0 => array:5 [
"name" => "csrf_token"
"type" => "hidden"
"value" => ""
"required" => true
"disabled" => false
]
1 => "\Ory\Kratos\Client\Model\UiNodeAttributes"
2 => null
]
]
4 => array:6 [
"file" => "/home/default/app/vendor/ory/kratos-client-php/lib/ObjectSerializer.php"
"line" => 286
"function" => "deserialize"
"class" => "Ory\Kratos\Client\ObjectSerializer"
"type" => "::"
"args" => array:3 [
0 => array:5 [
"type" => "input"
"group" => "default"
"attributes" => array:5 [
"name" => "csrf_token"
"type" => "hidden"
"value" => ""
"required" => true
"disabled" => false
]
"messages" => []
"meta" => []
]
1 => "\Ory\Kratos\Client\Model\UiNode"
2 => null
]
]

Expected behavior

Should return deserialized login flow object.

Environment

  • Version: v0.7
  • Environment: MacOs, Docker, ...

Additional context

The problem is with the "value" attribute since it doesn't have the type set in the openapi spec.

pyhton authentication issues with session cookie

Note: I already reached out to the ory community on slack pointing out that i would be willing to write a patch for this if someone can point me into the right direction.

kratos version and environment

Kratos: oryd/kratos:v0.5.4-alpha.1-sqlite and v0.5.5-alpha.1-pre.1-sqlite

SDK: 0.5.4-alpha1 python (via pip)

Description of my issues

Requests from flask to kratos's settings endpoint return 'unauthorized' even tho I am passing the session cookie of a user that has been redirected to flask using the recovery link.

I mostly followed the docs of the python sdk:

From https://github.com/ory/sdk/blob/master/clients/kratos/python/docs/PublicApi.md#get_self_service_settings_flow

# Configure API key authorization: sessionToken
configuration = ory_kratos_client.Configuration(
    host = "http://localhost",
    api_key = {
        'X-Session-Token': 'YOUR_API_KEY'
    }
)
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['X-Session-Token'] = 'Bearer'

# Enter a context with an instance of the API client
with ory_kratos_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ory_kratos_client.PublicApi(api_client)
    id = 'id_example' # str | ID is the Settings Flow ID  The value for this parameter comes from `flow` URL Query parameter sent to your application (e.g. `/settings?flow=abcde`).

    try:
        # Get Settings Flow
        api_response = api_instance.get_self_service_settings_flow(id)

I implemented it like this:

    @kratos_is_ready
    def get_settings(self, flow_id, session_key):
        ## Add user session key to kratos api object
        self.kratos_config.api_key = {
            "X-Session-Token": session_key
        }
        self.kratos_config.api_key_prefix["X-Session-Token"] = "Bearer"
        kratos = ory_kratos_client.ApiClient(self.kratos_config)
        kratos_admin = ory_kratos_client.PublicApi(kratos)
        try:
            settings_flow_object = kratos_admin.get_self_service_settings_flow(flow_id)
        except ApiException as e:
            raise BackendConnectionError(e.reason)
        except MaxRetryError as error:
            raise BackendConnectionError(str(error.reason))
        password_method = settings_flow_object.methods["password"]

And I have written a test which expects this:

def test_get_service_variables(httpserver):
    kratos_url = httpserver.url_for("")
    httpserver.expect_request("/health/ready").respond_with_json({})
    httpserver.expect_request(
        "/self-service/settings/flows",
        query_string=f"id=fake-flow-id",
        headers={"X-Session-Token": "Bearer fake-session-key"},
    ).respond_with_json(
        {
            "id": "fake-flow-id",
            "type": "browser",
            "expires_at": "2021-03-17T16:09:37.457574217Z",
            "issued_at": "2021-03-17T15:09:37.457574217Z",
            "request_url": "http://ignored:4433/self-service/settings/browser",
            <---------------- some other lines that are not important here --------------->
        }
    )
    login_flow = LoginFlow(kratos_url)
    settings_form_data = login_flow.get_settings(
        "fake-flow-id", "fake-session-key"
    )
    assert settings_form_data.csrf_token == "insecure_csrf_token"
    assert settings_form_data.identity == "[email protected]"

The test passes so everything seems good, right?

testing with the actual server

However the API returns an unauthorized when I try the code against the real server.

using the recovery function i get a link via email, which looks like this:

 http://127.0.0.1:4433/self-service/recovery/methods/link?token=M3FV0w95kDIurOGpzW9zK24iLEgDqpoT

just as expected, when i click on the link the kratos endpoint creates a session (cookie is created) and redirects to my /settings endpoint. my settings endpoint then extracts the session cookie and triggers the get_settings function from above by doing this:

    if "ory_kratos_session" in request.cookies:
        kratos_session = request.cookies.get("ory_kratos_session")
        form_data = kratos.get_settings(
            flow_id=flow, session_key=kratos_session
        )

I already debugged through the whole python sdk and I can't spot anything obvious.
While reading through the code of kratoss sdk I found some things that confuse me.

First this line:

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['X-Session-Token'] = 'Bearer'

Do I need this or not?

Then there is another one in the implementation of Configuration https://github.com/ory/sdk/blob/master/clients/kratos/python/ory_kratos_client/configuration.py:

    :Example:
    API Key Authentication Example.
    Given the following security scheme in the OpenAPI specification:
      components:
        securitySchemes:
          cookieAuth:         # name for the security scheme
            type: apiKey
            in: cookie
            name: JSESSIONID  # cookie name
    You can programmatically set the cookie:
conf = ory_kratos_client.Configuration(
    api_key={'cookieAuth': 'abc123'}
    api_key_prefix={'cookieAuth': 'JSESSIONID'}
)
    The following cookie will be added to the HTTP request:
       Cookie: JSESSIONID abc123
    """

But looking at the code around line 331
we find:

    def auth_settings(self):
        """Gets Auth Settings dict for api client.
        :return: The Auth Settings information dict.
        """
        auth = {}
        if 'X-Session-Token' in self.api_key:
            auth['sessionToken'] = {
                'type': 'api_key',
                'in': 'header',
                'key': 'X-Session-Token',
                'value': self.get_api_key_with_prefix('X-Session-Token')
            }
        return auth

So i assume X-Session-Token is the only header that works.
Also i think an exception should be thrown here if authentication is required instead of silenty ignoring other auuth headers.

anyways, cookie auth doesn't seem to be supported anymore.
And maybe this is where I am doing something wrong?

additional information

the auth cookie which I am using (ory_kratos_session) looks like this:

image

stacktraces

Traceback (most recent call last):
  File "/usr/src/app/service.py", line 139, in get_settings_form_data
    settings_flow_object = kratos_admin.get_self_service_settings_flow(flow_id)
  File "/usr/local/lib/python3.7/site-packages/ory_kratos_client/api/public_api.py", line 1465, in get_self_service_settings_flow
    return self.get_self_service_settings_flow_with_http_info(id, **kwargs)  # noqa: E501
  File "/usr/local/lib/python3.7/site-packages/ory_kratos_client/api/public_api.py", line 1554, in get_self_service_settings_flow_with_http_info
    collection_formats=collection_formats)
  File "/usr/local/lib/python3.7/site-packages/ory_kratos_client/api_client.py", line 369, in call_api
    _preload_content, _request_timeout, _host)
  File "/usr/local/lib/python3.7/site-packages/ory_kratos_client/api_client.py", line 188, in __call_api
    raise e
  File "/usr/local/lib/python3.7/site-packages/ory_kratos_client/api_client.py", line 185, in __call_api
    _request_timeout=_request_timeout)
  File "/usr/local/lib/python3.7/site-packages/ory_kratos_client/api_client.py", line 393, in request
    headers=headers)
  File "/usr/local/lib/python3.7/site-packages/ory_kratos_client/rest.py", line 234, in GET
    query_params=query_params)
  File "/usr/local/lib/python3.7/site-packages/ory_kratos_client/rest.py", line 224, in request
    raise ApiException(http_resp=r)
ory_kratos_client.exceptions.ApiException: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Cache-Control': 'private, no-cache, no-store, must-revalidate', 'Content-Type': 'application/json', 'Set-Cookie': 'csrf_token=jILDmHeQE7FchT370+J3kCFXr5UGsA98/oSB6TlD0cc=; Path=/; Domain=127.0.0.1; Max-Age=31536000; HttpOnly; SameSite=Lax', 'Vary': 'Origin, Cookie', 'Date': 'Thu, 18 Mar 2021 14:57:42 GMT', 'Content-Length': '166'})
HTTP response body: {"error":{"code":401,"status":"Unauthorized","reason":"A valid ORY Session Cookie or ORY Session Token is missing.","message":"The request could not be authorized"}}

image

Rust SDK

I wanted to see if there was any interest in a Rust SDK for ORY services. I'd be happy to help get it together and test it out.

One issue I hit trying to test Rust openapi generation locally just now is that the openjdk:12-alpine Docker image doesn't support ARM and I'm currently using the new M1 Apple silicon. Do you have plans to move to a base Docker image that does support ARM? I'd be up for helping with that in a separate issue if so, otherwise I can switch to an old Intel mac to help with this one. Thanks!

Active field should not be required for Kratos registration

Kratos version: v0.2.1-alpha.1
Oathkeeper version: v0.38.1-beta.1
SDK version: Python 0.2.1a1

When calling:
api_response = api_instance.get_self_service_browser_registration_request(request)
I get the following exception:
Invalid value for 'active', must not be 'None'
This is the same problem as #10 and #11 and I think the solution here is the same.

The following line is the one that causes the problem: https://github.com/ory/kratos/blob/master/selfservice/flow/registration/request.go#L45

omitempty-flag is set but required true is also set so an exception is thrown in the Python SDK when it is omitted. The solution is probably to remove required: true. Strangely, this is only set for the registration flow, not any other flow and I don't know if you can set this active property. I don't see anything about it in the documentation. Also the active property documentation in the SDK seems a bit broken, it just says:

and so on.

Python client username/password are not sent

Tried to use basic authentication with the python client, but it simply does not work. This is the code:

config = ory_hydra_client.Configuration(
    host=app.config["ORY_HOST"],
    username="username",
    password="password",
)  

client = ory_hydra_client.ApiClient(config)

api_instance = admin_api.AdminApi(client)

# error!
api_instance.get_login_request(challenge)

What am I doing wrong?

PHP SDK code generator makes Authorization headers misbehave

Hi everyone. First of all, thank you for giving the community such a great open-source tool as Hydra.

I tested out the PHP SDK and in general, it works well, except when trying to exchange the authorization code for an access token, even when setting the username and password in the configuration passed to PublicApi.

The generated code based on these properties

   /**
     * Access token for OAuth/Bearer authentication
     *
     * @var string
     */
    protected $accessToken = '';

    /**
     * Username for HTTP basic authentication
     *
     * @var string
     */
    protected $username = '';

    /**
     * Password for HTTP basic authentication
     *
     * @var string
     */
    protected $password = '';

will always make this block misbehave:

        // this endpoint requires HTTP basic authentication
        if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) {
            $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
        }
        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

since the access token is never null (defaults to ''), so the Authorization header will always have the value Bearer .

I can make a pull request to fix this, just point me in the rigth direction on how to regenerate the code to test the fix.

rust serialize error: UiNodeInputAttributesValue

server info
server_version: ory_kratos v0.6.0.alpha2

client_sdk
language: rust
version: v0.6.0.alpha17

bug info

  1. when ::public_api::calling initialize_self_service_registration_via_api_flow, the success return struct is RegistrationFlow, which contains nested type ui -> UiContainer -> Vec ->UiNodeInputAttributesValue
  2. the return value gives string while the generated struct as empty struct.

error log:

Message:  called `Result::unwrap()` on an `Err` value: Serde(Error("invalid type: string \"\", expected struct UiNodeInputAttributesValue", line: 1, column: 443))

[Kratos] TypeScript Client SDK throws error in browser

When trying to import e.g. the PublicApi in a React project, it tries to include multiple server-side modules such as fs, request etc.

This causes the following error to be thrown:

Module not found: Can't resolve 'fs' in '/Users/.../app/node_modules/request/lib'
ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in '/Users/.../app/node_modules/request/lib'
    at factory.create (/Users/.../app/node_modules/webpack/lib/Compilation.js:925:10)
    at factory (/Users/.../app/node_modules/webpack/lib/NormalModuleFactory.js:401:22)
    at resolver (/Users/.../app/node_modules/webpack/lib/NormalModuleFactory.js:130:21)
    at asyncLib.parallel (/Users/.../app/node_modules/webpack/lib/NormalModuleFactory.js:224:22)
    at /Users/.../app/node_modules/neo-async/async.js:2830:7
    at /Users/.../app/node_modules/neo-async/async.js:6877:13
    at normalResolver.resolve (/Users/.../app/node_modules/webpack/lib/NormalModuleFactory.js:214:25)
    at doResolve (/Users/.../app/node_modules/enhanced-resolve/lib/Resolver.js:213:14)
    at hook.callAsync (/Users/.../app/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
    at _fn0 (eval at create (/Users/.../app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at resolver.doResolve (/Users/.../app/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7)
    at hook.callAsync (/Users/.../app/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
    at _fn0 (eval at create (/Users/.../app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at hook.callAsync (/Users/.../app/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
    at _fn0 (eval at create (/Users/.../app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at resolver.doResolve (/Users/.../app/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43)

Generated Dart Sdk is invalid

I notice, that the client, that I generated locally differs from the client in the repo:

image image

The client in the repo/published to pub.dev is invalid and cannot be used.

This is also marked on the pub score page:

image

Python empty fields raise Exception

I am migrating from the old hydra_client lib and I encounter some errors.

Consider the following example object (retrieved via hydra admin api)

root@localhost:/# curl 10.43.169.219:4445/clients/nextcloud
{
  "client_id":"nextcloud",
  "client_name":"",
  "redirect_uris":["https://example.com/apps/sociallogin/custom_oidc/oas"],
  "grant_types":["authorization_code","refresh_token","client_credentials"],
  "response_types":["code","id_token"],
  "scope":"openid profile email roles",
  "audience":null,
  "owner":"nextcloud/example",
  "policy_uri":"",
  "allowed_cors_origins":null,
  "tos_uri":"",
  "client_uri":"",
  "logo_uri":"",
  "contacts":null,
  "client_secret_expires_at":0,
  "subject_type":"public",
  "token_endpoint_auth_method":"client_secret_post",
  "userinfo_signed_response_alg":"none",
  "created_at":"0001-01-01T00:00:00Z",
  "updated_at":"2021-03-24T11:58:06Z",
  "metadata":{"client_name":"Nextcloud"
}

Now for all objects that are null the following Exception is raised:

โ”‚ single-sign-on-userbackend-api Traceback (most recent call last):                                                                                                                                                                                           โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/src/app/database/hydra.py", line 24, in _get_hydra_client                                                                                                                                                       โ”‚
โ”‚ single-sign-on-userbackend-api     return self.hydra.get_o_auth2_client(id=client_id)                                                                                                                                                                       โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/api_client.py", line 763, in __call__                                                                                                                        โ”‚
โ”‚ single-sign-on-userbackend-api     return self.callable(self, *args, **kwargs)                                                                                                                                                                              โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/api/admin_api.py", line 1911, in __get_o_auth2_client                                                                                                        โ”‚
โ”‚ single-sign-on-userbackend-api     return self.call_with_http_info(**kwargs)                                                                                                                                                                                โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/api_client.py", line 841, in call_with_http_info                                                                                                             โ”‚
โ”‚ single-sign-on-userbackend-api     collection_formats=params['collection_format'])                                                                                                                                                                          โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/api_client.py", line 411, in call_api                                                                                                                        โ”‚
โ”‚ single-sign-on-userbackend-api     _check_type)                                                                                                                                                                                                             โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/api_client.py", line 226, in __call_api                                                                                                                      โ”‚
โ”‚ single-sign-on-userbackend-api     _check_type                                                                                                                                                                                                              โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/api_client.py", line 327, in deserialize                                                                                                                     โ”‚
โ”‚ single-sign-on-userbackend-api     configuration=self.configuration                                                                                                                                                                                         โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 1402, in validate_and_convert_types                                                                                                    โ”‚
โ”‚ single-sign-on-userbackend-api     check_type=_check_type                                                                                                                                                                                                   โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 1290, in attempt_convert_item                                                                                                          โ”‚
โ”‚ single-sign-on-userbackend-api     raise conversion_exc                                                                                                                                                                                                     โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 1283, in attempt_convert_item                                                                                                          โ”‚
โ”‚ single-sign-on-userbackend-api     configuration, spec_property_naming)                                                                                                                                                                                     โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 1201, in deserialize_model                                                                                                             โ”‚
โ”‚ single-sign-on-userbackend-api     return model_class(**kw_args)                                                                                                                                                                                            โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 1563, in wrapped_init                                                                                                                  โ”‚
โ”‚ single-sign-on-userbackend-api     return fn(self, *args, **kwargs)                                                                                                                                                                                         โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model/o_auth2_client.py", line 274, in __init__                                                                                                              โ”‚
โ”‚ single-sign-on-userbackend-api     setattr(self, var_name, var_value)                                                                                                                                                                                       โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 167, in __setattr__                                                                                                                    โ”‚
โ”‚ single-sign-on-userbackend-api     self[attr] = value                                                                                                                                                                                                       โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 352, in __setitem__                                                                                                                    โ”‚
โ”‚ single-sign-on-userbackend-api     self.set_attribute(name, value)                                                                                                                                                                                          โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 141, in set_attribute                                                                                                                  โ”‚
โ”‚ single-sign-on-userbackend-api     self._check_type, configuration=self._configuration)                                                                                                                                                                     โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 1402, in validate_and_convert_types                                                                                                    โ”‚
โ”‚ single-sign-on-userbackend-api     check_type=_check_type                                                                                                                                                                                                   โ”‚
โ”‚ single-sign-on-userbackend-api   File "/usr/local/lib/python3.7/site-packages/ory_hydra_client/model_utils.py", line 1277, in attempt_convert_item                                                                                                          โ”‚
โ”‚ single-sign-on-userbackend-api     key_type=key_type)                                                                                                                                                                                                       โ”‚
โ”‚ single-sign-on-userbackend-api ory_hydra_client.exceptions.ApiTypeError: Invalid type for variable 'allowed_cors_origins'. Required value type is StringSlicePipeDelimiter and passed type was NoneType at ['received_data']['allowed_cors_origins']

This is not expected as fields like audience and allowed_cors_origins are allowed to be empty

Workaround:

Set all fields that raise this exception to: ""

However as I am using maester:

https://github.com/ory/hydra-maester/blob/master/config/samples/hydra_v1alpha1_oauth2client.yaml

I can not set the fields using the Oauth2Client CRD.

ARM support in Docker build

The current Docker container is built off of openjdk:12-alpine, which unfortunately doesn't have ARM support. Looking at the openjdk Docker Hub page, it doesn't look like any of the Alpine image tags have ARM support in general. With the new Apple M1 silicon this will cause issues if you're trying to build locally to test openapi generation.

I also noticed that in #27 the Dart SDK generation was having issues with musl in the Alpine image. Between these two issues it might make sense to move to another base image altogether.

I did some testing with the Debian openjdk:16-slim-buster container and I was able to generate libraries for Typescript just fine.

I'll put together a PR in a few for others to take a look at in case there is interest in this. One thing to note is the container size is a lot bigger.

Dart SDK

Is your feature request related to a problem? Please describe.

I'd like to implement a Flutter sample application consuming the Kratos API. In order to do that I'd rather use or contribute a Dart SDK.

Describe the solution you'd like

Why Dart? Because of Flutter, which let you build cross-platform apps from a single codebase

Deserialization issue when getting self service flow

I am getting a deserialization issue when calling getSelfServiceLoginFlow (i think any flow will have this issue though) when using both v0.6.3-alpha.1 of kratos and this java client. Previously, I was using v0.5.4-alpha.1 and everything worked fine and I was now looking to upgrade to v0.6. The payload changed of the flows changed betweem these versions so this might be the cause of the issue. I tried it both with the migrated and a clean database but it made no difference. Any ideas?

Error log:

2021-05-19 10:38:11,486 INFO  [io.alo.ser.KratosService_Subclass] (executor-thread-199) requesting getSelfServiceLoginFlow with flow id: b74da03c-86b4-4ad6-b77c-fbe57323cde4
2021-05-19 10:38:11,506 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-199) HTTP Request to /auth/login?flow=b74da03c-86b4-4ad6-b77c-fbe57323cde4 failed, error id: 6617a238-58c3-4259-b3f2-633fac1cfbd9-1: org.jboss.resteasy.spi.UnhandledException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 548 path $.ui.nodes[0].attributes.value
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:138)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:41)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:93)
        at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:231)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 548 path $.ui.nodes[0].attributes.value
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        at com.google.gson.Gson.fromJson(Gson.java:932)
        at com.google.gson.Gson.fromJson(Gson.java:897)
        at com.google.gson.Gson.fromJson(Gson.java:846)
        at sh.ory.kratos.JSON.deserialize(JSON.java:146)
        at sh.ory.kratos.ApiClient.deserialize(ApiClient.java:812)
        at sh.ory.kratos.ApiClient.handleResponse(ApiClient.java:1018)
        at sh.ory.kratos.ApiClient.execute(ApiClient.java:942)
        at sh.ory.kratos.api.AdminApi.getSelfServiceLoginFlowWithHttpInfo(AdminApi.java:895)
        at sh.ory.kratos.api.AdminApi.getSelfServiceLoginFlow(AdminApi.java:872)
        at io.aloxy.services.KratosService.getLoginFlow(KratosService.java:50)
        at io.aloxy.services.KratosService_Subclass.getLoginFlow$$superaccessor3(KratosService_Subclass.zig:527)
        at io.aloxy.services.KratosService_Subclass$$function$$8.apply(KratosService_Subclass$$function$$8.zig:33)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:63)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
        at io.aloxy.services.KratosService_Subclass.getLoginFlow(KratosService_Subclass.zig:484)
        at io.aloxy.services.KratosService_ClientProxy.getLoginFlow(KratosService_ClientProxy.zig:128)
        at io.aloxy.resources.KratosResource.browser(KratosResource.java:44)
        at io.aloxy.resources.KratosResource_Subclass.browser$$superaccessor2(KratosResource_Subclass.zig:378)
        at io.aloxy.resources.KratosResource_Subclass$$function$$4.apply(KratosResource_Subclass$$function$$4.zig:33)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:63)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
        at io.aloxy.resources.KratosResource_Subclass.browser(KratosResource_Subclass.zig:317)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
        ... 18 more
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 548 path $.ui.nodes[0].attributes.value
        at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:386)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
        ... 76 more

0.6.0+ JsonSyntaxException

First of all, thanks for Ory Kratos.
Currently experimenting with it, and so far it's great, can't wait for more features (like MFA!).

I've been trying out the latest generated clients from Maven, however when running apiInstance.initializeSelfServiceLoginViaAPIFlow I get a JsonSyntaxException.
I haven't tried all endpoints, other than version and health check from the admin api (which work fine).

I've just been using the example given here.

I've tried with 0.5.4-alpha.1 and it works as expected, however on 0.6.1-alpha.1/0.6.0-alpha.17/0.6.0-alpha.13 it does not (haven't tested more versions).

Error:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 443 path $.ui.nodes[0].attributes.value
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at com.google.gson.Gson.fromJson(Gson.java:897)
	at com.google.gson.Gson.fromJson(Gson.java:846)
	at sh.ory.kratos.JSON.deserialize(JSON.java:146)
	at sh.ory.kratos.ApiClient.deserialize(ApiClient.java:797)
	at sh.ory.kratos.ApiClient.handleResponse(ApiClient.java:1003)
	at sh.ory.kratos.ApiClient.execute(ApiClient.java:927)
	at sh.ory.kratos.api.PublicApi.initializeSelfServiceLoginViaAPIFlowWithHttpInfo(PublicApi.java:1161)
	at sh.ory.kratos.api.PublicApi.initializeSelfServiceLoginViaAPIFlow(PublicApi.java:1140)
...
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 443 path $.ui.nodes[0].attributes.value
	at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:386)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
	... 40 more

Not super duper concerned, it's still alpha after all and I'm still going to experiment with Kratos, but would definitely be nice to have this fixed ๐Ÿ˜„
Worst case scenario I'll implement my own api client.

Thanks!

CI is currently failing

CI job "publish" is currently failing:

failed rendering template data for definition: template execution failed for template definition: template: schematype:20:18: executing "typeSchemaType" at <(len .AllOf) gt 0>: can't give argument to non-function len .AllOf

This causes for example the Kratos PyPI project to not get updated which means that if you have installed ory-kratos-client as a dependency through there then you can't currently use the latest version of Kratos.

Exception when using Python SDK for Kratos verification

Describe the bug

This is very similar to #10. An exception is thrown because Kratos sets the verified_at-field to null which causes an exception to be thrown in the Python SDK.

Reproducing the bug

This happens when using the Python SDK and calling the function api_instance.list_identities(). If a user is unverified then the verified_at-field is null and the exception is thrown.

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1703, in _execute
    result = await result
  File "/app/app/web/handlers/admin/members.py", line 24, in get
    members = api_instance.list_identities()
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api/admin_api.py", line 925, in list_identities
    return self.list_identities_with_http_info(**kwargs)  # noqa: E501
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api/admin_api.py", line 987, in list_identities_with_http_info
     return self.api_client.call_api(
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 348, in call_api
    return self.__call_api(resource_path, method,
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 192, in __call_api
    return_data = self.deserialize(response_data, response_type)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 264, in deserialize
    return self.__deserialize(data, response_type)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 280, in __deserialize
    return [self.__deserialize(sub_data, sub_kls)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 280, in <listcomp>
    return [self.__deserialize(sub_data, sub_kls)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 303, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 639, in __deserialize_model
    kwargs[attr] = self.__deserialize(value, attr_type)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 280, in __deserialize
    return [self.__deserialize(sub_data, sub_kls)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 280, in <listcomp>
    return [self.__deserialize(sub_data, sub_kls)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 303, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 641, in __deserialize_model
    instance = klass(**kwargs)
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/models/verifiable_address.py", line 71, in __init__
    self.verified_at = verified_at
  File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/models/verifiable_address.py", line 185, in verified_at
    raise ValueError("Invalid value for `verified_at`, must not be `None`")  # noqa: E501
ValueError: Invalid value for `verified_at`, must not be `None`

Expected behavior

The SDK should be able to handle the value being null.

Exception when using Python SDK for Kratos registration

Kratos version: v0.1.1-alpha.1
Oathkeeper version: v0.37.1-beta.1
SDK version: 0.1.1a1

When calling:
api_response = api_instance.get_self_service_browser_registration_request(request)
I get the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1701, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/app/app/web/handlers/authentication.py", line 62, in get
api_response = api_instance.get_self_service_browser_registration_request(request)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api/public_api.py", line 514, in get_self_service_browser_registration_request
return self.get_self_service_browser_registration_request_with_http_info(request, **kwargs)  # noqa: E501
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api/public_api.py", line 583, in get_self_service_browser_registration_request_with_http_info
return self.api_client.call_api(
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 348, in call_api
return self.__call_api(resource_path, method,
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 192, in __call_api
return_data = self.deserialize(response_data, response_type)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 264, in deserialize
return self.__deserialize(data, response_type)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 303, in __deserialize
return self.__deserialize_model(data, klass)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 639, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 285, in __deserialize
return {k: self.__deserialize(v, sub_kls)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 285, in <dictcomp>
return {k: self.__deserialize(v, sub_kls)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 303, in __deserialize
return self.__deserialize_model(data, klass)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 639, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 303, in __deserialize
return self.__deserialize_model(data, klass)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 639, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 280, in __deserialize
return [self.__deserialize(sub_data, sub_kls)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 280, in <listcomp>
return [self.__deserialize(sub_data, sub_kls)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 303, in __deserialize
return self.__deserialize_model(data, klass)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/api_client.py", line 641, in __deserialize_model
instance = klass(**kwargs)
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/models/form_field.py", line 77, in __init__
self.required = required
File "/usr/local/lib/python3.8/site-packages/ory_kratos_client/models/form_field.py", line 197, in required
raise ValueError("Invalid value for `required`, must not be `None`")  # noqa: E501
ValueError: Invalid value for `required`, must not be `None`

My identity.traits.schema.json for Kratos:

{
  "$id": "https://example.org/registration.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Member",
  "type": "object",
  "properties": {
    "email": {
      "type": "string",
      "format": "email",
      "title": "E-Mail",
      "minLength": 3,
      "ory.sh/kratos": {
        "credentials": {
          "password": {
            "identifier": true
          }
        },
        "verification": {
          "via": "email"
        }
      }
    }
  },
  "required": [
    "email"
  ],
  "additionalProperties": false
}

I don't have any problems with the login flow, only when calling the registration flow.

Admin API createOAuth2Client not working correctly

It seems that in the latest Typescript version (v1.9.0-alpha.2) and v1.8.5 the Admin API's createOAuth2Client method is not creating the client correctly with the provided parameters. It's like the OAuth2Client body object is not being used.

I feel that this line in sdk/api.ts could be the problem:
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");

since the body has field names like "clientId" but the REST API expects names like "client_id".

Previously it was using a customer serializer in v1.7.0;
body: models_1.ObjectSerializer.serialize(body, "OAuth2Client")

To Reproduce

  1. Call the createOauth2Client method of AdminApi

kratos-client (typescript): Deprecated axios dependency => Severe Vulnerability Issues with current npm package

Please release an updated npm package that is not depending on a deprecated axios version.

(Almost) min. repo with angular installed: https://github.com/TMInnovations/kratos-client-vulnerabilities . Simply try to run npm install --save @ory/kratos-client and see the 2 high severity vulnerabilities.

The info block mentions npm WARN deprecated [email protected]: Critical security vulnerability fixed in v0.21.1..

Thank you and
all the best!
Thomas

How to pass cookies to Kratos API client? (Python)

I have a Python Flask application in which I use this code successfully in order to verify the user's identity:

import requests
from flask import request

headers = {
    'Accept': 'application/json'
}

r = requests.get(
    'http://kratos:4433/sessions/whoami',
    params={},
    headers=headers,
    cookies=request.cookies)
print r.json()

However, when I try to use the SDK like so:

configuration = ory_kratos_client.Configuration(
    host = "http://kratos:4433" # public endpoint
)
 
with ory_kratos_client.ApiClient(configuration=configuration) as api_client:
    api_instance = ory_kratos_client.PublicApi(api_client)
    try:
        api_response = api_instance.whoami()
    except ApiException as e:
        print("Exception when calling PublicApi->whoami: %s\n" % e)

I get the following error message:

Exception when calling PublicApi->whoami: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Set-Cookie': 'csrf_token=KV1kaiDHZyGxa/ejEjzPv4GxgHPYqcZBr0+Z/7n6mi4=; Path=/.ory/kratos/public/; Domain=161.35.206.172; Max-Age=31536000; HttpOnly', 'Vary': 'Cookie', 'Date': 'Wed, 02 Sep 2020 12:14:09 GMT', 'Content-Length': '137'})
HTTP response body: {"error":{"code":401,"status":"Unauthorized","reason":"No valid session cookie found.","message":"The request could not be authorized"}}

I couldn't find in the repository whether there is a way to explicitly pass the cookies to the API client. Help would be appreciated.

Update Python to client version 0.5.5a2 breaks import

Hey everyone,
I updated from the sdk client version 0.5.4a1 to 0.5.5a2 and the new __init__.py seems to be missing a lot of import statements. A reproducible example that worked in 0.5.4a1 but not in 0.5.5a2:

import ory_kratos_client

def create_kratos_identity(email: str: int, kratos_admin_url: str):
    traits = {"email": email}

    configuration = ory_kratos_client.Configuration(host=f"http://{kratos_admin_url}")
    api_client = ory_kratos_client.ApiClient(configuration=configuration)
    admin_api = ory_kratos_client.AdminApi(api_client=api_client)
    parameters = ory_kratos_client.CreateIdentity(schema_id="default", traits=traits)
    created_identity: ory_kratos_client.Identity = admin_api.create_identity(
        body=parameters
    )

    return created_identity.id

create_kratos_identity("[email protected]", os.environ["KRATOS_ADMIN_URL"])

Is this to be expected or a bug? ๐Ÿ™‚
Thank you in advance for every input ๐Ÿ™‚

Kratos Go Client is not importable

import "github.com/ory/kratos-client-go"

Fails because declared name is wrong in generated go.mod:

go: github.com/ory/[email protected]: parsing go.mod:
	module declares its path as: github.com/ory/sdk
	        but was required as: github.com/ory/kratos-client-go

upstream reference closed: github.com/square/okhttp/issues/350

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.