Hi,

I am using Mongoose release 5.2 and trying to use a uri callback to 
implement Digest Auth to protect content (static and cgi) in /protected. I 
am using server.c as a starting point and the mongoose -A to create my 
passwords.txt file.

In my main function I register the following callback:

  //  Add handler/callback for protected content
  *mg_add_uri_handler(server, "/protected", protected_page);*

  while (exit_flag == 0) {
    mg_poll_server(server, 1000);
  }


 The protected_page handler (from the auth.c example) looks like:

static int protected_page(struct mg_connection *conn)
{
  static const char *passwords_file = 
"/home/ben/Downloads/mongoose-5.2/passwords.txt";  //temp location
  FILE *fp = fopen(passwords_file, "r");

  if (mg_authorize_digest(conn, fp)) {
    mg_printf_data(conn, "%s", "Hi, here is a secret message!");
  } else {
    mg_send_digest_auth_request(conn);
  }
  if (fp != NULL) {
    fclose(fp);
  }
  return 1;
}


So everything above works exactly as I would expect. If I try to access 
content in /protected I get challenged and enter credentials, the "Hi, here 
is a secret message!" is then transmitted.

What I want to do but can't seem to figure out, is to respond back on a 
successful call to mg_authorize_digest with the content pointed to by the 
uri in the request and not the hard-coded message. How do I do that?

Thanks,
Ben

-- 
You received this message because you are subscribed to the Google Groups 
"mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to