-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(openid-connect): add proxy_opts attribute #9948
Changes from 9 commits
2af32a1
682e638
d2cf653
7ff7c67
a3a9456
0adee8a
971d870
f21c702
4f96e3e
41a4c86
2bdeb21
b43a0c9
af65432
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 |
---|---|---|
|
@@ -61,6 +61,7 @@ description: OpenID Connect allows the client to obtain user information from th | |
| session | object | False | | | When bearer_only is set to false, openid-connect will use Authorization Code flow to authenticate on the IDP, so you need to set the session-related configuration. | | ||
| session.secret | string | True | Automatic generation | 16 or more characters | The key used for session encrypt and HMAC operation. | | ||
| unauth_action | string | False | "auth" | | Specify the response type on unauthenticated requests. "auth" redirects to identity provider, "deny" results in a 401 response, "pass" will allow the request without authentication. | | ||
| proxy_opts | object | False | | | Configure an HTTP proxy to be used with the openid-connect plugin. | | ||
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. Could you list all options? 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.
done,pls help to review 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 didn't see the options in 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 had add no_proxy option before doc in set_proxy_options
syntax: httpc:set_proxy_options(opts)
Configure an HTTP proxy to be used with this client instance. The opts table expects the following fields:
http_proxy: an URI to a proxy server to be used with HTTP requests
http_proxy_authorization: a default Proxy-Authorization header value to be used with http_proxy, e.g. Basic ZGVtbzp0ZXN0, which will be overriden if the Proxy-Authorization request header is present.
https_proxy: an URI to a proxy server to be used with HTTPS requests
https_proxy_authorization: as http_proxy_authorization but for use with https_proxy (since with HTTPS the authorisation is done when connecting, this one cannot be overridden by passing the Proxy-Authorization request header).
no_proxy: a comma separated list of hosts that should not be proxied. 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. The option you added in the doc
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. hi @monkeyDluffy6017 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. hi @Sn0rt Because when I did that before in our project, it caused an exception In addition I noticed some hardcoded special handling in the We may need to confirm this disagreement |
||
|
||
NOTE: `encrypt_fields = {"client_secret"}` is also defined in the schema, which means that the field will be stored encrypted in etcd. See [encrypted storage fields](../plugin-develop.md#encrypted-storage-fields). | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
use t::APISIX 'no_plan'; | ||
|
||
log_level('debug'); | ||
repeat_each(1); | ||
no_long_string(); | ||
no_root_location(); | ||
no_shuffle(); | ||
|
||
add_block_preprocessor(sub { | ||
my ($block) = @_; | ||
|
||
if ((!defined $block->error_log) && (!defined $block->no_error_log)) { | ||
$block->set_value("no_error_log", "[error]"); | ||
} | ||
|
||
if (!defined $block->request) { | ||
$block->set_value("request", "GET /t"); | ||
} | ||
}); | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
|
||
=== TEST 1: Set up new route access the auth server via http proxy | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local t = require("lib.test_admin").test | ||
local code, body = t('/apisix/admin/routes/1', | ||
ngx.HTTP_PUT, | ||
[[{ | ||
"plugins": { | ||
"openid-connect": { | ||
"client_id": "kbyuFDidLLm280LIwVFiazOqjO3ty8KH", | ||
"client_secret": "60Op4HFM0I8ajz0WdiStAbziZ-VFQttXuxixHHs2R7r7-CW8GR79l-mmLqMhc-Sa", | ||
"discovery": "https://samples.auth0.com/.well-known/openid-configuration", | ||
"redirect_uri": "https://iresty.com", | ||
"ssl_verify": false, | ||
"timeout": 10, | ||
"scope": "apisix", | ||
"proxy_opts": { | ||
"http_proxy": "http://127.0.0.1:8080", | ||
"http_proxy_authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQK" | ||
}, | ||
"use_pkce": false | ||
} | ||
}, | ||
"upstream": { | ||
"nodes": { | ||
"127.0.0.1:1980": 1 | ||
}, | ||
"type": "roundrobin" | ||
}, | ||
"uri": "/hello" | ||
}]] | ||
) | ||
|
||
if code >= 300 then | ||
ngx.status = code | ||
end | ||
ngx.say(body) | ||
|
||
} | ||
} | ||
--- response_body | ||
passed | ||
|
||
|
||
|
||
=== TEST 2: Access route w/o bearer token. Should redirect to authentication endpoint of ID provider. | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local http = require "resty.http" | ||
local httpc = http.new() | ||
local uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/hello" | ||
local res, err = httpc:request_uri(uri, {method = "GET"}) | ||
ngx.status = res.status | ||
local location = res.headers['Location'] | ||
if location and string.find(location, 'https://samples.auth0.com/authorize') ~= -1 and | ||
string.find(location, 'scope=apisix') ~= -1 and | ||
string.find(location, 'client_id=kbyuFDidLLm280LIwVFiazOqjO3ty8KH') ~= -1 and | ||
string.find(location, 'response_type=code') ~= -1 and | ||
string.find(location, 'redirect_uri=https://iresty.com') ~= -1 then | ||
ngx.say(true) | ||
end | ||
} | ||
} | ||
--- timeout: 10s | ||
--- response_body | ||
true | ||
--- error_code: 302 | ||
--- error_log | ||
use http proxy |
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.
Typo?
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.
seems to, i just fixed it
by the way, do you think it will be better by using "oauth2 server" instead of "openid server" ?
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.
Do you mean
OpenID Provider(OP)
?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.
This PR will be handed over to you to follow up later, I have to fix other problems. Can you? @darkSheep404