I am having difficulty with my securityDefinitions object.

My folder structure is like this:

/api
/console
  /swagger
    /file1.json
    /file2.json
  /swagger-ui

We are not yet ready to make the console (or associated swagger files) 
available to the whole internet, so everything under /console is protected 
using Basic Authentication. 

Most of the API calls require apiKey authorization.

If I just put the apiKey authorization in the securityDefinitions and then 
authorize via the Authorize button, and the json files are refreshed for 
any reason (such as changing from file1.json to file2.json) my browser 
displays an HTTP Basic Authentication dialog box, and no matter what values 
I enter, the dialog box just refreshes.

If I put both the apiKey authorization and basic authorization in the 
securityDefinitions, then I can refresh the json files without any problems 
as long as I authorize with both the apiKey and basic, but all calls to the 
API seem to use just basic authentication and ignore the apiKey 
authorization.

This is what my securityDefinitions object looks like:

  "securityDefinitions": {
    "Basic": {
      "type": "basic",
      "description": "You must enter your username and password"
    },
    "Authorization": {
      "type": "apiKey",
      "name": "Authorization",
      "in": "header",
      "description": "Fill out as described in the documentation"
    }
  }

And this is an example of the curl that the console generates for me when 
authorised with both basic and apiKey:

curl -X GET --header 'Accept: application/json' --header 'Authorization: 
Basic xxxxxxxxxxxxxxxxxxxxxx' 'http://example.com/api/call'

What I want to get is

curl -X GET --header 'Accept: application/json' --header 'Authorization: 
apiKey_value' 'http://example.com/api/call'

Is there an easy solution to this problem? I'm inclined to think I should 
remove the Basic authentication and restrict access based on IP address.

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to