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

Authentication to see documentation #1032

Open
Sparviero-Sughero opened this issue May 17, 2024 · 2 comments
Open

Authentication to see documentation #1032

Sparviero-Sughero opened this issue May 17, 2024 · 2 comments
Assignees

Comments

@Sparviero-Sughero
Copy link

Sparviero-Sughero commented May 17, 2024

I think there is some problems when you need to share API documentation using auth.
I'm using

$config = new Config([
  'username' => 'aaa',
  'password' => 'bbb',
  'database' => 'ccc',
  'tables' => 'products',
  'openApiBase' => json_encode(array(
    "info" => array(
      "title" => "Title",
      "version" => "1.0.0",
    ),
    "components" => array(
      "securitySchemes" => array(
        "ApiKeyAuth" => array(
          "type" => "apiKey", 
          "in" => "header",
          "name" => "X-API-Key",
        )
      )
    )
  )),
  // auth 
  'apiKeyAuth.mode'=> 'required',
  'middlewares' => 'cors,apiKeyAuth',
  'apiKeyAuth.keys' => 'Vp7LxyEpfwYjSVm',
]);

In https://petstore.swagger.io/?url=https://<your domain>/api.php/openapi there is no way to pass the auth-key.
I think you should define in json the option to enable auth also in swagger (or similar).

@mevdschee
Copy link
Owner

mevdschee commented May 17, 2024

there is no way to pass the auth-key.

I know

I think you should define in json the option to enable auth also in swagger (or similar).

I'm not sure I properly understand what it is you are proposing. Can you try to clarify this for me?

Probably, what change do you think would be needed in the openapi to support authenticating using the api key?

I'm looking forward to your suggestion for improvement.

@mevdschee mevdschee self-assigned this May 17, 2024
@Sparviero-Sughero
Copy link
Author

Hi mevdschee (tnx for your amazing job).
With the code

    "components" => array(
      "securitySchemes" => array(
        "ApiKeyAuth" => array(
          "type" => "apiKey", 
          "in" => "header",
          "name" => "X-API-Key",
        )
      )

swagger show the Authorize button.
Then:

  1. click on Authorize button
  2. insert the apiKey
  3. click to "Try it out"
  4. click to "Execute"
    Swagger show "Loading" message and the API doesn't work.
    I don't know why :o(
    Maybe there is some options you need to add to json to enable auth on swagger?

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

No branches or pull requests

2 participants