# HG changeset patch # User Kim Alvefur # Date 1701643458 -3600 # Node ID b8a2b3ebe79204508233a7f95d81e86a7cfa20a1 # Parent 78368d2865ddd8eea66ab3d3416a77a48f882bd3 mod_http_oauth2: Return validation output added in trunk rev 72d7830505f0 It's not fun at all to try to register a client and only get back "failed schema validation", this should help with that. diff -r 78368d2865dd -r b8a2b3ebe792 mod_http_oauth2/mod_http_oauth2.lua --- 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);