Welcome! Log In Create A New Profile

Advanced

ngx modul development - how modul context works

Posted by Kukaac 
ngx modul development - how modul context works
February 01, 2012 07:07AM
Hi,

I'm working on a NTLM authentication module. It works fine except one small problem:
NTLM is challenge-response authentication:
1 - the client sends a request for the authentication
2 - the server send a randomly generated key (challenge)
3 - the client sends the password encoded with the challenge

My problem is, that it takes 2 requests to process the authentication.
In the first request I create a module_context:

typedef struct {
char *challenge;
char *user;
char *domain;
char *password;
int auth_ok;
unsigned int ntlmssp_flags;
} ngx_http_auth_ntlm_ctx_t;

...

ngx_http_auth_ntlm_ctx_t *ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_auth_ntlm_ctx_t));
ngx_http_set_ctx(r, ctx, ngx_http_auth_ntlm_module);

In the second request, when I am trying to get the module context I'm getting a new context, which is NULL:

ctx = ngx_http_get_module_ctx(r, ngx_http_auth_ntlm_module); // ==NULL

I have to remember the challenge from the first request for each connection, to be able to check the password.Is there any way to save the context to a client connection and not only for one request?

Any help would be greatly appreciated.
Kukaac
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 258
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