Skip to content

Commit fd9d934

Browse files
committed
all auth errors as JSON
1 parent b616780 commit fd9d934

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/hooks/app/auth/auth.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,30 @@ def validate_auth!(payload, headers, endpoint_config, global_config = {})
2525
# Ensure auth type is present and valid
2626
auth_type = auth_config&.dig(:type)
2727
unless auth_type&.is_a?(String) && !auth_type.strip.empty?
28-
error!("authentication configuration missing or invalid", 500)
28+
error!({
29+
error: "authentication_configuration_error",
30+
message: "authentication configuration missing or invalid"
31+
}, 500)
2932
end
3033

3134
# Get auth plugin from loaded plugins registry (boot-time loaded only)
3235
begin
3336
auth_class = Core::PluginLoader.get_auth_plugin(auth_type)
3437
rescue => e
3538
log.error("failed to load auth plugin '#{auth_type}': #{e.message}")
36-
error!("unsupported auth type '#{auth_type}'", 400)
39+
error!({
40+
error: "authentication_plugin_error",
41+
message: "unsupported auth type '#{auth_type}'"
42+
}, 400)
3743
end
3844

3945
log.debug("validating auth for request with auth_class: #{auth_class.name}")
4046
unless auth_class.valid?(payload:, headers:, config: endpoint_config)
4147
log.warn("authentication failed for request with auth_class: #{auth_class.name}")
42-
error!("authentication failed", 401)
48+
error!({
49+
error: "authentication_failed",
50+
message: "authentication failed"
51+
}, 401)
4352
end
4453
end
4554

0 commit comments

Comments
 (0)