Skip to content

Adding username as parameter for the redis authentication#65

Closed
kerkmann wants to merge 1 commit intoboj:masterfrom
kerkmann:add-username-parameter
Closed

Adding username as parameter for the redis authentication#65
kerkmann wants to merge 1 commit intoboj:masterfrom
kerkmann:add-username-parameter

Conversation

@kerkmann
Copy link

Intention

I am using Authentik which is using your library. There is an open ticket for settings the Redis username. Sadly the username is not set in this library. Without fixing that issuer here, it's impossible to fix it in Authentik. ^^"

Changes

Adding the username as optional parameter.

I hope the PR is looking good, I am not a go developer. Please let me know if something is wrong/missing.

Comment on lines +146 to +155
if username != "" {
if _, err := c.Do("AUTH", password); err != nil {
c.Close()
return nil, err
}
} else {
if _, err := c.Do("AUTH", username, password); err != nil {
c.Close()
return nil, err
}

Choose a reason for hiding this comment

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

You switched the call in the condition:

  • empty username calls the command using the username variable
  • a non-empty username calls the command without using the username variable

Copy link

Choose a reason for hiding this comment

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

Yes, sorry for the mistaken.

I don't think this PR will be accepted by the author.
The repo is inactive for such a long time.

Copy link

Choose a reason for hiding this comment

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

Besides, I suggest that using tcp link url to include username and database index is the trick to pass through this dilemma if your library is dependent on redistore.

Choose a reason for hiding this comment

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

Yes, sorry for the mistaken.

I don't think this PR will be accepted by the author.
The repo is inactive for such a long time.

Yes, I am of the same opinion. Perhaps an authentik should use a different library than this one if we want to implement modern Redis features.

appleboy added a commit that referenced this pull request Feb 10, 2025
- Add import for `strconv`
- Remove the `dial` function and its associated comments
- Update `NewRediStore` to include `username` parameter
- Replace `dial` with `dialClient` in `NewRediStore`
- Remove `dialWithDB` function
- Add `dialClient` function with username and database handling
- Update `NewRediStoreWithDB` to include `username` parameter
- Replace `dialWithDB` with `dialClient` in `NewRediStoreWithDB`
- Update tests to include `username` parameter in `NewRediStore` and `NewRediStoreWithDB` calls

fix #65

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@appleboy appleboy closed this in #75 Feb 10, 2025
appleboy added a commit that referenced this pull request Feb 10, 2025
* refactor: refactor RediStore to support username parameter

- Add import for `strconv`
- Remove the `dial` function and its associated comments
- Update `NewRediStore` to include `username` parameter
- Replace `dial` with `dialClient` in `NewRediStore`
- Remove `dialWithDB` function
- Add `dialClient` function with username and database handling
- Update `NewRediStoreWithDB` to include `username` parameter
- Replace `dialWithDB` with `dialClient` in `NewRediStoreWithDB`
- Update tests to include `username` parameter in `NewRediStore` and `NewRediStoreWithDB` calls

fix #65

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* docs: clarify and update comments for authentication and Redis connection

- Update authentication comments to include username and password
- Clarify that keyPairs are used for cookie encryption only
- Add username parameter to Redis connection details in comments
- Simplify and clarify comments on Redis connection parameters and return values

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

---------

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
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