[go: nahoru, domu]

Skip to content
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: Add the function to hide header for key-auth plugin #6670

Merged
merged 17 commits into from
Apr 6, 2022

Conversation

bin-ya
Copy link
Contributor
@bin-ya bin-ya commented Mar 21, 2022

Description

Add the function of hiding header for key-auth plugin

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@spacewander
Copy link
Member

Let's merge master to make CI pass.

…th-plugin-uograde

Conflicts:
	docs/en/latest/plugins/key-auth.md
	docs/zh/latest/plugins/key-auth.md
@@ -110,6 +114,10 @@ function _M.rewrite(conf, ctx)
end
core.log.info("consumer: ", core.json.delay_encode(consumer))

if conf.hide_credentials then
core.request.set_header(ctx, "apikey", nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
core.request.set_header(ctx, "apikey", nil)
core.request.set_header(ctx, conf.header, nil)

@tzssangglass
Copy link
Member

tzssangglass
tzssangglass previously approved these changes Mar 23, 2022
@@ -41,6 +41,7 @@ For route side:
| ---- | ------ | ----------- | ------- | ----- | ---------------------------------------------------------------------------- |
| header | string | optional | apikey | | the header we get the key from |
| query | string | optional | apikey | | the query string we get the key from, which priority is lower than `header` |
| hide_credentials | bool | optional | false | | Whether to pass the apikey request headers to the upstream. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing, the header is not necessary to be "apikey", it's specified by the header. Also, the query should also be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query is the content modified by others. Can I delete it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should only handle the query that used to carry the credential.

Copy link
Member
@juzhiyuan juzhiyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Would you like to share your Apache APISIX Development experience?

@tzssangglass
Copy link
Member

oo, another file conflict @bin-ya

@@ -41,6 +41,7 @@ router 端配置:
| ---- | ------ | ------ | ------ | ------ | ------------------------------------------------------------------------------------------------------------- |
| header | string | 可选| apikey | | 设置我们从哪个 header 获取 key。 |
| query | string | 可选 | apikey | | 设置我们从哪个 query string 获取 key,优先级低于 `header` |
| hide_credentials | bool | 可选 | false | | 是否将请求头传递给 upstream。 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| hide_credentials | bool | 可选 | false | | 是否将请求头传递给 upstream。 |
| hide_credentials | bool | 可选 | false | | 是否将含有认证信息的请求头传递给 upstream。 |

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@tzssangglass
Copy link
Member

File conflicts have not been resolved @bin-ya

…th-plugin-uograde

Conflicts:
	docs/zh/latest/plugins/key-auth.md
starsz
starsz previously approved these changes Mar 29, 2022
@@ -110,6 +114,10 @@ function _M.rewrite(conf, ctx)
end
core.log.info("consumer: ", core.json.delay_encode(consumer))

if conf.hide_credentials then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove the key according to where the key comes from.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will.

Comment on lines 119 to 120
core.request.get_uri_args(ctx)
core.request.set_uri_args(ctx, {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide information from query

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't necessary to remove the all query params
If the key is in the header, we only need to delete the key in the headers.
If the key is in the query, we only need to delete the key in the query params.

cc @spacewander right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should only remove the key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll revise it right away.

@spacewander spacewander changed the title feat: Add the function of hiding header for key-auth plugin feat: Add the function to hide header for key-auth plugin Apr 6, 2022
@spacewander spacewander merged commit 07d535d into apache:master Apr 6, 2022
Liu-Junlin pushed a commit to Liu-Junlin/apisix that referenced this pull request May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants