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

Purge with surrogate key not working #583

Open
neurosnap opened this issue Dec 10, 2024 · 3 comments · May be fixed by #589
Open

Purge with surrogate key not working #583

neurosnap opened this issue Dec 10, 2024 · 3 comments · May be fixed by #589

Comments

@neurosnap
Copy link

neurosnap commented Dec 10, 2024

Greetings, purging with surrogate keys is not currently working for me. It looks like the key values are getting stored URL encoded and then being sent to the Storer as-is and then not finding the keys to clear:

curl -v -H "Authorization: Basic xxx" https://pgs.test/souin-api/souin/surrogate_keys
{"erock-test":",GET-https-erock-test.pgs.test-%2F"}

curl -v -XPURGE -H "Authorization: Basic xxx" -H "surrogate-key: erock-test" https://pgs.test/souin-api/souin/
Status: 204

curl -v -H "Authorization: Basic xxx" https://pgs.test/souin-api/souin/
["GET-https-erock-test.pgs.test-/"]

curl -v -H "Authorization: Basic xxx" https://pgs.test/souin-api/souin/surrogate_keys
{"erock-test":",GET-https-erock-test.pgs.test-%2F"}

https://github.com/darkweak/souin/blob/master/pkg/surrogate/providers/common.go#L223

It looks like we might need to expand the QueryUnescape logic? https://github.com/darkweak/souin/blob/master/pkg/surrogate/providers/common.go#L85

@neurosnap
Copy link
Author

This probably isn't the "right" way to fix it but this is what we did inside pico (we are using our own impl of the souin API): https://github.com/picosh/pico/blob/706b21492f4133c7e5519a0a82f9d8c89fed8317/pgs/web.go#L315

@darkweak
Copy link
Owner

Hey @neurosnap sorry for the long delay. I'll try to write a fix for that.

@darkweak
Copy link
Owner

@neurosnap you can try the fix using

xcaddy build --with github.com/darkweak/souin/plugins/caddy@cae85eea6558e65bf2eb049a4c885a648fd781d7 --with github.com/darkweak/souin@cae85eea6558e65bf2eb049a4c885a648fd781d7

@darkweak darkweak linked a pull request Dec 24, 2024 that will close this issue
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.

2 participants