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

AuthPublicShareController generates the wrong routes #19475

Closed
Tim-Obert opened this issue Feb 14, 2020 · 5 comments · Fixed by #19478
Closed

AuthPublicShareController generates the wrong routes #19475

Tim-Obert opened this issue Feb 14, 2020 · 5 comments · Fixed by #19478
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug

Comments

@Tim-Obert
Copy link
Contributor

I've tried to implement an App that has a PublicSharing function without extending the core/routes.php.

Steps to reproduce

  1. create a new app
  2. implement a controller that extends the AuthPublicShareController
  3. define the routes for the controller in the appinfo/routes.php:
        ['name' => 'auth_secret_share#showShare', 'url' => '/secret/{token}', 'verb' => 'GET'],
        ['name' => 'auth_secret_share#showAuthenticate', 'url' => '/secret/{token}/authenticate/{redirect}', 'verb' => 'GET'],
        ['name' => 'auth_secret_share#authenticate', 'url' => '/secret/{token}/authenticate/{redirect}', 'verb' => 'POST'],

Expected behaviour

The controller functions should be accessible via /apps/<app_namespace>/<defined_route>.

Actual behaviour

An Error is logged:
Symfony\Component\Routing\Exception\RouteNotFoundException: Unable to generate a URL for the named route “<my_namespace>.<controller_class_name>.showAuthenticate” as such route does not exist.
https://github.com/nextcloud/server/blob/master/lib/public/AppFramework/AuthPublicShareController.php#L159-L168
The route in the Controller is build with the classname so it has to be defined in the core/routes.php because the syntax there is the whole classname.
The name of my controller is AuthSecretShareController and the namespace of my app is wcoonetimesecret so the route for the URLGenerator is build:
wcoonetimesecret.authsecretsharecontroller.showAuthenticate
the right route would be:
wcoonetimesecret.auth_secret_share.showAuthenticate

Server configuration

Nextcloud version: 18.0.0

Logs

Nextcloud log (data/nextcloud.log)

Nextcloud log
{"reqId":"THqNmaUGOsKLKIPRQqHP","level":3,"time":"2020-02-14T10:10:03+00:00","remoteAddr":"172.19.0.6","user":"admin","app":"no app in context","method":"GET","url":"/apps/wcoonetimesecret/secret/7","message":{"Exception":"Symfony\\Component\\Routing\\Exception\\RouteNotFoundException","Message":"Unable to generate a URL for the named route \"wcoonetimesecret.AuthSecretShareController.showAuthenticate\" as such route does not exist.","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Route/Router.php","line":339,"function":"generate","class":"Symfony\\Component\\Routing\\Generator\\UrlGenerator","type":"->","args":["wcoonetimesecret.AuthSecretShareController.showAuthenticate",{"token":"7","redirect":"showShare"},1]},{"file":"/var/www/html/lib/private/URLGenerator.php","line":82,"function":"generate","class":"OC\\Route\\Router","type":"->","args":["wcoonetimesecret.AuthSecretShareController.showAuthenticate",{"token":"7","redirect":"showShare"}]},{"file":"/var/www/html/lib/public/AppFramework/AuthPublicShareController.php","line":155,"function":"linkToRoute","class":"OC\\URLGenerator","type":"->","args":["wcoonetimesecret.AuthSecretShareController.showAuthenticate",{"token":"7","redirect":"showShare"}]},{"file":"/var/www/html/lib/private/AppFramework/Middleware/PublicShare/PublicShareMiddleware.php","line":106,"function":"getAuthenticationRedirect","class":"OCP\\AppFramework\\AuthPublicShareController","type":"->","args":["showShare"]},{"file":"/var/www/html/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php","line":121,"function":"afterException","class":"OC\\AppFramework\\Middleware\\PublicShare\\PublicShareMiddleware","type":"->","args":[{"__class__":"OCA\\WcoOneTimeSecret\\Controller\\AuthSecretShareController"},"showShare",{"__class__":"OC\\AppFramework\\Middleware\\PublicShare\\Exceptions\\NeedAuthenticationException"}]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":107,"function":"afterException","class":"OC\\AppFramework\\Middleware\\MiddlewareDispatcher","type":"->","args":[{"__class__":"OCA\\WcoOneTimeSecret\\Controller\\AuthSecretShareController"},"showShare",{"__class__":"OC\\AppFramework\\Middleware\\PublicShare\\Exceptions\\NeedAuthenticationException"}]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":125,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\WcoOneTimeSecret\\Controller\\AuthSecretShareController"},"showShare"]},{"file":"/var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["AuthSecretShareController","showShare",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"token":"7","_route":"wcoonetimesecret.auth_secret_share.showShare"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"token":"7","_route":"wcoonetimesecret.auth_secret_share.showShare"}]},{"file":"/var/www/html/lib/private/Route/Router.php","line":299,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"token":"7","_route":"wcoonetimesecret.auth_secret_share.showShare"}]},{"file":"/var/www/html/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/wcoonetimesecret/secret/7"]},{"file":"/var/www/html/index.php","line":38,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/3rdparty/symfony/routing/Generator/UrlGenerator.php","Line":144,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36","version":"18.0.0.10"}
@Tim-Obert Tim-Obert added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Feb 14, 2020
@Rello
Copy link
Contributor

Rello commented Feb 14, 2020

Hello,

I would say the route needs to match your actual controller implementation

either:

['name' => 'auth_secret_share#showAuthenticate', 'url' => '/secret/{token}/authenticate/{redirect}', 'verb' => 'GET'],
+ 
Auth_Secret_ShareController

(not sure about capital letters when using _ here)

or

['name' => 'authsecretshare#showAuthenticate', 'url' => '/secret/{token}/authenticate/{redirect}', 'verb' => 'GET'],
+ 
AuthsecretshareController

@nickvergessen
Copy link
Member

I think you need to use the following: AuthSecretShare#showAuthenticate

At least that works for the Talk app:
https://github.com/nextcloud/spreed/blob/master/appinfo/routes.php#L334

@Tim-Obert
Copy link
Contributor Author

The Talk app doesn't implement a controller that extends the AuthSecretShare controller. I fixed the issue in my pull request #19478. With the changes everything is working fine.

@nickvergessen
Copy link
Member

But I don't understand how extending another class would break anything.
Do you mind to share your app code? If you don't want to make it public feel free to send a link to <my gihub name>@nextcloud.com

@nickvergessen
Copy link
Member

ah, now I saw it. the controller is doing mess...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants