question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bearer / JWT security definitions is not working

See original GitHub issue

Hi, we just testing new version of swagger-ui, the new functions is badly documented so we reverse engineered needed configuration values from source code, but maybe our assumptions were bad.

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version?
Which Swagger-UI version? latest from master
How did you install Swagger-UI? grom git
Which browser & version? Chrome latest
Which operating system? Mac OS X

Demonstration API definition

 securityDefinitions:
   bearerAuth:
     type: http
     scheme: bearer
     bearerFormat: JWT

Expected Behavior

Bearer auth should be visible in Authorize section

Current Behavior

Unknown security definition type http in this window

Possible Solution

Add some section to https://github.com/swagger-api/swagger-ui/blob/master/src/core/components/auth/auth-item.jsx to ensure

Context

We wanted to use swagger-ui for swagger api using JWT.

Thanks a lot for your help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
shockeycommented, Nov 3, 2017

@jakubjosef, that should work if you change bearerAuth:[] to - bearerAuth: [], since security requirements under security need to be arrays.

Here’s a minimal example of a definition that will use bearer auth globally:

openapi: "3.0.0"
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
security:
- bearerAuth: []
paths:
  /:
    get:
      description: my operation
      responses: 
        200:
          description: all is well
2reactions
LukeWReagancommented, Jun 27, 2019

Can anyone tell me why my Available Authorizations box is empty in my swagger ui with this code. Screen Shot 2019-06-26 at 5 14 59 PM

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jwt authentication implement in swagger api? - Stack Overflow
According to the Swagger documentation about Bearer authentication, you should use the following configuration: securityDefinitions: ...
Read more >
Troubleshooting issues with HTTP API JWT authorizers
The following provides troubleshooting advice for errors and issues that you might encounter when using JSON Web Token (JWT) authorizers with HTTP APIs....
Read more >
Bearer Authentication - Swagger
In OpenAPI 3.0, Bearer authentication is a security scheme with type: http and scheme: bearer . You first need to define the security...
Read more >
JSON Web Token Introduction - jwt.io
Since tokens are credentials, great care must be taken to prevent security issues. In general, you should not keep tokens longer than required....
Read more >
OAuth2 with Password (and hashing), Bearer with JWT tokens
After a week, the token will be expired and the user will not be authorized and will have to sign in again to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found