mod_http_oauth2/mod_http_oauth2.lua
changeset 5770 b8a2b3ebe792
parent 5768 87920d436cb4
child 5771 a967bb4972c5
--- a/mod_http_oauth2/mod_http_oauth2.lua	Sun Dec 03 21:25:39 2023 +0100
+++ b/mod_http_oauth2/mod_http_oauth2.lua	Sun Dec 03 23:44:18 2023 +0100
@@ -1344,8 +1344,24 @@
 end
 
 function create_client(client_metadata)
-	if not schema.validate(registration_schema, client_metadata) then
-		return nil, oauth_error("invalid_request", "Failed schema validation.");
+	local valid, validation_errors = schema.validate(registration_schema, client_metadata);
+	if not valid then
+		return nil, errors.new({
+			type = "modify";
+			condition = "bad-request";
+			code = 400;
+			text = "Failed schema validation.";
+			extra = {
+				oauth2_response = {
+					error = "invalid_request";
+					error_description = "Client registration data failed schema validation."; -- TODO Generate from validation_errors?
+					-- JSON Schema Output Format
+					-- https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#name-basic
+					valid = false;
+					errors = validation_errors;
+				};
+			};
+		});
 	end
 
 	local client_uri = url.parse(client_metadata.client_uri);