Skip to content

Commit 4b686af

Browse files
committed
using x-required
1 parent 0da53c3 commit 4b686af

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/main/resources/wfc/schemas/auth.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
#####################################################################################################################
2+
## We use a JSON Schema to validate JSON/YAML configuration files with auth info.
3+
## However, such files need to be post-processed to handle merge of keys from 'authTemplate'.
4+
## In the past, YAML had native support for this in the form of templates, but this is no longer the case.
5+
## A concrete side-effect of this issue is that we cannot use "required" constraints, as those would be applied
6+
## to the document as it is, before the template resolution.
7+
## A pragmatic compromise is to avoid "required", and rather use "x-required".
8+
## The validation of required constraints would then be delegated to whatever is used to resolve the templates.
9+
#####################################################################################################################
110
$schema: "https://json-schema.org/draft/2020-12/schema"
211
$id: "https://github.com/WebFuzzing/Commons/blob/master/src/main/resources/wfc/schemas/auth.yaml"
312
title: "Web Fuzzing Commons Authentication"
@@ -45,7 +54,7 @@ $defs:
4554
value:
4655
description: "The value of the header"
4756
type: string
48-
required: ["name","value"]
57+
x-required: ["name","value"]
4958
AuthenticationInfo:
5059
type: object
5160
properties:
@@ -69,7 +78,7 @@ $defs:
6978
$ref: "#/$defs/Header"
7079
loginEndpointAuth:
7180
$ref: "#/$defs/LoginEndpoint"
72-
required: ["name"]
81+
x-required: ["name"]
7382
###
7483
LoginEndpoint:
7584
description: "Used to represent the case in which a login endpoint is used to obtain the authentication credentials. \
@@ -115,7 +124,7 @@ $defs:
115124
If so, a fuzzer can use those as auth info in following requests, instead of trying to extract \
116125
an auth token from the response payload."
117126
type: boolean
118-
required: ["verb"]
127+
x-required: ["verb"]
119128
###
120129
TokenHandling:
121130
description: "Specify how to extract the token from the HTTP response, and how to use it for auth in following requests. \
@@ -156,7 +165,7 @@ $defs:
156165
examples:
157166
- "Bearer {token}"
158167
- "JWT {token}"
159-
required: ["extractFrom", "extractSelector", "sendIn", "sendName"]
168+
x-required: ["extractFrom", "extractSelector", "sendIn", "sendName"]
160169
###
161170
PayloadUsernamePassword:
162171
description: "Payload with username and password information. \
@@ -175,4 +184,4 @@ $defs:
175184
passwordField:
176185
description: "The name of the field in the body payload containing the password"
177186
type: string
178-
required: ["username","usernameField","password","passwordField"]
187+
x-required: ["username","usernameField","password","passwordField"]

0 commit comments

Comments
 (0)