Welcome! Log In Create A New Profile

Advanced

Re: [ANNOUNCE] auth request module

agentzh
February 28, 2010 01:14AM
On Sun, Feb 28, 2010 at 3:00 AM, Maxim Dounin <mdounin@mdounin.ru> wrote:
> Here is auth request module, it allows authorization based on
> subrequest result.  It works at access phase and therefore may be
> nicely combined with other access modules (access, auth_basic) via
> satisfy directive.
>

This is really awesome!

But too sad the ngx_eval module can't work in subrequests itself so I
can not combine this with ngx_eval + ngx_drizzle + ngx_rds_json to do
mysql-based auth :)

It's mostly an issue in the ngx_eval, not your excellent
ngx_auth_request ;) Our ngx_srcache module will also take advantage of
subrequests to do response caching.

For now, I'm using something like this for mysql-based login and it
works on my machine [1]:

location = /auth {
default_type 'application/json';
eval_subrequest_in_memory off;
eval $res {
set_quote_sql_str $user $arg_user;
set_quote_sql_str $pass $arg_pass;
set $sql 'select count(*) res from users where name=$user
and passwd=$pass';
drizzle_query $sql;
drizzle_pass backend;
rds_json on;
rds_json_content_type application/octet-stream;
}
if ($res ~ '"res":1') {
echo "Cool! you're already logged in!";
}
if ($res !~ '"res":1') {
return 403;
}
}

where the "backend" upstream name used in the drizzle_pass directive
is defined like this:

upstream backend {
drizzle_server 127.0.0.1:3306 dbname=test
password=some_pass user=monty protocol=mysql;
drizzle_keepalive max=400 overflow=reject;
}

Then we can login the system by GET /auth?user=john&pass=some_pass.
Well, it's just a naive demonstration. Hopefully I'm not too OT :P

Cheers,
-agentzh

[1] Here we're using my fork of ngx_eval module (
http://github.com/agentzh/nginx-eval-module ) for two important
features: 1) capture outputs from arbitrary locations with output
filter support, 2) pass the parent request's query string (or "args")
into the eval block.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

[ANNOUNCE] auth request module

Maxim Dounin February 27, 2010 02:06PM

Re: [ANNOUNCE] auth request module

agentzh February 28, 2010 01:14AM

Re: [ANNOUNCE] auth request module

Valery Kholodkov March 01, 2010 04:40AM

Re: [ANNOUNCE] auth request module

agentzh March 11, 2010 05:10AM

Re: [ANNOUNCE] auth request module

amvtek March 11, 2010 12:04PM

Re: [ANNOUNCE] auth request module

Maxim Dounin March 11, 2010 12:40PM

Re: [ANNOUNCE] auth request module

amvtek March 12, 2010 02:53AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 307
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready