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

gives ability to custom url shorten provider #14

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

wilsonlmh
Copy link

It's a small upgrade gives ability to custom url shorten provider with following config:

config:
customUrl : the url will wrap with sprintf(), use %s as the source url, example http://shorten_server/add?url=%s
customJSON : extract value in JSON for returning, example: ->response->shortedURL note: '->' is required for array, this gives ability to access root level of JSON.

It use curl on server side to query the provider(it good for local server, more secure). I haven't test it yet bcoz im still working on my shorten script. However I don't have experience on writing owncloud plugin. Can you please help to do a fast review on it? Thanks!

config:
customUrl : the url will wrap with sprintf(), use %s as the source url, example http://shorten_server/add?url=%s
customJSON : extract value in JSON for returning, example: ->response->shortedURL note:  '->' is required for array, this gives ability to access root level of JSON.
long-en the var name in eval() to improve security hahaha
@wilsonlmh
Copy link
Author

I tested with some code correction, however it doesn't works.
Since I never write owncloud plugin before, I can't figure out where $_['xxx'] came from in /templates/admin.php and it cause error and stuck everything. :'(

@wilsonlmh
Copy link
Author

OK I figure out this, but something other happen: an error from log:
Array to string conversion at /var/www/sites/cloud.server4.home.luniz.info/lib/private/template/functions.php#36
However I don't know how to trace the issue bcoz i dun know how to debug in owncloud@@

@wilsonlmh
Copy link
Author

OK, the problem is about cross-origin now
My server is rewrite behind a front-end server(honestly, that's bcoz i dun hv a physical linux server). And I'm using radius-auth plugin with the tricks described here(add a require statement):
https://forum.owncloud.org/viewtopic.php?f=3&t=6543
The radius is works fine seems not a issue from there. And here is my debug log(I replaced my domain name):

Exception: {"Exception":"OC\\AppFramework\\Middleware\\Security\\SecurityException","Message":"CORS requires basic auth","Code":0,"Trace":"#0 \/var\/www\/sites\/my-owncloud-server.com\/lib\/private\/appframework\/middleware\/middlewaredispatcher.php(92): OC\\AppFramework\\Middleware\\Security\\CORSMiddleware->beforeController(Object(OCA\\Shorten\\Controller\\ShortenApiController), 'setval')\n#1 \/var\/www\/sites\/my-owncloud-server.com\/lib\/private\/appframework\/http\/dispatcher.php(88): OC\\AppFramework\\Middleware\\MiddlewareDispatcher->beforeController(Object(OCA\\Shorten\\Controller\\ShortenApiController), 'setval')\n#2 \/var\/www\/sites\/my-owncloud-server.com\/lib\/private\/appframework\/app.php(108): OC\\AppFramework\\Http\\Dispatcher->dispatch(Object(OCA\\Shorten\\Controller\\ShortenApiController), 'setval')\n#3 \/var\/www\/sites\/my-owncloud-server.com\/lib\/private\/appframework\/routing\/routeactionhandler.php(45): OC\\AppFramework\\App::main('ShortenApiContr...', 'setval', Object(OC\\AppFramework\\DependencyInjection\\DIContainer), Array)\n#4 [internal function]: OC\\AppFramework\\routing\\RouteActionHandler->__invoke(Array)\n#5 \/var\/www\/sites\/my-owncloud-server.com\/lib\/private\/route\/router.php(274): call_user_func(Object(OC\\AppFramework\\routing\\RouteActionHandler), Array)\n#6 \/var\/www\/sites\/my-owncloud-server.com\/lib\/base.php(874): OC\\Route\\Router->match('\/apps\/shorten\/s...')\n#7 \/var\/www\/sites\/my-owncloud-server.com\/index.php(40): OC::handleRequest()\n#8 {main}","File":"\/var\/www\/sites\/my-owncloud-server.com\/lib\/private\/appframework\/middleware\/security\/corsmiddleware.php","Line":86}

@wilsonlmh wilsonlmh changed the title gies ability to custom url shorten provider gives ability to custom url shorten provider Sep 23, 2015
@wilsonlmh
Copy link
Author

OK, I finally make it works! I will also publish my shorten site and api soon.

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.

1 participant