-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(openid-connect): the default 'redirect_uri' (#2426) #7690
Changes from 8 commits
674b85e
4af8303
75abdd0
02b0707
d4f158a
9d11f55
46ecafd
af8d34b
b375f9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ local schema = { | |
}, | ||
redirect_uri = { | ||
type = "string", | ||
description = "use ngx.var.request_uri if not configured" | ||
description = "auto append '.apisix/redirect' if not configured" | ||
monkeyDluffy6017 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
post_logout_redirect_uri = { | ||
type = "string", | ||
|
@@ -357,7 +357,22 @@ function _M.rewrite(plugin_conf, ctx) | |
end | ||
|
||
if not conf.redirect_uri then | ||
conf.redirect_uri = ctx.var.request_uri | ||
-- NOTE: 'lua-resty-openidc' requires that 'redirect_uri' be | ||
-- different from 'uri'. So default to append the | ||
-- '.apisix/redirect' suffix if not configured. | ||
local suffix = "/.apisix/redirect" | ||
local uri = ctx.var.uri | ||
if core.string.has_suffix(uri, suffix) then | ||
-- This is the redirection response from the OIDC provider. | ||
conf.redirect_uri = uri | ||
else | ||
if string.sub(uri, -1, -1) == "/" then | ||
conf.redirect_uri = string.sub(uri, 1, -2) .. suffix | ||
else | ||
conf.redirect_uri = uri .. suffix | ||
end | ||
end | ||
core.log.debug("auto set redirect_uri: ", conf.redirect_uri) | ||
Comment on lines
+360
to
+375
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When there is no Can we inject a default value for For example:
Listen to what others say. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @liweitianux any thoughts about this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we can set a proper default value for Please correct me if I'm mistaken. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a test case to show that not providing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the job this year, and I haven't been working with APISIX for more than one year now. I'm unfamiliar with the test framework, and that was the main reason that this PR was lacking a test case. It would be great if you can rejuvenate this PR. Thanks. |
||
end | ||
|
||
if not conf.ssl_verify then | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it cannot make sure the new URI will be matched by the same route, it actually adds an implicit condition that the route match type is prefix instead of exact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well. If the route is of type exact, then it cannot actually use this
openid-connect
plugin, because theredirect_uri
must be different from the request URI, as required bylua-resty-openidc
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liweitianux Could you write some hints about this in the OpenID Connect doc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'll update the doc later.