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

add support for username for redis as cache in tegola config #1010

Closed
ibrahimjel opened this issue Nov 17, 2024 · 10 comments · Fixed by #1011
Closed

add support for username for redis as cache in tegola config #1010

ibrahimjel opened this issue Nov 17, 2024 · 10 comments · Fixed by #1011

Comments

@ibrahimjel
Copy link

Hi,
I am using tegola with redis as cache type. my redis DB has username and password to authenticate with. when put in address like this URL redis://<username>:<password>@redis:6379, tegola throw exception

could not register cache: address redis://<user>:<password>@redis:6379: too many colons in address

would be great to introduce new field username in redis.go.

@ibrahimjel ibrahimjel changed the title add support for username for redis as cache for tegola add support for username for redis as cache in tegola config Nov 17, 2024
@iwpnd
Copy link
Member

iwpnd commented Nov 17, 2024

I can take a look tomorrow. I’m however surprised to read this. Pretty sure we use it with credentials too.

@ibrahimjel
Copy link
Author

do you have example with that or where credentials used.
I cant find where credentials mentioned under cache/redis

@iwpnd
Copy link
Member

iwpnd commented Nov 17, 2024

You can use the uri like you did. Make sure your password does not contain a colon though. If this does not work correctly I can take a look.

@ibrahimjel
Copy link
Author

I tried different combinations of parsedURL, and in all of them tegola container threw the exception tegola | could not register cache: address <address>: too many colons in address. I believe it throws this exception if there is more than 1 colon in the address

@ARolek
Copy link
Member

ARolek commented Nov 18, 2024

@ibrahimjel here's what seems like a related issue in the driver: redis/go-redis#2870

Try removing redis:// from the connection string.

@iwpnd
Copy link
Member

iwpnd commented Nov 18, 2024

As far as I can see we do not support the uri after all. Probably something we should do similar to the change we did to Postgres a while back? @ARolek
I mean deprecating the host name in v0.21.0 and removing it in favor of the uri in v0.22.0?

@ARolek
Copy link
Member

ARolek commented Nov 18, 2024

As far as I can see we do not support the uri after all. Probably something we should do similar to the change we did to Postgres a while back? @ARolek
I mean deprecating the host name in v0.21.0 and removing it in favor of the uri in v0.22.0?

Ah yes, so that's the issue. I should have dug deeper. I agree we should deprecate the old config properties in favor of the connection string. Thanks for the quick turn around on the PR. I just left you a review!

iwpnd added a commit to iwpnd/tegola that referenced this issue Nov 19, 2024
closes: go-spatial#1010

chore: resolve review comments
ARolek pushed a commit that referenced this issue Nov 19, 2024
closes: #1010

chore: resolve review comments
@ARolek
Copy link
Member

ARolek commented Nov 19, 2024

@ibrahimjel the one and only @iwpnd implemented connection string handling for redis! You can grab a binary to test it out via the GH Action: https://github.com/go-spatial/tegola/actions/runs/11917492487. Config documentation has also been updated: https://github.com/go-spatial/tegola/tree/master/cache/redis

Please report back how this works for you.

@ibrahimjel
Copy link
Author

@rolek @iwpnd Thanks for your work. I just tested the uri in my tegola config.toml

# Use Redis for caching
[cache]
type = "redis"
uri = "redis://${REDIS_USER_TEGOLA}:${REDIS_PASSWORD_TEGOLA}@${REDIS_HOST}:${REDIS_PORT}/${REDIS_DB_TEGOLA"
ttl = 43200

and I go this error:

tegola | 2024-11-19 16:57:47 [INFO] providers.go:82: registering provider(type): <.....>
tegola | Error: could not register cache: ERR AUTH called without any password configured for the default user. Are you sure your configuration is correct?

I have multiple redis users in my redis ACL. I believe tegola assume the default user here, which I disabled it in my ACL.

can you please add option for Username in &redis.Options redis.go.

@iwpnd
Copy link
Member

iwpnd commented Nov 19, 2024

Username is the same as REDIS_USER_TEGOLA in the example your provided. Make sure your environment is properly populated and your redis instance actually requires a password.

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 a pull request may close this issue.

3 participants