Contributions
Is there a seamless way to use JWT (JSON web tokens) to authenticate a user in SwaggerHub?
Currently, the workflow to authenticate a user is as follows: 1. Manually edit example JSON in the /login endpoint. 2. Copy the response header string and add as a header variable to the endpoints that need authentication. It would be optimal to build an authentication type of 'JWT' - where the user could log in byjust typing theirusername/password into text fields and clicking 'authenticate'. This JWT modification has been done by the Swagger community and is a relatively straightforward modification to swagger-ui. Is this anywhere on the SwaggerHub roadmap? Thanks3.3KViews0likes1CommentRe: Can I use my existing session cookie authentication for my API when testing on swaggerhub?
FWIW I installed Swagger UI on my machine, and the API works as expected when I load the UI as a file://... When i load as "http://localhost:8080..." it does not work. Separately, we rolled out our API with an API key, so I am going to pursue this path instead.10KViews0likes0CommentsRe: Can I use my existing session cookie authentication for my API when testing on swaggerhub?
The auth cookies are set after successful authentication from the UI of our app on (for example) www.mydashboard.com. The cookie domain is for *.mydashboard.com. Therefore, my workflow would be as follows: 1. Log into www.mydashboard.com. Auth cookies will be set in the browser. 2. Open a new tab and go to swaggerhub.com, and navigate to my API. 3. "Try it out" and allow swaggerhub.com to make an XHR request to api.mydashboard.com. The expected behavior is that cookies are sent for this request. They are not being sent because the "withCredentials = true" flag is not being set from the instance of Swagger being hosted at SwaggerHub. More information is here: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials What I am asking for is the ability to instruct the version of swagger on swaggerhub to modify their XHR request to pass with credentials = true. Perhaps this should be part of the spec?10KViews0likes2CommentsRe: Can I use my existing session cookie authentication for my API when testing on swaggerhub?
Here are some details: We have a relatively simple Rails application that powers an analytics dashboard. In order to log into the application, a user goes through a login process, and a session cookie is set for this user. When the user requests a dashboard screen, the API is called to get time series data about a given object. This session cookie is passed, and a JSON result is returned. Here is an example of a working script (with the session cookie values modified): curl 'https://app.authenticated.digital/analytics/custom?fields=platform%2Cexchange%2Ctotal&sorts=-total&limit=50&page=1&granularity=all&start_date=2016-06-14&end_date=2016-06-15' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Accept: application/json' -H 'Referer: https://app.authenticated.digital/analysis/all/authentic_dsp/' -H 'Cookie: remember_user_token=fjsdlkfjsdlkfjsdlkfjsldkfjsldkfj--dlsdjflsdifjlsdkfjdslkfjsdlf; _admin_session=flkjsdflksdjflksdjflksdjflksdjfldksfjsldkfj--dfkjsdlfkjdsflksdjflksdjfd' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' --compressed When SwaggerHubuses XHR to pass in the request, the cookies are not passed, so I receive a 401 not authorized error. I have read in the forums that there may bethe ability to pass cookies (e.g. with-credentials: true) by passing in "enableCookies: true" in the Swagger definition file. This does not seem to work. I'd like to be able to set a flag somewhere in the Swagger definition file to instruct XHR to pass cookies with the JSON request. Thanks! P.S. I know that using cookie based authentication is not the preferred method of auth, but one FANTASTIC application of Swagger is to document existing API that may have been written in this way - and I would imagine that a large percentage of API's implement authentication this way. Two popular examples are JIRA and Wordpress.10KViews0likes4CommentsCan I use my existing session cookie authentication for my API when testing on swaggerhub?
When I send API requests from SwaggerHub to my API, it seems like the cookie that gets set when I log into my app is not sent. I tried setting "enableCookies: true" in my swagger.yaml API definition - no luck. What is the best way to do this? FWIW my API spec is here: https://swaggerhub.com/api/switzer/authenticated-digital-analytics-api/1.0.010KViews0likes6Comments