Skip to content
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

Code generated using feathers cli, unable to use swagger with authentication #107

Closed
1 of 2 tasks
HarisHashim opened this issue May 28, 2018 · 3 comments
Closed
1 of 2 tasks

Comments

@HarisHashim
Copy link

HarisHashim commented May 28, 2018

## Steps to reproduce

  • Tell us what broke. The more detailed the better.

I have tried to troubleshoot this as per issue #36 . But so far never got it working.

I have feathers-swagger working up to displaying Swagger UI and using it to execute get and post for services that does not require authentication.

However after enabling authentication, I got error as per bellow screenshot:

error
The reply at the end of Issue #35 might have similar problem.

Bellow code is in messages.services.js

const messages = createService(options);
  messages.docs = {
    description: "A service to send and receive chat messages",
    definitions: {
      messages: {
        type: "object",
        required: ["text"],
        properties: {
          text: {
            type: "string",
            description: "The message text"
          },
          userId: {
            type: "string",
            description: "The id of the user that send the message"
          }
        }
      }
    }
  };

  app.use("/messages", messages);

And this one in app.js

//Swagger
app.configure(
  swagger({
    docsPath: "/docs",
    uiIndex: true,
    info: {
      title: "Feathers Chat Backend",
      description: "Feathers chat backend!"
    },
   securityDefinitions: {
      bearer: {
        type: "apiKey",
        name: "authorization",
        in: "header"
      }
    },
    security: [
      {
        bearer: []
      }
    ]
  })
);
  • If you can, please create a simple example that reproduces the issue and link to a gist, jsbin, repo, etc.

I have created example to demonstrate this issue using feathers-chat repo

Github - feathers-chat-swagger

Expected behavior

As per #36 I did see bellow screen. So something work. But expected get and post for authenticated service to work.

image

@HarisHashim
Copy link
Author

@daffl & @ideally , appreciate your help.

I have tried

securityDefinitions: {
      bearer: {
        type: "apiKey",
        name: "authorization",
        in: "header"
      }
    },
    security: [
      {
        bearer: []
      }
    ]

and


    security: {
      name: "jwt",
      type: "apiKey",
      in: "header"
    },
    securityDefinitions: {
      jwt: {
        type: "apiKey",
        name: "Authorization",
        in: "header"
      }
    }

Does it have something to do with authentication method using local authentication strategy? Or wrong securityDefinitions? Or something change in latest swagger library that I have to specify swagger 2.0?

@HarisHashim
Copy link
Author

HarisHashim commented Sep 24, 2018

Wow! Can't imagine I wrote all those. Must be a bad case of alien possession.

Or perhaps it is time to retrace the step and remember what the hell this is about!

Note to future self. As per the final reply to #35 . @ivanmarjanovic might have solve this. So future self please try the fork at https://github.com/ivanmarjanovic/feathers-swagger

@Mairu
Copy link
Collaborator

Mairu commented May 24, 2019

Authentication has to be configured and should work when done correctly with version 1.0.0. See also the examples folder for help.

@Mairu Mairu closed this as completed May 24, 2019
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

No branches or pull requests

2 participants