Skip to content

Authorization: config or default to Bearer token approach #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
simranbentel opened this issue Nov 29, 2021 · 12 comments · Fixed by #74
Closed

Authorization: config or default to Bearer token approach #67

simranbentel opened this issue Nov 29, 2021 · 12 comments · Fixed by #74
Assignees

Comments

@simranbentel
Copy link

Is there any way for the Authorization UI to default to the Bearer token input? Users of my site will need to figure out switching the user/pass inputs to Bearer token. I tried use CSS to alter the presentation but the React logic is not allowing that approach.

@bourdakos1
Copy link
Member

I think this might be a bug. The intended behavior is that you would only have to toggle between auth modes that are specified in the OpenAPI definition (in the order that they are listed), but I think the component incorrectly always shows both basic and bearer auth modes when any auth modes are listed.

I am unable to make any contributions at the moment, but I believe @avaidyam added the basic auth support, so he might be able to help resolve this.

I am also happy to get a PR merged if you want to attempt to fix this. The relevant code can be found here:
https://github.com/cloud-annotations/docusaurus-plugin-openapi/blob/main/packages/docusaurus-theme-openapi/src/theme/ApiDemoPanel/Authorization/index.js

@avaidyam
Copy link
Contributor

@simranbentel Right, as @bourdakos1 says, it's supposed to work off of the different auth types present in the OpenAPI specification. I recall hardcoding support for basic auth in addition to the previously present Bearer auth. This may take some extra work to implement properly, I think.

@simranbentel
Copy link
Author

@simranbentel Right, as @bourdakos1 says, it's supposed to work off of the different auth types present in the OpenAPI specification. I recall hardcoding support for basic auth in addition to the previously present Bearer auth. This may take some extra work to implement properly, I think.

Thanks @avaidyam. Looking at the Authorization component I see a clear path to getting the Bearer auth to show by default and hiding the switch button. I will make a fork with those changes for the time being. Will check back to see when you get this fully implemented based on the security scheme. Cheers!

@bourdakos1 bourdakos1 self-assigned this Dec 5, 2021
@bourdakos1
Copy link
Member

I should be able to work on this now

@bourdakos1
Copy link
Member

@simranbentel This should be available in the next release

@simranbentel
Copy link
Author

@bourdakos1 I have installed v0.2.2 and integrated via preset. The Authorization panel contains only a "Save" button for me. No input is being rendered.

In my swagger json components contains:
"securitySchemes": { "Bearer": { "type": "http", "description": "Put your **API key** (JWT or Reference token) on textbox below (without 'Bearer ' prefix)", "scheme": "Bearer", "bearerFormat": "JWT or Reference token" } }

and each endpoint method contains:
"security": [ { "Bearer": [ "sample.endpoint.id" ] } ]

Expected: Bearer input should display as in v0.1 of the package.
Actual: No input is displayed.

Is this still being worked on?

@bourdakos1
Copy link
Member

@simranbentel it expects scheme to be bearer (all lowercase). I'm not super well versed in how these security schemes are intended to work, should scheme not be case sensitive?

@simranbentel
Copy link
Author

simranbentel commented Dec 8, 2021

@simranbentel it expects scheme to be bearer (all lowercase). I'm not super well versed in how these security schemes are intended to work, should scheme not be case sensitive?

My backend dev says the case is standard for swagger. I think you should be looking for initial case "Bearer". But you could also add .toLowerCase() to make it work with either if you can make that change on your side..

@bourdakos1
Copy link
Member

Yea, I can do that :) Do you mind opening a separate issue for this?

@bourdakos1
Copy link
Member

Looks like scheme is intended to be case insensitive OAI/OpenAPI-Specification#1876

@bourdakos1
Copy link
Member

@simranbentel Bearer should now work in v0.2.3

@simranbentel
Copy link
Author

@bourdakos1 Confirmed, it is working now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants