diff options
author | goodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2000-09-18 21:42:37 +0000 |
---|---|---|
committer | goodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2000-09-18 21:42:37 +0000 |
commit | 3969eb0efd59f2942493ed273e82ba63bfe5cc3a (patch) | |
tree | db3192dee6697d99bd931ca445cb510a72076e3f | |
parent | 3ed49f02b7b2b3452d1fa8563781682235e89985 (diff) |
Added an extra two arguments to the authentication so it returns
the username of the person who authenticated (optionally).
Tom
git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@45 1faa4e14-9dd3-4be0-9f0e-ffe519881164
-rw-r--r-- | doc/Auth.txt | 10 | ||||
-rw-r--r-- | src/Authorisation.c | 8 | ||||
-rw-r--r-- | src/http_Auth.h | 4 |
3 files changed, 17 insertions, 5 deletions
diff --git a/doc/Auth.txt b/doc/Auth.txt index b1a2b34..cddda88 100644 --- a/doc/Auth.txt +++ b/doc/Auth.txt @@ -33,12 +33,16 @@ web page to be encrypted. The other function is int HTTP_AuthenticateBasic(httpRequest *request, - const char *database); + const char *database, + char *user, + int length); which takes an HTTP request, and a password database, and sees if the 'Authorization' header field declares a user and password which are in the database. This function supports the 'Basic' authentication -scheme supplied by HTTP/1.0. +scheme supplied by HTTP/1.0. It will also, if 'user' is not null, +pass back the name of the user who authenticated if that isn't longer +than length. This function has three possible return codes. @@ -63,7 +67,7 @@ if the configuration supports crypt(3) passwords. Then when a page comes in, one does - notauthorised = HTTP_AuthenticateBasic(request, "users"); + notauthorised = HTTP_AuthenticateBasic(request, "users", NULL, 0); if(!notauthorised) { diff --git a/src/Authorisation.c b/src/Authorisation.c index 883dff8..92a6a27 100644 --- a/src/Authorisation.c +++ b/src/Authorisation.c @@ -156,7 +156,9 @@ int HTTP_AuthAddUser(const char *database, @@*/ int HTTP_AuthenticateBasic(httpRequest *request, - const char *database) + const char *database, + char *user, + int length) { int retval; char message[1024]; @@ -203,6 +205,10 @@ int HTTP_AuthenticateBasic(httpRequest *request, password++; authorised = VerifyPassword(database, decoded, password); + if(user && strlen(user) < decoded_size) + { + sprintf(user,"%s", decoded); + } } } } diff --git a/src/http_Auth.h b/src/http_Auth.h index 89442ec..c5bf70e 100644 --- a/src/http_Auth.h +++ b/src/http_Auth.h @@ -22,7 +22,9 @@ int HTTP_AuthAddUser(const char *database, const char *encryption_scheme); int HTTP_AuthenticateBasic(httpRequest *request, - const char *database); + const char *database, + char *user, + int length); #ifdef __cplusplus } |