Skip to content

Commit 344c198

Browse files
authored
Merge pull request #32 from JaredCE/correctly-deal-with-authentication
Correctly deal with authentication
2 parents 52ce8d0 + ea13435 commit 344c198

27 files changed

+2927
-32
lines changed

README.md

Lines changed: 106 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Obviously, if you have a lot of secret variables that need adding as inputs, the
6565

6666
## OpenAPI Servers
6767

68-
OpenAPI Documents allow you to specify servers at the root, [path](https://spec.openapis.org/oas/latest.html#path-item-object) and [operation](https://spec.openapis.org/oas/latest.html#operation-object) level. They allow you to specify multiple servers, however the OpenAPI specification is opinionated that all servers specified in a Document should return the same thing.
68+
OpenAPI Documents allow you to specify servers at the root, [path](https://spec.openapis.org/oas/latest.html#path-item-object) and [operation](https://spec.openapis.org/oas/latest.html#operation-object) level. They allow you to specify multiple servers, however the OpenAPI specification is opinionated that all servers specified in a Document should return the same thing and this Arazzo Runner will follow this opinion and only attempt one of the specified servers.
6969

7070
This Arazzo Runner will pick the first server it comes across in the array of servers and run the operation against that.
7171

@@ -77,10 +77,114 @@ It will attempt to map to the [Server Variables](https://spec.openapis.org/oas/l
7777

7878
## OpenAPI Parameters
7979

80-
OpenAPI Documents allow you to specify [`header`, `path` and `query` parameters](https://spec.openapis.org/oas/latest.html#parameter-object) in myriad of styles. This Arazzo Runner will respect your styling (unless you specify stylings for `Accept`, `Authorization` or `Content-Type` headers, then it will ignore the stylings, as per the OpenAPI specification) and send the format to the server as specified by your OpenAPI document.
80+
OpenAPI Documents allow you to specify [`header`, `path` and `query` parameters](https://spec.openapis.org/oas/latest.html#parameter-object) in myriad of styles. This Arazzo Runner will respect your styling (unless you specify stylings for `Accept`, `Authorization` or `Content-Type` headers, then it will ignore the stylings, as per the OpenAPI specification) and send the format to the server as specified by your OpenAPI Document.
8181

8282
It currently does not follow the `allowEmptyValue`, `allowReserved` or the `content` keywords currently.
8383

84+
## OpenAPI Security
85+
86+
OpenAPI Document security is supported. There are a couple of ways that you will have to document your Arazzo Workflow for certain documentation types.
87+
88+
### Basic
89+
90+
For HTTP Basic authentication, you should document your Arazzo like:
91+
92+
**arazzo.json**
93+
94+
```json
95+
"steps": [
96+
{
97+
"stepId": "deleteUser",
98+
"operationId": "deleteUser",
99+
"parameters": [
100+
{
101+
"name": "Authorization",
102+
"in": "header",
103+
"value": "{$inputs.username}:{$inputs.password}"
104+
},
105+
{ "name": "username", "in": "path", "value": "$inputs.username" }
106+
]
107+
}
108+
]
109+
```
110+
111+
The Runner will correctly encode and prepend `Basic` to the Authorization Header.
112+
113+
### Bearer
114+
115+
For HTTP Bearer authentication, you should document your Arazzo like:
116+
117+
**arazzo.json**
118+
119+
```json
120+
{
121+
"stepId": "LoginExistingUser",
122+
"operationId": "loginUser",
123+
"requestBody": {
124+
"contentType": "application/json",
125+
"payload": {
126+
"username": "$inputs.username",
127+
"password": "$inputs.password"
128+
}
129+
},
130+
"outputs": { "AccessToken": "$response.body#/AccessToken" }
131+
},
132+
{
133+
"stepId": "deleteUser",
134+
"operationId": "deleteUser",
135+
"parameters": [
136+
{
137+
"name": "Authorization",
138+
"in": "header",
139+
"value": "$steps.LoginExistingUser.outputs.AccessToken"
140+
},
141+
{ "name": "username", "in": "path", "value": "$inputs.username" }
142+
]
143+
}
144+
```
145+
146+
The Runner will prepend `Bearer` for you.
147+
148+
### mutualTLS
149+
150+
> mutualTLS is quite a complex authorization topic. I have written a naive way of dealing with it that I am unsure will actually work in production. If you are using mutualTLS and this Arazzo Runner and find that you run into bugs/issues, please do feel free to opena. report. The more I know and understand mutualTLS the better I can support it.
151+
152+
You will need to provide inputs for your ClientKey and ClientCert as their path locations:
153+
154+
**input.json**
155+
156+
```json
157+
{
158+
"deleteCurrentUser-mutualTLS": {
159+
"username": "jack",
160+
"key": "./client-key.pem",
161+
"cert": "./client-cert.pem"
162+
}
163+
}
164+
```
165+
166+
`key` and `cert` are reserved names when used in an OpenAPI Document with `mutualTLS` as the authentication method. The Runner will error out if they are not found.
167+
168+
### UNSUPPORTED oauth/openId
169+
170+
**CURRENTLY UNSUPPORTED**
171+
172+
You will need to provide inputs for your clientId and clientSecret:
173+
174+
**input.json**
175+
176+
```json
177+
{
178+
"deleteCurrentUser-mutualTLS": {
179+
"username": "jack",
180+
"clientId": "abc123",
181+
"clientSecret": "123abc"
182+
}
183+
}
184+
```
185+
186+
`clientId` and `clientSecret` are reserved name and will be used when oauth or openId authentication is set.
187+
84188
## Logging And Reporting
85189

86190
### Logging
@@ -111,10 +215,6 @@ Work on Reporting still needs completeing.
111215

112216
## Still unsupported
113217

114-
### Security
115-
116-
OpenAPI security is still not fully supported
117-
118218
### PathOperation
119219

120220
Accessing an OpenAPI operation by Operation Path `'{$sourceDescriptions.petstoreDescription.url}#/paths/~1pet~1findByStatus/get'` does not work currently

package-lock.json

Lines changed: 34 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "arazzo-runner",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"description": "A runner to run through Arazzo Document workflows",
55
"main": "index.js",
66
"scripts": {
@@ -43,6 +43,7 @@
4343
"jsonpath": "^1.1.1",
4444
"openapi-params": "^0.0.5",
4545
"openapi-server-url-templating": "^1.3.0",
46+
"openid-client": "^6.8.1",
4647
"stream-chain": "^3.4.0",
4748
"stream-json": "^1.9.1"
4849
}

0 commit comments

Comments
 (0)