nic-6443 commented on code in PR #13081:
URL: https://github.com/apache/apisix/pull/13081#discussion_r3007920981
##########
apisix/plugins/openid-connect.lua:
##########
@@ -622,6 +623,88 @@ local function validate_claims_in_oidcauth_response(resp,
conf)
return core.schema.check(conf.claim_schema, data)
end
+
+local function get_forwarded_param(ctx, param_name)
+ local forwarded = ctx.var.http_forwarded
+ if not forwarded then
+ return nil
+ end
+ -- take only the first proxy entry (before any comma)
+ local first = forwarded:match("^([^,]+)")
+ if not first then
+ return nil
+ end
+ for part in first:gmatch("[^;]+") do
+ local name, value = part:match("^%s*([^=]+)%s*=%s*(.-)%s*$")
+ if name and name:lower() == param_name then
+ -- strip surrounding quotes
+ if value:sub(1, 1) == '"' then
+ value = value:sub(2, -2)
+ end
+ return value
+ end
+ end
+ return nil
+end
+
+
+-- Build an absolute redirect_uri from the incoming request.
+local function build_redirect_uri(ctx)
+ local suffix = "/.apisix/redirect"
+ local uri = ctx.var.uri
+ local redirect_path
+ if core.string.has_suffix(uri, suffix) then
+ -- This is the redirection response from the OIDC provider.
+ redirect_path = uri
+ else
+ if string.sub(uri, -1, -1) == "/" then
+ redirect_path = string.sub(uri, 1, -2) .. suffix
+ else
+ redirect_path = uri .. suffix
+ end
+ end
+
+ local scheme
+ local host
+
+ if trusted_addr.is_trusted(ctx.var.realip_remote_addr) then
Review Comment:
I think this logic is duplicated with `handle_x_forwarded_headers`. For the
current issue, I believe we should fix it in `handle_x_forwarded_headers` by
adding the port to `X-Forwarded-Host`. The port can be omitted for 80/443,
while other non-standard ports should be included in `X-Forwarded-Host`. I've
checked the relevant information, and this is the conventional practice.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]