-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
I've tried to implement an App that has a PublicSharing function without extending the core/routes.php.
Steps to reproduce
- create a new app
- implement a controller that extends the AuthPublicShareController
- 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"}