Skip to content

Generated OpenAPI spec lacks 'securityDefinitions' key #14268

Closed

Description

@caseyfw

The generated OpenAPI spec is missing the securityDefinitions section that defines which security mechanisms the API supports (e.g. OAuth, HTTP Basic, etc).

This means clients generated from it using tools like Swagger Codegen lack security context and only work with endpoints that do not require auth.

Version

Current master branch.

Steps To Reproduce
curl -s https://raw.githubusercontent.com/openshift/origin/master/api/swagger-spec/openshift-openapi-spec.json | grep securityDefinitions
Current Result

No output.

Expected Result
  "securityDefinitions": {
Additional Information

As a concrete example, here is an OpenShift PHP client generated using the 2.3.0 branch of Swagger Codegen from the current OpenShift API spec in master branch. The PHP codegen templates (correctly) only output auth code if the authMethods item is set, which is derived from the securityDefinitions key in the spec.

The example API spec provided by Swagger shows a correctly configured securityDefinitions item.

Activity

  1. added
    kind/bug
    on May 22, 2017
  2. assigned and unassigned on May 30, 2017
  3. enj commented on May 30, 2017

    @enj
    Contributor

    @liggitt I think the cleanest change would be to update DefaultOpenAPIConfig to extract info from masterConfig to build the SecurityDefinitions. I believe we would want (assuming OpenAPI supports all of these):

    1. OAuth
    2. Bearer Token (web sockets?)
    3. x509

    WDYT?

  4. self-assigned this
    on Jun 16, 2017
  5. simo5 commented on Jun 16, 2017

    @simo5

    Looking at existing securityDefitions examples in the code, it looks like Oauth is considered a Bearertoken and rthere is no differentiation between that ans ServiceAccount tokens ...
    Also I could not find any example of x509 auth defintions ...

  6. enj commented on Jun 17, 2017

    @enj
    Contributor

    @simo5 does swagger differentiate between random noise tokens and JWTs? I believe they use the same header. I would assume you need to look at the swagger specification to determine how to represent tokens, certs, etc.

  7. simo5 commented on Jun 19, 2017

    @simo5

    Swagger (and code in origin) does not differentiate between JWT and other Bearer tokens.
    I couldn't find any example of swagger representing a x509 authentication, so I am kinda blocked on that one.
    I will open a WIP PR in a moment to start reasoning on this with some code at hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

component/restapikind/bugpriority/P2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions