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(redis) add support for username/password auth #121

Merged
merged 6 commits into from
Aug 13, 2024
Merged

feat(redis) add support for username/password auth #121

merged 6 commits into from
Aug 13, 2024

Conversation

gruceo
Copy link
Collaborator

@gruceo gruceo commented Aug 13, 2024

lua-resty-redis supports username/password authentication:

local res, err = red:auth("userexample", "passexample")
if not res then
  ngx.say("failed to authenticate: ", err)
  return
end

Squash and merge:

feat(redis) add support for username/password auth

lua-resty-redis supports username/password authentication:

```
local res, err = red:auth("userexample", "passexample")
if not res then
  ngx.say("failed to authenticate: ", err)
  return
end
```
local _, err = client:auth(self.auth)
local _, err
if type(self.auth) == "table" then
_, err = client:auth(self.auth.username, self.auth.password)
Copy link
Owner

Choose a reason for hiding this comment

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

I would actually suggest new fields being added (username, password) in addition to auth, otherwise we may need to write complex compat code on kong side.

Copy link

Choose a reason for hiding this comment

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

I think from style perspective I'd rather prefer to have separate fields as well. However I'm wondering - will it really require compat code on kong side? Even the way it's implemented here? 🤔 CP/DP will run different versions of this lib so I think we're good, right?

Copy link
Owner

@fffonion fffonion Aug 13, 2024

Choose a reason for hiding this comment

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

we do, unfortunately, because we need to define the schema at kong side (https://github.com/Kong/kong/blob/master/kong/plugins/acme/schema.lua#L85).
actually, i'm thinking to implement a new redis storage, using the kong provided redis library + schema in the kong acme plugin, that skipped the redis storage provided by this library.
basically we only need to add a kong/plugins/acme/storage/redis.lua then do something similar as this line https://github.com/Kong/kong/blob/master/kong/plugins/acme/client.lua#L91.

then we can from now on have aligned redis schema in the acme plugin with other plugins too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done here 3766433

Copy link

Choose a reason for hiding this comment

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

@fffonion Please correct me if I'm wrong but I think with the introduction of config adapter: https://github.com/Kong/kong/blob/master/kong/plugins/acme/storage/config_adapters/redis.lua
There's no need to write any compat code since plugin's schema is separated from this library's config.

@fffonion
Copy link
Owner

fffonion commented Aug 13, 2024

added you as collaborator so don't need to approve the CI run everytime @gruceo you might need to click some button to accept it

@gruceo
Copy link
Collaborator Author

gruceo commented Aug 13, 2024

FYI there are some flaky tests unrelated to the PR:

Error: led test 't/e2e.t TEST 2: http-01 challenge with RSA + ECC dual certs - pattern "[error]" should not match any line in error.log but matches line "2024/08/13 15:55:13 [error] 22960#0: *24 [acme] autossl.lua:659: failed to create ecc certificate for domain e2e-test2-1723564498: no challenge is registered and no challenge is valid, context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:5001" (req 0)

Restarted the build, and the error went away. Full build with logs: https://github.com/fffonion/lua-resty-acme/actions/runs/10373050111/attempts/1?pr=121

Please squash and merge:

feat(redis) add support for username/password auth

@gruceo gruceo requested review from fffonion and nowNick August 13, 2024 16:04
@fffonion
Copy link
Owner

i fixed a typo in code and seems tests need to be adjusted, could you take a look @gruceo ?

@gruceo
Copy link
Collaborator Author

gruceo commented Aug 13, 2024

done, thanks @fffonion

failure seems unrelated now

@gruceo
Copy link
Collaborator Author

gruceo commented Aug 13, 2024

@fffonion fffonion merged commit 186ab23 into fffonion:master Aug 13, 2024
5 checks passed
@fffonion
Copy link
Owner

Thank you @gruceo !

@fffonion
Copy link
Owner

released 0.15.0

gruceo added a commit to Kong/kong that referenced this pull request Aug 13, 2024
Fixed an issue where username and password were not accepted as valid authentication methods.

Depends on this PR of lua-resty-acme: fffonion/lua-resty-acme#121

Fix FTI-6143
gruceo added a commit to Kong/kong that referenced this pull request Aug 13, 2024
Fixed an issue where username and password were not accepted as valid authentication methods.

Depends on this PR of lua-resty-acme: fffonion/lua-resty-acme#121

Fix FTI-6143
gruceo added a commit to Kong/kong that referenced this pull request Aug 13, 2024
Fixed an issue where username and password were not accepted as valid authentication methods.

Depends on this PR of lua-resty-acme: fffonion/lua-resty-acme#121

Fix FTI-6143
gruceo added a commit to Kong/kong that referenced this pull request Aug 14, 2024
Fixed an issue where username and password were not accepted as a valid
authentication method. This is already accepted as valid authentication
method in other plugins that use the shared Redis library such as the
rate-limiting plugin.

Depends on this PR of lua-resty-acme: fffonion/lua-resty-acme#121

Fix FTI-6143
gruceo added a commit to Kong/kong that referenced this pull request Aug 15, 2024
Fixed an issue where username and password were not accepted as a valid
authentication method. This is already accepted as valid authentication
method in other plugins that use the shared Redis library such as the
rate-limiting plugin.

Depends on this PR of lua-resty-acme: fffonion/lua-resty-acme#121

Fix FTI-6143
gruceo added a commit to Kong/kong that referenced this pull request Aug 16, 2024
Fixed an issue where username and password were not accepted as a valid
authentication method. This is already accepted as valid authentication
method in other plugins that use the shared Redis library such as the
rate-limiting plugin.

Depends on this PR of lua-resty-acme: fffonion/lua-resty-acme#121

Fix FTI-6143
bungle added a commit to Kong/kong that referenced this pull request Aug 19, 2024
### Summary

### [0.15.0] - 2024-08-14
#### bug fixes
- **tests:** use tlsv1.2 in dual cert test [415be3f](fffonion/lua-resty-acme@415be3f)
- **tests:** uses v3 protocol for etcd [c3928b5](fffonion/lua-resty-acme@c3928b5)

#### features
- **etcd:** etcd storage to use v3 protocol [a3353b3](fffonion/lua-resty-acme@a3353b3)
- **redis:** add support for username/password auth ([#121](fffonion/lua-resty-acme#121)) [186ab23](fffonion/lua-resty-acme@186ab23)

KAG-5189

Signed-off-by: Aapo Talvensaari <[email protected]>
bungle added a commit to Kong/kong that referenced this pull request Aug 19, 2024
### Summary

### [0.15.0] - 2024-08-14
#### bug fixes
- **tests:** use tlsv1.2 in dual cert test [415be3f](fffonion/lua-resty-acme@415be3f)
- **tests:** uses v3 protocol for etcd [c3928b5](fffonion/lua-resty-acme@c3928b5)

#### features
- **etcd:** etcd storage to use v3 protocol [a3353b3](fffonion/lua-resty-acme@a3353b3)
- **redis:** add support for username/password auth ([#121](fffonion/lua-resty-acme#121)) [186ab23](fffonion/lua-resty-acme@186ab23)

KAG-5189

Signed-off-by: Aapo Talvensaari <[email protected]>
bungle pushed a commit to Kong/kong that referenced this pull request Aug 19, 2024
Fixed an issue where username and password were not accepted as a valid
authentication method. This is already accepted as valid authentication
method in other plugins that use the shared Redis library such as the
rate-limiting plugin.

Depends on this PR of lua-resty-acme: fffonion/lua-resty-acme#121

Fix FTI-6143
gruceo added a commit to Kong/kong that referenced this pull request Aug 19, 2024
…#13496)

* fix(plugins/acme): username/password is a valid authentication method

Fixed an issue where username and password were not accepted as a valid
authentication method. This is already accepted as valid authentication
method in other plugins that use the shared Redis library such as the
rate-limiting plugin.

Depends on this PR of lua-resty-acme: fffonion/lua-resty-acme#121

Fix FTI-6143
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.

3 participants