RapiDoc icon indicating copy to clipboard operation
RapiDoc copied to clipboard

Relative url for the security schemes

Open buhtr opened this issue 4 years ago • 3 comments

Try to use RapiDoc in a new project and see some strange behavior when working with relative urls.

Consider this openapi spec

servers:
  - url: https://api.example.com/v2
components:
  securitySchemes:
    openId:
      type: openIdConnect
      openIdConnectUrl: /.well-known/openid-configuration

According to https://swagger.io/docs/specification/authentication/openid-connect-discovery section "Relative Discovery URL".

Relative URLs are resolved according to RFC 3986. In the example above, it will be resolved to https://api.example.com/.well-known/openid-configuration.

Swagger-ui in the authorization section uses this rule. RapiDoc takes full server url and resolves openIdConnectUrl as https://api.example.com/v2/.well-known/openid-configuration.

Is this intended behavior or bug ?

buhtr avatar Oct 05 '21 07:10 buhtr

thank you for testing it out. We havent yet tested OpenID security schemes that well. Is this only the issue you are facing ? else please list down all others. I will use this ticket to create our tasks to provide a better support for OpenID security scheme

mrin9 avatar Oct 07 '21 02:10 mrin9

I also see this issue with "Authorization Code flow".

components:
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: ...
          tokenUrl: ...
          refreshUrl: ...

Probably there is a generic algorithm of building a url for a security schema which has an error.

buhtr avatar Oct 07 '21 13:10 buhtr

@buhtr - does the OpenID Connect even render something for you? I am using a full url as my OpenID Connect server is somewhere else - but it just shows the following for me: image

ThaDaVos avatar Aug 16 '22 13:08 ThaDaVos

I've also seen this issue with clientCredentials flow as well.

serverUrl="http://localhost:8080/api/v1" causes my tokenUrl to render as "http://localhost:8080/api/v1/token" instead of "http://localhost:8080/token".

jak103 avatar Dec 13 '22 05:12 jak103

From https://swagger.io/docs/specification/authentication/oauth2/

Screen Shot 2022-12-13 at 12 08 17 PM

My PR fixes this issue so RapiDoc is compliant with the spec.

Showing the fix works. Screen Shot 2022-12-13 at 4 42 01 PM

jak103 avatar Dec 13 '22 19:12 jak103