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" for fields that can be merged, and rather use "x-required".
8+ # # The validation of x-required constraints would then be delegated to whatever is used to resolve the templates.
9+ # #
10+ # # An "x-required" custom entry can be either an array of strings (with same semantic of "required") or an object (with
11+ # # fields such as "allOf" and "oneOf" to express more fine-grained constraints)
12+ # ####################################################################################################################
113$schema : " https://json-schema.org/draft/2020-12/schema"
214$id : " https://github.com/WebFuzzing/Commons/blob/master/src/main/resources/wfc/schemas/auth.yaml"
315title : " Web Fuzzing Commons Authentication"
@@ -27,8 +39,6 @@ properties:
2739 type : string
2840required : ["auth"]
2941$defs :
30- # TODO unfortunately, tools like jsonschema2pojo-maven-plugin have major limitations when dealing with enums.
31- # This is not created as a top-level class
3242 HttpVerb :
3343 type : string
3444 enum :
7181 $ref : " #/$defs/Header"
7282 loginEndpointAuth :
7383 $ref : " #/$defs/LoginEndpoint"
74- required : ["name"]
84+ x- required : ["name"]
7585 # ##
7686 LoginEndpoint :
7787 description : " Used to represent the case in which a login endpoint is used to obtain the authentication credentials. \
@@ -99,17 +109,8 @@ $defs:
99109 items :
100110 $ref : " #/$defs/Header"
101111 verb :
102- # description: "The verb used to connect to the login endpoint. \
103- # Most of the time, this will be a 'POST'."
104- # type: string
105- # enum:
106- # - POST
107- # - GET
108- # - PATCH
109- # - DELETE
110- # - PUT
111112 $ref : " #/$defs/HttpVerb"
112- # # FIXME: unfortunately, plugin is not able to handle this... need new schema version with $ref not replacing everything
113+ # # FIXME: need to schema version with $ref not replacing everything
113114# description: "The verb used to connect to the login endpoint. \
114115# Most of the time, this will be a 'POST'."
115116# allOf:
@@ -126,7 +127,9 @@ $defs:
126127 If so, a fuzzer can use those as auth info in following requests, instead of trying to extract \
127128 an auth token from the response payload."
128129 type : boolean
129- required : ["verb"]
130+ x-required :
131+ allOf : ["verb"]
132+ oneOf : ["endpoint","externalEndpointURL"]
130133 # ##
131134 TokenHandling :
132135 description : " Specify how to extract the token from the HTTP response, and how to use it for auth in following requests. \
@@ -167,7 +170,7 @@ $defs:
167170 examples :
168171 - " Bearer {token}"
169172 - " JWT {token}"
170- required : ["extractFrom", "extractSelector", "sendIn", "sendName"]
173+ x- required : ["extractFrom", "extractSelector", "sendIn", "sendName"]
171174 # ##
172175 PayloadUsernamePassword :
173176 description : " Payload with username and password information. \
@@ -186,4 +189,4 @@ $defs:
186189 passwordField :
187190 description : " The name of the field in the body payload containing the password"
188191 type : string
189- required : ["username","usernameField","password","passwordField"]
192+ x- required : ["username","usernameField","password","passwordField"]
0 commit comments