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

Hapi - authentication is not working. #109

Closed
fenrirx22 opened this issue Jul 23, 2020 · 3 comments
Closed

Hapi - authentication is not working. #109

fenrirx22 opened this issue Jul 23, 2020 · 3 comments
Assignees
Labels

Comments

@fenrirx22
Copy link

Couldn't find out any issue with this. I'm trying to hide my swagger-stats behind the authentication. Everything works except the authentication. I've set the authentication param to true and provide the handler for the callback and nothing happens. I'm out of the ideas.
I'm using hapi-swagger 13.0.2, "swagger-stats": "^0.95.17".

return server.register({
    plugin: swStats.getHapiPlugin,
    options: {
      name: "Testing metrics",
      version: "1.0",
      authentication: true,
      onAuthenticate: (req, username, password) => {
        console.log("auth!");
        return (
          username === config.METRICS_USERNAME &&
          password === config.METRICS_PASS
        );
      }
    }
  });
@sv2 sv2 self-assigned this Jul 23, 2020
@sv2 sv2 added the bug label Jul 23, 2020
@fenrirx22
Copy link
Author

fenrirx22 commented Jul 24, 2020

I've done a little investigation. Seems like in the swsHapi.js file, routes are added for stats/metrics/ui/ux but the handler are using just processor functions to obtain those. The whole auth callback is called on swsInterface.js functions (processGetStats and so on) that wraps up the processor ones.

@fenrirx22
Copy link
Author

I've created a PR to fix this. #110

Btw, there are some tests on master that are not working ( supertest with elasticsearch - 500_elastic.js ). I didn't repair them because the test settings are pretty hard to understand, would take too much time and honestly I do not agree with this kind of setup (like one test depend on the execution of the previous one ).

@sv2 sv2 closed this as completed Apr 3, 2021
@sv2
Copy link
Collaborator

sv2 commented Apr 3, 2021

Addressed v0.99.1

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

No branches or pull requests

2 participants