Arango auth and Foxx auth

240 views
Skip to first unread message

Dan Tomosoiu

unread,
Jun 25, 2014, 6:23:37 AM6/25/14
to aran...@googlegroups.com
Hello,

I have a question regarding the way Foxx is authorized to do its requests when authorization is enabled on arangod.

These are my auth settings in arangod.conf:

disable-authentication = false
authenticate-system-only = true

My plan is to have current REST requests towards arangodb be routed through Foxx, which would allow them only if the user is authenticated in the Foxx application, and forbid REST requests directly to arangodb.

This is an example of such a routing:

controller.put("/api/:paramA/:paramB", function (req, res, options, next) {
        var paramA = req.params("paramA");
        var paramB = req.params("paramB");
        if(paramA != "simle" || paramB != "all"){
            res.json({"bad request?"});
        } else {
            actions.redirectRequest(req, res, { destination: "http://localhost:8529/_db/MyDB/_api/" + paramA + "/" + paramB }, next);
        }
    }).onlyIfAuthenticated(401, "You are not authenticated");



This seemed to be working towards what I wanted, if authorization is disabled the routing works fine, but when I enable it, I get an authorization dialog which wants me to enter the credentials for MyDB database.
Am I missing something or did I understand "authenticate-system-only = true" poorly ? I was hoping that Foxx would be able to bypass that authorization, either by 'magic' (arangodb realising it's a trusted source) or by providing some credentials in the Foxx application itself (but not on the client) ?

Dan Tomosoiu

unread,
Jun 27, 2014, 8:57:38 AM6/27/14
to aran...@googlegroups.com
Bump ?

Frank Celler

unread,
Jun 27, 2014, 9:36:46 AM6/27/14
to aran...@googlegroups.com
Lucas is currently in Singapore. I hope he will be back on Monday.

Am Freitag, 27. Juni 2014 14:57:38 UTC+2 schrieb Dan Tomosoiu:
Bump ?

Dan Tomosoiu

unread,
Jun 27, 2014, 10:46:17 AM6/27/14
to aran...@googlegroups.com
I understand, thanks for the update.

Regards,
Dan

Frank Celler

unread,
Jul 1, 2014, 8:50:34 AM7/1/14
to aran...@googlegroups.com
Hi Dan,

I talked to Lucas and Alan. We think the problem is as follows: You have enabled authentication for the API. If you do a redirect, your browser will be redirected to the API page and therefore shows the password dialog.

Alan is currently working on a solution to share the users between foxx and API calls. But this currently not working.

Instead of redirect the request, you could rewrite it (see e. g. http://stackoverflow.com/questions/23603483/how-to-set-foxx-app-at-server-root). There is however a catch, it is not possible to rewrite some of the basic operations. You would not to implement an equivalent in Javascript.

Hope that explain the situation a little bit. If you need more information, please let us know.
  Frank

Dan Tomosoiu

unread,
Jul 1, 2014, 12:26:27 PM7/1/14
to aran...@googlegroups.com
Hi Frank,

Thanks again for the reply, I'll try to see if I can solve my problem using rewriting in the next few days, hopefully.
Still, it's good to hear that a solution for sharing users is being worked on, looking forward to being able to use that in the end.

Best regards,
Dan

Dan Tomosoiu

unread,
Aug 26, 2014, 6:55:33 AM8/26/14
to aran...@googlegroups.com
Hi Frank,

I still haven't found a way to make this work.

What should the next parameter of a rewriteRequest be ?

controller.get('/api/:paramA/:paramB/:paramC', function (req, res, options, next) {
        var paramA = req.params('paramA');
        var paramB = req.params('paramB');
        var paramC = req.params('paramC');
        if (paramA === 'document') {
            actions.rewriteRequest(req, res, { destination: "http://localhost:8529/_db/MyDB/_api/" + paramA + "/" + paramB + "/" + paramC}, next); //this fails because next is undefined
        } else {
            res.json({ "error": "bad request?" });
        }
    }).onlyIfAuthenticated(401, "You are not authenticated");


Also, are there any updates regarding the release of the new session functionality ?

Regards,
Dan

Frank Celler

unread,
Sep 1, 2014, 9:02:51 AM9/1/14
to aran...@googlegroups.com
Sorry, lost sight of that matter, Did you manage to solve it?

Dan Tomosoiu

unread,
Sep 1, 2014, 10:06:37 AM9/1/14
to aran...@googlegroups.com
No, almost lost all hope :(

Frank Celler

unread,
Sep 1, 2014, 12:42:32 PM9/1/14
to aran...@googlegroups.com
We will find a solution. I have to talk to Lucas to check how he can extend Foxx to support this.

Frank Celler

unread,
Sep 2, 2014, 4:43:42 AM9/2/14
to aran...@googlegroups.com
I have talk to Lucas. We will add an "around" method (similar to before and after) to the Foxx controller. Then you will be able to use it as follow:

  controller.around("/hallo", function (req, res, options, next) {
    actions.rewriteRequest(req, res, {
      destination: applicationContext.mount + "/hello"
    }, next);
  });

Frank Celler

unread,
Sep 4, 2014, 8:45:18 AM9/4/14
to aran...@googlegroups.com
The around method is available in ArangoDB 2.2.3, see https://www.arangodb.org/2014/09/04/arangodb-2-2-3

Dan Tomosoiu

unread,
Sep 5, 2014, 8:37:16 AM9/5/14
to aran...@googlegroups.com
Hi Frank,

Thanks very much for the update, I'm not working on this issue for the time being but it's good to know I'll be able to get 'around' it once I'll be back :)

Thank you, I really appreciate the work you're doing!

Regards,
Dan
Reply all
Reply to author
Forward
0 new messages