kiota: [Plugin generation] Kiota should warn users when api contains unsupported auth flows

What are you generating using Kiota, clients or plugins?

Kiota plugin

In what context or format are you using Kiota?

Windows executable

Client library/SDK language

None

Describe the bug

Copilot not support OAuth with implicit flow, currently it only support OAuth with authcode flow. Kiota should warn if user selected API contains unsupported auth flow like OAuth with implicit flow.

components:
  securitySchemes:
    oAuth2AuthImplicit:  
      type: oauth2
      description: This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth)
      flows:
        implicit:   # <---- OAuth flow(authorizationCode, implicit, password or clientCredentials)
          authorizationUrl: https://api.example.com/oauth2/authorize
          scopes:
            read_pets: read your pets
            write_pets: modify pets in your account

Sample schema: https://raw.githubusercontent.com/SLdragon/example-openapi-spec/main/oauth-implicit.yaml

Related bug: https://github.com/microsoft/kiota/issues/5288 https://github.com/microsoft/kiota/issues/5070 https://github.com/microsoft/kiota/issues/5162

Expected behavior

Kiota should generate API Plugins and neither warn nor error when the OpenAPI description has no security definition. Kiota should generate API Plugins and warn users when the specified auth flow is different from OAuth code flow and HTTP bearer token (current supported auth). Kiota should generate API Plugins and warn users when there is a combination of two auth methods for an endpoint (AND scenario, e.g., API Key + OAuth for calling a #GET operation)."

How to reproduce

Open sample schema: https://raw.githubusercontent.com/SLdragon/example-openapi-spec/main/oauth-implicit.yaml -> click generate plugin

Open API description file

No response

Kiota Version

v1.18.100000002

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

Click to expand log ``` <log output here>
</details>


### Other information

_No response_

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (16 by maintainers)

Most upvoted comments

We absolutely should log the warning so the user can filter and look at them. I like to idea of having the “Authentication warning”. Not sure about the “Using anonymous auth” for each endpoint though. We would be repeating that every endpoint with unsupported auth.

@thewahome could we do a single warn with the message: “Incompatible security schemes for Copilot usage detected in the selected endpoints.” and maybe add a button “Logs” where the user can click to load the filtered log?

@maisarissi is the set of warnings also expected when using the CLI?

Implicit OAuth2 flow is not supported by Copilot. However, just because an OpenAPI does not say the API supports OAuth2 AuthCode does not mean the API doesn’t support it. We should not fail to generate a Plugin because of this.

There are many OpenAPI descriptions that do not describe the security capabilities of an API. In fact only 25% of OpenAPI descriptions contain security information. Security information is often conveyed out-of-band.