node-odata icon indicating copy to clipboard operation
node-odata copied to clipboard

Async Auth support

Open emathias opened this issue 8 years ago • 1 comments

Hi,

As of now, the implementation of node-odata requires 'auth' to be synchronous, as it has to return true or false. (as described here: http://tossshinhwa.github.io/node-odata/en/#51-resource)

In realistic scenarios, checking auth may usually entail some async operation (checking DB, etc) and because of the async nature of node, a control flow as express middleware (using next() ) seems more appropriate.

What do you think ?

Best,

emathias avatar May 12 '17 12:05 emathias

Hi @emathias

There has another way to implement this.

You can add middleware to handle auth check, it support async function, and put the result into req, then auth hook just check this field.

Here is a example: middleware, auth hook.

But it can not solve some complex scene problems, such as data permissions check, I will try to let it become to a async function later.

Thank you.

zackyang000 avatar May 13 '17 02:05 zackyang000