Support for basic auth
Closed this issue · 2 comments
Counterfact doesn't currently read the security object of the OpenAPI schema.
When generating types, it should take that object into account.
For example, if the security object is defined as:
{
"type": "http",
"scheme": "basic"
}
Then Counterfact should read the username and add it to a $.user
object.
Note: this only covers "http" authentication. OpenAPI also "apiKey", "mutualTLS", "oauth2", "openIdConnect". Eventually we'll want to support "apiKey" and "oauth2" as well. I'm not sure the others worth pursuing.
In the server, I think we need to look for either an Authorization
header or a username / password in the URL, and parse out the username and password in a $.user
object.
In the typescript generator, we need to include the $.user
object if OpenAPI has a security object with type "http".
Should be working in 0.39
From this point, supporting other auth methods like API key should be pretty straightforward.