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

Remove the trailling slash for every requests #3760

Closed
wants to merge 3 commits into from
Closed

Remove the trailling slash for every requests #3760

wants to merge 3 commits into from

Conversation

Peltoche
Copy link
Contributor

@Peltoche Peltoche commented Feb 16, 2023

@Peltoche
Copy link
Contributor Author

@nono could you give me a little help here? I don't understand why the integration tests fail. It doesn't seems to be a flacky test.

@nono
Copy link
Member

nono commented Feb 21, 2023

The logs say:

time="2023-02-20T18:40:29.797020311Z" level=info msg="Not allowed ()" domain="alice.test.localhost:8102" nspace=replicator
time="2023-02-20T18:40:29.797077315Z" level=error msg="POST /sharings code=403, message=Forbidden" domain="alice.test.localhost:8102" nspace=http
time=2023-02-20T18:40:29.797106817Z	status=403	method=POST	host=alice.test.localhost:8102	uri=/sharings	bytes_out=9

It is weird, it looks like POST /sharings is not routed to CreateSharing (https://github.com/cozy/cozy-stack/pull/3760/files#diff-aea2d79003ac8d745e5e74e5788cc7283ae2356a687e037935773bceee38b410R704), but to a function in web/sharings/replicator.go. We have 3 occurrences of Not allowed in this file, but I doesn't understand which one is called and why.

@nono
Copy link
Member

nono commented Feb 21, 2023

Well, I think it is checkSharingPermissions from https://github.com/cozy/cozy-stack/blob/master/web/sharings/replicator.go#L165 that is called even if we don't call a route from this group.

@Peltoche
Copy link
Contributor Author

Sadness 😞 . Will try to find a solution

Previously a Group matching `"/"` was used but this match was matching
all the sharing path and the middleware was applied to incorrect paths
@nono
Copy link
Member

nono commented Feb 21, 2023

It looks like a bug from echo. Maybe you can open an issue and/or a PR.

@Peltoche
Copy link
Contributor Author

I think the issues is with group := router.Group("/", checkSharingPermissions) in replicatorRoutes matching all the routes in sharings.go.Router , router.POST("", CreateSharing) included.

I tried to remove this group and add the middleware to all the required paths

@Peltoche
Copy link
Contributor Author

And it works 🎊

@Peltoche Peltoche closed this by deleting the head repository May 22, 2023
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.

Different behaviour between POST /sharings and POST /sharings/ 404 when path includes double leading slashes
2 participants